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 committed by Yann Esposito (Yogsototh)
parent 40e9a17160
commit 88cfbf8307
Signed by untrusted user who does not match committer: yogsototh
GPG key ID: 7B19A4C650D59646

View file

@ -406,6 +406,11 @@ the unwritable tidbits."
(unless doom-large-file-p
(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)
"`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