abo-abo / ace-window

Quickly switch windows in Emacs
984 stars 87 forks source link

`aw--done` assumes all buffers in `aw-empty-buffers-list` are still alive #242

Open mentalisttraceur opened 1 year ago

mentalisttraceur commented 1 year ago

aw--done goes through the buffers in aw-empty-buffers-list, but doesn't handle the possibility of them getting killed since they were added to the list.

aw--done could fix this with a simple buffer-live-p check:

   (dolist (b aw-empty-buffers-list)
+    (when (buffer-live-p b)
       (with-current-buffer b
         (when (string= (buffer-string) " ")
           (let ((inhibit-read-only t))
             (delete-region (point-min) (point-max))))))
+    )

In the meantime, for anyone else hitting this problem, here's the workaround I'm using:

(defun fixed-aw--done (&rest _)
    (setq aw-empty-buffers-list
        (seq-filter 'buffer-live-p aw-empty-buffers-list)))
(advice-add 'aw--done :before 'fixed-aw--done)