bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#62413: 29.0.60; [PATCH] save-place-mode cannot restore saved positio


From: Eli Zaretskii
Subject: bug#62413: 29.0.60; [PATCH] save-place-mode cannot restore saved position
Date: Sat, 25 Mar 2023 14:52:17 +0300

> From: Liu Hui <liuhui1610@gmail.com>
> Date: Fri, 24 Mar 2023 10:19:07 +0800
> 
> save-place-mode cannot restore last saved position when
> `save-place-abbreviate-file-names' is non-nil:
> 
> - emacs -Q
> - M-x save-place-mode, and set save-place-abbreviate-file-names to t
> - open a file, scroll to some position, and kill buffer
> - reopen the file, the position is not restored
> 
> The reason is it uses abbreviated file names when saving positions to
> `save-place-alist', but uses full file names to find position in
> `save-place-alist'.

I believe you are right with this analysis, thanks.

> --- a/lisp/saveplace.el
> +++ b/lisp/saveplace.el
> @@ -353,8 +353,11 @@ 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 (save-place-load-alist-from-file))
> -  (let ((cell (assoc buffer-file-name save-place-alist)))
> +  (let* ((item (if (and (stringp buffer-file-name)
> +                        save-place-abbreviate-file-names)
> +                   (abbreviate-file-name buffer-file-name)
> +                 buffer-file-name))
> +         (cell (assoc item save-place-alist)))

Wouldn't it be best to always test for abbreviated file name if the
full file name fails to match?  E.g., it could be that the user turned
on save-place-abbreviate-file-names for a while, then turned it off
(or vice versa), thus causing mixed file names in the saved history.
It would also make the code simpler, I think.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]