unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#62413: 29.0.60; [PATCH] save-place-mode cannot restore saved position
@ 2023-03-24  2:19 Liu Hui
  2023-03-25 11:52 ` Eli Zaretskii
  0 siblings, 1 reply; 14+ messages in thread
From: Liu Hui @ 2023-03-24  2:19 UTC (permalink / raw)
  To: 62413

[-- Attachment #1: Type: text/plain, Size: 465 bytes --]

Hi,

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'.


Best,
Liu Hui

[-- Attachment #2: 0001-Restore-positions-for-abbreviated-file-names.patch --]
[-- Type: text/x-patch, Size: 1179 bytes --]

From 468b699e3123c008d8a5bd050c1efc3ad926b198 Mon Sep 17 00:00:00 2001
From: Liu Hui <liuhui1610@gmail.com>
Date: Fri, 24 Mar 2023 10:08:12 +0800
Subject: [PATCH] Restore positions for abbreviated file names in saveplace.el

* lisp/saveplace.el (save-place-find-file-hook): Use abbreviated file
name when `save-place-abbreviate-file-names' is non-nil.
---
 lisp/saveplace.el | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/lisp/saveplace.el b/lisp/saveplace.el
index 7512fc87c5d..5262f574efc 100644
--- 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)))
     (if cell
 	(progn
 	  (or revert-buffer-in-progress-p
--
2.25.1


^ permalink raw reply related	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2023-04-06 10:27 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-03-24  2:19 bug#62413: 29.0.60; [PATCH] save-place-mode cannot restore saved position Liu Hui
2023-03-25 11:52 ` Eli Zaretskii
2023-03-25 14:14   ` Liu Hui
2023-03-25 14:17     ` Eli Zaretskii
2023-03-26  1:26       ` Liu Hui
2023-03-26  5:20         ` Eli Zaretskii
2023-03-28  5:56           ` Liu Hui
2023-03-28 12:03             ` Eli Zaretskii
2023-03-30  2:49               ` Liu Hui
2023-03-30  5:34                 ` Eli Zaretskii
2023-04-03  1:02                   ` Liu Hui
2023-04-03  2:45                     ` Ruijie Yu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-04-04  1:37                       ` Liu Hui
2023-04-06 10:27                         ` Eli Zaretskii

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).