From bd03a399440aa24123f09e7103135785be0e0e0d Mon Sep 17 00:00:00 2001 From: JSDurand Date: Mon, 19 Jun 2023 02:27:13 +0800 Subject: 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. --- common.el | 14 ++++++++++++++ 1 file changed, 14 insertions(+) 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. -- cgit v1.2.3-18-g5258