diff options
author | John Ankarström <john@ankarstrom.se> | 2022-08-27 02:01:43 +0200 |
---|---|---|
committer | John Ankarström <john@ankarstrom.se> | 2022-08-27 02:01:43 +0200 |
commit | 2f10a264ab96bf53342c9e0042b7d9fedb60ce7f (patch) | |
tree | 84768201fa7bd27c231f6f43f32ce621108e5019 /eb.el | |
parent | 271a8bfa2ed3c5ea864cfb9183b568508f8177e0 (diff) | |
download | EpisodeBrowser-2f10a264ab96bf53342c9e0042b7d9fedb60ce7f.tar.gz |
eb.el: Add eb-quit-or-bury.
Diffstat (limited to 'eb.el')
-rw-r--r-- | eb.el | 41 |
1 files changed, 27 insertions, 14 deletions
@@ -46,17 +46,19 @@ "List project buffers." (interactive "P") (require 'projectile) - (let ((buffer - (list-buffers-noselect (not arg) - (if arg - (projectile-project-buffers) - (mapcan - (lambda (b) (and (buffer-file-name b) (list b))) - (projectile-project-buffers)))))) - (display-buffer-in-direction buffer '((direction . up))) - (select-window (get-buffer-window buffer)) - (with-current-buffer buffer - (setq-local eb--list-buffers t)))) + (if eb--list-buffers + (quit-window) + (let ((buffer + (list-buffers-noselect (not arg) + (if arg + (projectile-project-buffers) + (mapcan + (lambda (b) (and (buffer-file-name b) (list b))) + (projectile-project-buffers)))))) + (display-buffer-in-direction buffer '((direction . up))) + (select-window (get-buffer-window buffer)) + (with-current-buffer buffer + (setq-local eb--list-buffers t))))) (define-advice Buffer-menu-mouse-select (:around (f event) eb-list-buffers) (if eb--list-buffers @@ -71,7 +73,18 @@ (defun eb-dired () "Open the root of the current project with `dired'." (interactive) - (dired (project-root (project-current)))) + (let ((project-root (project-root (project-current)))) + (if (and (eq major-mode 'dired-mode) (equal default-directory project-root)) + (bury-buffer) + (dired project-root)))) + +;;;###autoload +(defun eb-quit-or-bury () + "Quit window or bury buffer." + (interactive) + (if (window-parameter (selected-window) 'quit-restore) + (quit-window) + (bury-buffer))) (defvar-local eb-tool-bar-mode--old-map nil) (defvar-local eb-tool-bar-mode--old-back-button-mode nil) @@ -90,8 +103,8 @@ (back-button-mode 1) (setq-local back-button-show-toolbar-buttons nil) (let ((map (make-sparse-keymap))) - (tool-bar-local-item "close" #'bury-buffer 'bury-buffer map - :label "Bury" :help "Bury buffer") + (tool-bar-local-item "close" #'eb-quit-or-bury 'quit-or-bury map + :label "Bury" :help "Bury buffer or window") (tool-bar-local-item "index" #'eb-list-buffers 'list-buffers map :label "Buffers" :help "Show project buffers") (tool-bar-local-item "diropen" #'eb-dired 'dired map |