Output feedback from buffer/session kill commands

This commit is contained in:
Henrik Lissner 2019-12-21 02:24:11 -05:00
parent 491e80a568
commit a49c0b6691
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395
2 changed files with 37 additions and 24 deletions

View file

@ -272,6 +272,12 @@ If DONT-SAVE, don't prompt to save modified buffers (discarding their changes)."
(set-buffer-modified-p nil))) (set-buffer-modified-p nil)))
(doom-kill-buffer-fixup-windows buffer)) (doom-kill-buffer-fixup-windows buffer))
(defun doom--message-or-count (interactive message count)
(if interactive
(message message count)
count))
;;;###autoload ;;;###autoload
(defun doom/kill-all-buffers (&optional buffer-list interactive) (defun doom/kill-all-buffers (&optional buffer-list interactive)
"Kill all buffers and closes their windows. "Kill all buffers and closes their windows.
@ -290,10 +296,10 @@ belong to the current project."
(when (memq (current-buffer) buffer-list) (when (memq (current-buffer) buffer-list)
(switch-to-buffer (doom-fallback-buffer))) (switch-to-buffer (doom-fallback-buffer)))
(mapc #'kill-buffer buffer-list) (mapc #'kill-buffer buffer-list)
(when interactive (doom--message-or-count
(message "Killed %s buffers" interactive "Killed %d buffers"
(- (length buffer-list) (- (length buffer-list)
(length (cl-remove-if-not #'buffer-live-p buffer-list))))))) (length (cl-remove-if-not #'buffer-live-p buffer-list))))))
;;;###autoload ;;;###autoload
(defun doom/kill-other-buffers (&optional buffer-list interactive) (defun doom/kill-other-buffers (&optional buffer-list interactive)
@ -308,10 +314,10 @@ project."
(doom-buffer-list))) (doom-buffer-list)))
t)) t))
(mapc #'doom-kill-buffer-and-windows buffer-list) (mapc #'doom-kill-buffer-and-windows buffer-list)
(when interactive (doom--message-or-count
(message "Killed %s buffers" interactive "Killed %d other buffers"
(- (length buffer-list) (- (length buffer-list)
(length (cl-remove-if-not #'buffer-live-p buffer-list)))))) (length (cl-remove-if-not #'buffer-live-p buffer-list)))))
;;;###autoload ;;;###autoload
(defun doom/kill-matching-buffers (pattern &optional buffer-list interactive) (defun doom/kill-matching-buffers (pattern &optional buffer-list interactive)
@ -341,10 +347,10 @@ current project."
(if current-prefix-arg (doom-project-buffer-list))) (if current-prefix-arg (doom-project-buffer-list)))
t)) t))
(mapc #'kill-buffer buffer-list) (mapc #'kill-buffer buffer-list)
(when interactive (doom--message-or-count
(message "Killed %s buried buffers" interactive "Killed %d buried buffers"
(- (length buffer-list) (- (length buffer-list)
(length (cl-remove-if-not #'buffer-live-p buffer-list)))))) (length (cl-remove-if-not #'buffer-live-p buffer-list)))))
;;;###autoload ;;;###autoload
(defun doom/kill-project-buffers (project &optional interactive) (defun doom/kill-project-buffers (project &optional interactive)
@ -362,9 +368,9 @@ current project."
nil) nil)
t)) t))
(when project (when project
(let ((buffers (doom-project-buffer-list project))) (let ((buffer-list (doom-project-buffer-list project)))
(doom-kill-buffers-fixup-windows buffers) (doom-kill-buffers-fixup-windows buffer-list)
(when interactive (doom--message-or-count
(message "Killed %d buffer(s)" interactive "Killed %d project buffers"
(- (length buffers) (- (length buffer-list)
(length (cl-remove-if-not #'buffer-live-p buffers)))))))) (length (cl-remove-if-not #'buffer-live-p buffer-list)))))))

View file

@ -268,13 +268,20 @@ workspace to delete."
('error (+workspace-error ex t)))) ('error (+workspace-error ex t))))
;;;###autoload ;;;###autoload
(defun +workspace/kill-session () (defun +workspace/kill-session (&optional interactive)
"Delete the current session, all workspaces, windows and their buffers." "Delete the current session, all workspaces, windows and their buffers."
(interactive) (interactive (list t))
(let ((windows (length (window-list)))
(persps (length (+workspace-list-names)))
(buffers 0))
(let ((persp-autokill-buffer-on-remove t))
(unless (cl-every #'+workspace-delete (+workspace-list-names)) (unless (cl-every #'+workspace-delete (+workspace-list-names))
(+workspace-error "Could not clear session")) (+workspace-error "Could not clear session")))
(+workspace-switch +workspaces-main t) (+workspace-switch +workspaces-main t)
(doom/kill-all-buffers (buffer-list))) (setq buffers (doom/kill-all-buffers (buffer-list)))
(when interactive
(message "Killed %d workspace(s), %d window(s) & %d buffer(s)"
persps windows buffers))))
;;;###autoload ;;;###autoload
(defun +workspace/kill-session-and-quit () (defun +workspace/kill-session-and-quit ()