New hook save-place-after-find-file-hook

This is intended for use in Org mode, where we currently use advise.
* lisp/saveplace.el (save-place-after-find-file-hook): New hook.
(save-place-find-file-hook): Run new hook.
This commit is contained in:
Stefan Kangas 2022-06-30 13:47:59 +02:00
parent 80cf13a3d2
commit bf65073767
2 changed files with 11 additions and 1 deletions

View file

@ -2911,6 +2911,10 @@ when used as part of a property list specification for the
** 'defalias' records a more precise history of definitions.
This is recorded in the 'function-history' symbol property.
---
** New hook 'save-place-after-find-file-hook'.
This is called at the end of 'save-place-find-file-hook'.
---
** 'indian-tml-base-table' no longer translates digits.
Use 'indian-tml-base-digits-table' if you want digits translation.

View file

@ -346,7 +346,12 @@ may have changed) back to `save-place-alist'."
(save-place-to-alist))
(setq buf-list (cdr buf-list))))))
(defvar save-place-after-find-file-hook nil
"Hook run at the end of `save-place-find-file-hook'.")
(defun save-place-find-file-hook ()
"Function added to `find-file-hook' by `save-place-mode'.
It runs the hook `save-place-after-find-file-hook'."
(or save-place-loaded (load-save-place-alist-from-file))
(let ((cell (assoc buffer-file-name save-place-alist)))
(if cell
@ -355,7 +360,8 @@ may have changed) back to `save-place-alist'."
(and (integerp (cdr cell))
(goto-char (cdr cell))))
;; and make sure it will be saved again for later
(setq save-place-mode t)))))
(setq save-place-mode t))))
(run-hooks 'save-place-after-find-file-hook))
(declare-function dired-goto-file "dired" (file))