doom-force-kill-buffer => doom/kill-this-buffer-in-all-windows

This commit is contained in:
Henrik Lissner 2017-12-30 00:55:11 -05:00
parent 6279241ec3
commit f61d7c9e7f
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395
2 changed files with 16 additions and 14 deletions

View file

@ -186,19 +186,6 @@ See `doom-real-buffer-p' for what 'real' means."
(kill-buffer buffer))) (kill-buffer buffer)))
(not (eq (current-buffer) buffer)))) (not (eq (current-buffer) buffer))))
;;;###autoload
(defun doom-force-kill-buffer (&optional buffer dont-save)
"Kill BUFFER globally and ensure all windows previously showing BUFFER have
switched to a real buffer."
(interactive)
(let* ((buffer (or buffer (current-buffer)))
(windows (get-buffer-window-list buffer nil t)))
(doom-kill-buffer buffer dont-save)
(dolist (win windows)
(with-selected-window win
(unless (doom-real-buffer-p)
(doom/previous-buffer))))))
;;;###autoload ;;;###autoload
(defun doom-kill-buffer-and-windows (buffer) (defun doom-kill-buffer-and-windows (buffer)
"Kill the buffer and delete all the windows it's displayed in." "Kill the buffer and delete all the windows it's displayed in."
@ -239,6 +226,21 @@ regex PATTERN. Returns the number of killed buffers."
(when (and (not (doom-kill-buffer)) interactive-p) (when (and (not (doom-kill-buffer)) interactive-p)
(message "Nowhere left to go!"))) (message "Nowhere left to go!")))
;;;###autoload
(defun doom/kill-this-buffer-in-all-windows (buffer &optional dont-save)
"Kill BUFFER globally and ensure all windows previously showing this buffer
have switched to a real buffer.
If DONT-SAVE, don't prompt to save modified buffers (discarding their changes)."
(interactive
(list (current-buffer) current-prefix-arg))
(cl-assert (bufferp buffer) t)
(let ((windows (get-buffer-window-list buffer nil t)))
(doom-kill-buffer buffer dont-save)
(cl-loop for win in windows
if (doom-real-buffer-p (window-buffer win))
do (with-selected-window win (doom/previous-buffer)))))
;;;###autoload ;;;###autoload
(defun doom/kill-all-buffers (&optional project-p) (defun doom/kill-all-buffers (&optional project-p)
"Kill all buffers and closes their windows. "Kill all buffers and closes their windows.

View file

@ -35,7 +35,7 @@ kills the buffer. If FORCE-P, force the deletion (don't ask for confirmation)."
(error "Failed to delete %s" short-path) (error "Failed to delete %s" short-path)
;; Ensures that windows displaying this buffer will be switched ;; Ensures that windows displaying this buffer will be switched
;; to real buffers (`doom-real-buffer-p') ;; to real buffers (`doom-real-buffer-p')
(doom-force-kill-buffer buf t) (doom/kill-this-buffer-in-all-windows buf t)
(+evil--forget-file fname) (+evil--forget-file fname)
(message "Successfully deleted %s" short-path)))))))) (message "Successfully deleted %s" short-path))))))))