aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--eb.el41
1 files changed, 27 insertions, 14 deletions
diff --git a/eb.el b/eb.el
index 4d9b430..7477372 100644
--- a/eb.el
+++ b/eb.el
@@ -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