summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJSDurand <mmemmew@gmail.com>2023-06-19 02:27:13 +0800
committerJSDurand <mmemmew@gmail.com>2023-06-19 02:27:13 +0800
commitbd03a399440aa24123f09e7103135785be0e0e0d (patch)
tree3683c16ca77bf285de01f70e9a66501b82c4ceb4
parent3a15818a01175865f2c6b625fe858aa5418af7b7 (diff)
common: add a binding to store bookmarks in registers
* common.el (durand-bookmark-to-register): Add an anonymous bookmark to a register. (ctl-x-r-map): Bind the function to 'C-x r B'. (bookmark-make-record): Automatically loads the bookmark if the required functionality is not loaded yet.
-rw-r--r--common.el14
1 files changed, 14 insertions, 0 deletions
diff --git a/common.el b/common.el
index fd317ad..550f16c 100644
--- a/common.el
+++ b/common.el
@@ -426,6 +426,20 @@ mark at the end for the first yank."
(define-key ctl-x-r-map (vector ?p) #'point-to-register)
+;;; Save anonymous bookmark in a register
+
+(load-after-function bookmark-make-record "bookmark-conf.el"
+ "Fake function that loads bookmarks." nil)
+
+(defun durand-bookmark-to-register (register)
+ "Store an anonymous bookmark in register REGISTER.
+Use \\[jump-to-register] to jump to the bookmark."
+ (interactive
+ (list (register-read-with-preview "Bookmark to register: ")))
+ (set-register register (cons 'bookmark (bookmark-make-record))))
+
+(define-key ctl-x-r-map (vector ?B) #'durand-bookmark-to-register)
+
;;; Intentionally disable some key-bindings.
;; Using byte-code is fun.