Smarter buffer killing (don't end up in unreal buffers)

This commit is contained in:
Henrik Lissner 2016-02-19 12:36:40 -05:00
parent 0d5493b45e
commit da80479292

View file

@ -141,7 +141,7 @@ the buffer if it is being displayed in another window."
(message "Killed %s matches" i))) (message "Killed %s matches" i)))
;;;###autoload ;;;###autoload
(defun narf/cycle-real-buffers (&optional n scratch-default) (defun narf/cycle-real-buffers (&optional n)
"Switch to the previous buffer and avoid special buffers. If there's nothing "Switch to the previous buffer and avoid special buffers. If there's nothing
left, create a scratch buffer." left, create a scratch buffer."
(let* ((start-buffer (current-buffer)) (let* ((start-buffer (current-buffer))
@ -158,12 +158,12 @@ left, create a scratch buffer."
(switch-to-buffer "*scratch*") (switch-to-buffer "*scratch*")
(message "Nowhere to go")) (message "Nowhere to go"))
(funcall move-func) (funcall move-func)
(while (and continue (< i max)) (while (and continue )
(let ((current-buffer (current-buffer))) (let ((current-buffer (current-buffer)))
(cond ((eq current-buffer start-buffer) (cond ((or (eq current-buffer start-buffer)
(when scratch-default (>= i max))
(narf|update-scratch-buffer-cwd) (narf|update-scratch-buffer-cwd)
(switch-to-buffer "*scratch*")) (switch-to-buffer "*scratch*")
(setq continue nil)) (setq continue nil))
((not (memq current-buffer real-buffers)) ((not (memq current-buffer real-buffers))
(funcall move-func)) (funcall move-func))