-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathcc-bookmarks-bmenu-mode.el
135 lines (107 loc) · 4.53 KB
/
cc-bookmarks-bmenu-mode.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
;;; cc-bookmarks-bmenu-mode.el --- Bookmarks Bmenu Mode Config -*- lexical-binding: t; -*-
;; Copyright (C) 2024 Charles Choi
;; Author: Charles Choi <[email protected]>
;; Keywords: tools
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <https://www.gnu.org/licenses/>.
;;; Commentary:
;;
;;; Code:
(require 'hl-line)
(require 'bookmark)
(require 'transient)
(require 'tabulated-list)
(require 'cc-main-tmenu)
(require 'casual-lib)
(add-hook 'bookmark-bmenu-mode-hook #'hl-line-mode)
(transient-define-prefix cc/bookmark-bmenu-tmenu ()
"CC Bookmark Transient menu."
[["Open"
("o" "Other window" bookmark-bmenu-other-window :transient nil)
("v" "Marked" bookmark-bmenu-select :transient nil)]
["Edit"
("r" "Rename…" bookmark-bmenu-rename :transient nil)
("R" "Relocate…" bookmark-bmenu-relocate :transient nil)]
["Mark"
("m" "Mark" bookmark-bmenu-mark :transient t)
("M" "Mark all" bookmark-bmenu-mark-all :transient t)
("u" "Unmark" bookmark-bmenu-unmark :transient t)
("U" "Unmark all" bookmark-bmenu-unmark-all :transient t)]
["Misc"
("/" "Filter…" bookmark-bmenu-search :transient t)
("w" "Show location" bookmark-bmenu-locate :transient t)]
["Navigate"
("p" "↑" previous-line :transient t)
("n" "↓" next-line :transient t)
("<" "⤒" beginning-of-buffer :transient t)
(">" "⤓" end-of-buffer :transient t)]]
[["Annotation"
("e" "Edit" bookmark-bmenu-edit-annotation :transient nil)
("a" "Show" bookmark-bmenu-show-annotation :transient nil)
("A" "Show All" bookmark-bmenu-show-all-annotations :transient nil)]
["Delete"
("d" "To delete" bookmark-bmenu-delete :transient t)
("D" "All to delete" bookmark-bmenu-delete-all :transient t)
("x" "Delete marked" bookmark-bmenu-execute-deletions :transient t)]
["Display"
("s" "Sort by›" cc/bookmark-bmenu-sortby-tmenu :transient t)
("t" "Toggle locations" bookmark-bmenu-toggle-filenames :transient t)]
["Column"
("b" "←" tabulated-list-previous-column :transient t)
("f" "→" tabulated-list-next-column :transient t)
("{" "Narrow Column" tabulated-list-narrow-current-column :transient t)
("}" "Widen Column" tabulated-list-widen-current-column :transient t)]]
[:class transient-row
("<return>" "Open" bookmark-bmenu-this-window :transient nil)
("g" "Refresh" revert-buffer :transient t)
("S" "Save" bookmark-bmenu-save :transient t)
(casual-lib-quit-all)])
(transient-define-prefix cc/bookmark-bmenu-sortby-tmenu ()
["Sort By"
("n" "Name" cc/bookmark-bmenu-sortby-name :transient nil)
("m" "Last Modified" cc/bookmark-bmenu-sortby-modified :transient nil)
("c" "Creation Time" cc/bookmark-bmenu-sortby-creation :transient nil)]
[:class transient-row
(casual-lib-quit-all)])
(defun cc/bookmark-bmenu-sortby-name ()
"Sort bookmark list by name."
(interactive)
(setq-local bookmark-sort-flag t)
(revert-buffer))
(defun cc/bookmark-bmenu-sortby-modified ()
"Sort bookmark list by last modified time."
(interactive)
(setq-local bookmark-sort-flag 'last-modified)
(revert-buffer))
(defun cc/bookmark-bmenu-sortby-creation ()
"Sort bookmark list by creation time."
(interactive)
(setq-local bookmark-sort-flag nil)
(revert-buffer))
;; Streamlined Bookmarks Menu
(easy-menu-define cc/bookmarks-menu nil
"Keymap for CC Bookmarks Menu."
'("Bookmarks"
["Edit Bookmarks" list-bookmarks
:help "Display a list of existing bookmarks."]
"---"
["Add Bookmark…" bookmark-set-no-overwrite
:help "Set a bookmark named NAME at the current location."]
"---"
["Jump to Bookmark…" bookmark-jump
:help "Jump to bookmark"]))
(easy-menu-add-item global-map '(menu-bar)
cc/bookmarks-menu
"Tools")
(keymap-set bookmark-bmenu-mode-map "C-o" #'cc/bookmark-bmenu-tmenu)
(keymap-set bookmark-bmenu-mode-map "C-M-o" #'cc/main-tmenu)
(provide 'cc-bookmarks-bmenu-mode)
;;; cc-bookmarks-bmenu-mode.el ends here