aboutsummaryrefslogtreecommitdiff
path: root/eb.el
diff options
context:
space:
mode:
authorJohn Ankarström <john@ankarstrom.se>2022-08-27 21:28:40 +0200
committerJohn Ankarström <john@ankarstrom.se>2022-08-27 21:28:40 +0200
commitfa9aa6a4418c77ac2a7c03cc73cfecc6caddb4ad (patch)
tree0da2179346644b4c0fc52ae297fe2693f9245024 /eb.el
parentff566993defe78a705173ab7ba883c19b37c8143 (diff)
downloadEpisodeBrowser-fa9aa6a4418c77ac2a7c03cc73cfecc6caddb4ad.tar.gz
eb.el: Add eb-bookmarks.
Diffstat (limited to 'eb.el')
-rw-r--r--eb.el66
1 files changed, 47 insertions, 19 deletions
diff --git a/eb.el b/eb.el
index c9877c9..60df634 100644
--- a/eb.el
+++ b/eb.el
@@ -4,7 +4,9 @@
;;; Code:
-(defgroup eb nil "Episode Browser development environment")
+(defgroup eb nil
+ "Episode Browser development package."
+ :prefix "eb-")
;;;###autoload
(defun eb-quit-or-bury ()
@@ -20,6 +22,9 @@
(interactive)
(switch-to-buffer (last-buffer)))
+(defvar-local eb--list-buffers nil)
+(defvar-local eb--bookmarks nil)
+
;;;###autoload
(defun eb-list-buffers (&optional arg all)
"List project buffers. By default, only file buffers are shown."
@@ -38,7 +43,7 @@
(display-buffer-in-direction buffer '((direction . up)))
(select-window (get-buffer-window buffer))
(with-current-buffer buffer
- (setq-local eb--list-buffers t)))))
+ (setq eb--list-buffers t)))))
;;;###autoload
(defun eb-list-buffers-all (&optional arg)
@@ -56,6 +61,36 @@
(funcall f event)))
;;;###autoload
+(defun eb-bookmarks ()
+ "Show bookmarks."
+ (interactive)
+ (require 'bookmark)
+ (if eb--bookmarks
+ (quit-window)
+ (bookmark-maybe-load-default-file)
+ (let ((buffer (get-buffer-create bookmark-bmenu-buffer)))
+ (display-buffer-in-direction buffer '((direction . up)))
+ (select-window (get-buffer-window buffer))
+ (with-current-buffer buffer
+ (bookmark-bmenu-mode)
+ (bookmark-bmenu--revert)
+ (bookmark-bmenu-list)
+ (setq eb--bookmarks t)))))
+
+(define-advice bookmark-bmenu-this-window (:around (f) eb-bookmarks)
+ (if eb--bookmarks
+ (progn
+ (let ((window (selected-window)))
+ (bookmark-bmenu-other-window)
+ (quit-window nil window)))
+ (funcall f)))
+
+(define-advice bookmark-bmenu-other-window-with-mouse (:around (f event) eb-list-buffers)
+ (funcall f event)
+ (when eb--bookmarks
+ (quit-window nil (posn-window (event-end event)))))
+
+;;;###autoload
(defun eb-dired (&optional dir)
"Open the root of the current project in `dired'."
(interactive)
@@ -118,8 +153,6 @@
(quit-window))
(display-buffer buf)))
-(defvar-local eb--list-buffers nil)
-
;;;###autoload
(defun eb-compile ()
"Compile project without prompt. Use `eb-system'."
@@ -170,21 +203,16 @@
(customize-group 'eb))
(defvar-local eb-tool-bar-mode--old-map nil)
-(defvar-local eb-tool-bar-mode--old-back-button-mode nil)
-(defvar-local eb-tool-bar-mode--old-back-button-show-toolbar-buttons nil)
;;;###autoload
(define-minor-mode eb-tool-bar-mode
- "Useful tool bar buttons."
+ "Episode Browser development tool bar."
:lighter " EB"
(if eb-tool-bar-mode
(progn
(setq eb-tool-bar-mode--old-map tool-bar-map)
(when (require 'back-button nil t)
- (setq eb-tool-bar-mode--old-back-button-mode back-button-mode)
- (setq eb-tool-bar-mode--old-back-button-show-toolbar-buttons back-button-show-toolbar-buttons)
- (back-button-mode 1)
- (setq-local back-button-show-toolbar-buttons nil))
+ (back-button-mode 1))
(let ((map (make-sparse-keymap)))
;; Windows, buffers and files.
@@ -198,6 +226,8 @@
(tool-bar-local-item "diropen" #'eb-dired 'dired map
:label "Root" :help "Browse project root")
(define-key map [(shift dired)] #'eb-dired-here)
+ (tool-bar-local-item "next-page" #'eb-bookmarks 'bookmarks map
+ :label "Bookmarks" :help "Show bookmarks")
(tool-bar-local-item "search-replace" #'eb-grep 'grep map
:label "Grep" :help "Grep project")
@@ -207,7 +237,7 @@
:label "Run" :help "Run executable")
(tool-bar-local-item "refresh" #'eb-compile 'compile map
:label "Compile" :help "Compile project")
- (tool-bar-local-item "info" #'eb-check 'check map
+ (tool-bar-local-item "spell" #'eb-check 'check map
:label "Check" :help "Check warnings and errors")
(define-key map [(shift check)] #'flycheck-buffer)
(define-key map [(control check)] #'flycheck-mode)
@@ -218,13 +248,13 @@
(when (require 'back-button nil t)
(define-key-after map [separator-2] menu-bar-separator)
(tool-bar-local-item "left-arrow" #'back-button-global-backward 'previous-mark map
- :label "Previous Mark" :help "Previous Mark")
+ :label "Previous Mark" :help "Go to previous mark")
(define-key map [(shift previous-mark)] #'back-button-local-backward)
(tool-bar-local-item "mpc/add" #'back-button-push-mark-local-and-global 'push-mark map
- :label "Push Mark" :help "Push Mark")
+ :label "Push Mark" :help "Push mark")
(define-key map [(shift push-mark)] #'back-button-push-mark)
(tool-bar-local-item "right-arrow" #'back-button-global-forward 'next-mark map
- :label "Next Mark" :help "Next Mark")
+ :label "Next Mark" :help "Go to next mark")
(define-key map [(shift next-mark)] #'back-button-local-forward))
;; Miscellaneous.
@@ -234,11 +264,9 @@
(setq-local tool-bar-map map)))
(setq-local tool-bar-map eb-tool-bar-mode--old-map)
- (when (require 'back-button nil t)
- (if (not eb-tool-bar-mode--old-back-button-mode)
- (back-button-mode 0))
- (setq-local back-button-show-toolbar-buttons eb-tool-bar-mode--old-back-button-show-toolbar-buttons))))
+ (back-button-mode 0)))
+;;;###autoload
(define-global-minor-mode global-eb-tool-bar-mode eb-tool-bar-mode
(lambda () (eb-tool-bar-mode 1))
:group 'eb)