From: Stefan Kangas Date: Thu, 30 Jun 2022 11:47:59 +0000 (+0200) Subject: New hook save-place-after-find-file-hook X-Git-Tag: emacs-29.0.90~1447^2~1353 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=bf65073767de47e3dfdb9b3086d4abd3ecb0089b;p=emacs.git 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. --- diff --git a/etc/NEWS b/etc/NEWS index ad0acd674e2..e757435ff91 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -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. diff --git a/lisp/saveplace.el b/lisp/saveplace.el index a23454b0bb4..3830e4b16cf 100644 --- a/lisp/saveplace.el +++ b/lisp/saveplace.el @@ -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))