From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Ruijie Yu via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#62413: 29.0.60; [PATCH] save-place-mode cannot restore saved position Date: Mon, 03 Apr 2023 10:45:34 +0800 Message-ID: References: <83tty9caku.fsf@gnu.org> <83y1nkc3vc.fsf@gnu.org> <83zg809jgv.fsf@gnu.org> <83cz4t84mv.fsf@gnu.org> <83v8ii6bw4.fsf@gnu.org> Reply-To: Ruijie Yu Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="14563"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: mu4e 1.9.22; emacs 30.0.50 Cc: eliz@gnu.org, 62413@debbugs.gnu.org To: Liu Hui Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Apr 03 05:07:10 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 1pjAXG-0003fT-D7 for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 03 Apr 2023 05:07:10 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pjAXA-0001gY-CB; Sun, 02 Apr 2023 23:07:04 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pjAX8-0001g5-OK for bug-gnu-emacs@gnu.org; Sun, 02 Apr 2023 23:07: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 1pjAX8-0003cc-GI for bug-gnu-emacs@gnu.org; Sun, 02 Apr 2023 23:07:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pjAX8-00050n-5X for bug-gnu-emacs@gnu.org; Sun, 02 Apr 2023 23:07:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Ruijie Yu Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 03 Apr 2023 03:07:02 +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 X-Debbugs-Original-Cc: Eli Zaretskii , 62413@debbugs.gnu.org, bug-gnu-emacs@gnu.org Original-Received: via spool by 62413-submit@debbugs.gnu.org id=B62413.168049117619191 (code B ref 62413); Mon, 03 Apr 2023 03:07:02 +0000 Original-Received: (at 62413) by debbugs.gnu.org; 3 Apr 2023 03:06:16 +0000 Original-Received: from localhost ([127.0.0.1]:43042 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pjAWN-0004zT-SL for submit@debbugs.gnu.org; Sun, 02 Apr 2023 23:06:16 -0400 Original-Received: from netyu.xyz ([152.44.41.246]:50814 helo=mail.netyu.xyz) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pjAWL-0004zL-Vx for 62413@debbugs.gnu.org; Sun, 02 Apr 2023 23:06:15 -0400 Original-Received: from fw.net.yu.netyu.xyz ( [27.18.235.120]) by netyu.xyz (OpenSMTPD) with ESMTPSA id f1afaeb1 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Mon, 3 Apr 2023 03:06:12 +0000 (UTC) In-reply-to: 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:259149 Archived-At: Liu Hui writes: > Eli Zaretskii =E4=BA=8E2023=E5=B9=B43=E6=9C=8830=E6=97=A5= =E5=91=A8=E5=9B=9B 13:33=E5=86=99=E9=81=93=EF=BC=9A >> >> I think there's a cleaner way: a defcustom can have a :set function, >> which is called each time the variable is customized; this setter >> function should be defined for a defcustom when changing its value has >> non-trivial effects. So we can define such a setter function to >> rewrite the list, and document in the doc string of the defcustom that >> users should not just set the value with setq, but instead use either >> setopt or "M-x customize-variable". WDYT? > > OK, I think it is good. Please see the attached patch. > > [2. text/x-patch; 0001-Restore-positions-reliably-for-abbreviated-file-na= me.patch]... Two minor comments below. > @@ -90,8 +92,32 @@ save-place-forget-unreadable-files > (defcustom save-place-abbreviate-file-names nil > [...] > + :set (lambda (sym val) > + (set-default sym val) > + (let ((fun (if val 'abbreviate-file-name 'expand-file-name))) I believe function quotes "#'" are preferred over simple quotes "'" when dealing with functions. > @@ -214,7 +241,11 @@ save-place-to-alist > ((and (derived-mode-p 'dired-mode) directory) > (let ((filename (dired-get-filename nil t))) > (if filename > - `((dired-filename . ,filename)) > + (list > + (cons 'dired-filename > + (if save-place-abbreviate-file= -names > + (abbreviate-file-name file= name) > + filename))) It seems that you rewrote the quote-backquote thing with regular list-cons construct -- no comments on that. I noticed that here, and in a few other places, you are reusing the exact `if' construct multiple times. Does that warrant defining a helper function? Also, while I was about to send the mail, regarding the docstring of `save-place-abbreviate-file-names', instead of letting the user enable `save-place-mode', would it be better if you directly call facilities in saveplace to load `save-place-alist' from file system, within your :set function? --=20 Best, RY