From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#62413: 29.0.60; [PATCH] save-place-mode cannot restore saved position Date: Sat, 25 Mar 2023 14:52:17 +0300 Message-ID: <83tty9caku.fsf@gnu.org> References: Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="1645"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 62413@debbugs.gnu.org To: Liu Hui Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Mar 25 12:53:28 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pg2Sc-000Adg-Iv for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 25 Mar 2023 12:53:26 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pg2SG-0005SY-Fr; Sat, 25 Mar 2023 07:53:04 -0400 Original-Received: from [2001:470:142:3::10] (helo=eggs.gnu.org) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pg2SE-0005IE-B2 for bug-gnu-emacs@gnu.org; Sat, 25 Mar 2023 07:53:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pg2SE-0007qj-33 for bug-gnu-emacs@gnu.org; Sat, 25 Mar 2023 07:53:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pg2SD-0003uH-Uz for bug-gnu-emacs@gnu.org; Sat, 25 Mar 2023 07:53:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 25 Mar 2023 11:53:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 62413 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 62413-submit@debbugs.gnu.org id=B62413.167974515414980 (code B ref 62413); Sat, 25 Mar 2023 11:53:01 +0000 Original-Received: (at 62413) by debbugs.gnu.org; 25 Mar 2023 11:52:34 +0000 Original-Received: from localhost ([127.0.0.1]:41886 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pg2Rm-0003tY-1b for submit@debbugs.gnu.org; Sat, 25 Mar 2023 07:52:34 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:46668) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pg2Rg-0003tH-Td for 62413@debbugs.gnu.org; Sat, 25 Mar 2023 07:52:32 -0400 Original-Received: from [2001:470:142:3::e] (helo=fencepost.gnu.org) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pg2Rb-0007jT-LF; Sat, 25 Mar 2023 07:52:23 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=6LqWPqmneUPepRchS30Z1dXQQgEjXyQRRibKUIBEk5A=; b=jJFoz3jfdVkp PMTW33zdSms3C54zem3sDfDfoIBnsH6Iw4FySCVhUE4keS4wBsItv9N67/9el30Ra2hGy0XJuoT7d VQLZhP+nfgqAgWdTjTmYhtxr1kq6hmzkimSNSfH+BMJ6+HQoT7awAnkfMLDqXc+Y9OxyrqeEa5ghj DNBGM1yy0qoXmtU5yHoCnlrnDbqxJo7DvCDsTSC7/nuici69HV3nPYdVDRzIvIwOs4y5t4wbwQrKG d5xa2gj1+HVfRUg2B2jT5buvDNucAYwKhbIrM5UYqI3HjAwnwcPoNrbdgMRQ1MSYLf8bhnSJAlqWQ xXWLmJf2z8SGKZo68Gtk1w==; Original-Received: from [87.69.77.57] (helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pg2RX-000141-Rv; Sat, 25 Mar 2023 07:52:20 -0400 In-Reply-To: (message from Liu Hui on Fri, 24 Mar 2023 10:19:07 +0800) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:258539 Archived-At: > From: Liu Hui > 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.