Refactor doom/cleanup-session & corresponding evil command
This commit is contained in:
parent
69385fac1a
commit
ab0223144c
2 changed files with 18 additions and 8 deletions
|
@ -242,18 +242,19 @@ project."
|
|||
(message "Killed %s buffers" n))))
|
||||
|
||||
;;;###autoload
|
||||
(defun doom/cleanup-session (&optional all-p)
|
||||
(defun doom/cleanup-session (&optional all-p interactive-p)
|
||||
"Clean up buried buries and orphaned processes in the current workspace. If
|
||||
ALL-P (universal argument), clean them up globally."
|
||||
(interactive "P")
|
||||
(run-hooks 'doom-cleanup-hook)
|
||||
(interactive (list current-prefix-arg 'interactive))
|
||||
(let ((buffers (doom-buried-buffers (if all-p (buffer-list))))
|
||||
(n 0)
|
||||
kill-buffer-query-functions)
|
||||
(mapc #'kill-buffer buffers)
|
||||
(setq n (+ n (length buffers) (doom/cleanup-processes)))
|
||||
(when (called-interactively-p 'interactive)
|
||||
(message "Cleaned up %s buffers" n))))
|
||||
(run-hooks 'doom-cleanup-hook)
|
||||
(when interactive-p
|
||||
(message "Cleaned up %s buffers" n))
|
||||
n))
|
||||
|
||||
;;;###autoload
|
||||
(defun doom/cleanup-processes ()
|
||||
|
|
|
@ -2,6 +2,15 @@
|
|||
|
||||
(defalias 'ex! 'evil-ex-define-cmd)
|
||||
|
||||
(evil-define-command doom:cleanup-session (&optional bang)
|
||||
(interactive "<!>")
|
||||
(doom/cleanup-session bang))
|
||||
|
||||
|
||||
;;
|
||||
;; Commands
|
||||
;;
|
||||
|
||||
;;; Commands defined elsewhere
|
||||
;;(ex! "al[ign]" #'+evil:align)
|
||||
;;(ex! "g[lobal]" #'+evil:global)
|
||||
|
@ -39,7 +48,7 @@
|
|||
(ex! "gblame" #'magit-blame)
|
||||
(ex! "grevert" #'git-gutter:revert-hunk)
|
||||
;; Dealing with buffers
|
||||
(ex! "clean[up]" #'doom/cleanup-session)
|
||||
(ex! "clean[up]" #'doom:cleanup-session)
|
||||
(ex! "k[ill]" #'doom/kill-this-buffer)
|
||||
(ex! "k[ill]all" #'+default:kill-all-buffers)
|
||||
(ex! "k[ill]m" #'+default:kill-matching-buffers)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue