>From c4378882ef88fafcd04017d1942f673658b04dd1 Mon Sep 17 00:00:00 2001 From: Jamie Beardslee Date: Sun, 21 Jun 2020 11:59:44 +1200 Subject: [PATCH] Allow save-place to override the position when using bookmarks. When the user option `save-place-override-bookmark' is non-nil, save-place will go to the last position rather than the position specified in the bookmark record. --- lisp/saveplace.el | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/lisp/saveplace.el b/lisp/saveplace.el index 46738ab03d..f32c1ad753 100644 --- a/lisp/saveplace.el +++ b/lisp/saveplace.el @@ -118,12 +118,22 @@ save-place-ignore-files-regexp :version "24.1" :type 'regexp) +(defcustom save-place-override-bookmark nil + "Whether `save-place' should override bookmarks. + +Normally, a bookmark is used to save a specific point in a buffer +or file. If this is non-nil, `save-place' will provide the +position instead." + :type 'boolean) + (declare-function dired-current-directory "dired" (&optional localp)) (defun save-place--setup-hooks (add) (cond (add (add-hook 'find-file-hook #'save-place-find-file-hook t) + (eval-after-load "bookmark" + '(add-hook 'bookmark-after-jump-hook #'save-place-bookmark-hook t)) (add-hook 'dired-initial-position-hook #'save-place-dired-hook) (unless noninteractive (add-hook 'kill-emacs-hook #'save-place-kill-emacs-hook)) @@ -334,6 +344,10 @@ save-place-find-file-hook ;; and make sure it will be saved again for later (setq save-place-mode t))))) +(defun save-place-bookmark-hook () + (when save-place-override-bookmark + (save-place-find-file-hook))) + (declare-function dired-goto-file "dired" (file)) (defun save-place-dired-hook () -- 2.27.0