fix: save-place: don't move point more than once

In some contexts, like org-agenda-switch-to visiting a TODO in an agenda
file, the visiting command will move the cursor after opening the file.
If save-place moves the cursor yet again, the cursor will end up in an
unpredictable place.
This commit is contained in:
Henrik Lissner 2024-03-13 00:05:26 -04:00
parent 5cc4056abf
commit fec28a19e1
No known key found for this signature in database
GPG key ID: B60957CA074D39A3

View file

@ -406,6 +406,11 @@ the unwritable tidbits."
(unless doom-large-file-p (unless doom-large-file-p
(apply fn args))) (apply fn args)))
(defadvice! doom--inhibit-saveplace-if-point-not-at-bol-a (&rest _)
"If something else has moved point, don't try to move it again."
:before-while #'save-place-find-file-hook
(bobp))
(defadvice! doom--dont-prettify-saveplace-cache-a (fn) (defadvice! doom--dont-prettify-saveplace-cache-a (fn)
"`save-place-alist-to-file' uses `pp' to prettify the contents of its cache. "`save-place-alist-to-file' uses `pp' to prettify the contents of its cache.
`pp' can be expensive for longer lists, and there's no reason to prettify cache `pp' can be expensive for longer lists, and there's no reason to prettify cache