From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Thierry Volpiatto Newsgroups: gmane.emacs.bugs Subject: bug#57334: 28.1; Fix wdired with (dired '(dir f1 f2 ...)) Date: Mon, 22 Aug 2022 15:45:03 +0000 Message-ID: <87sflo2s52.fsf@posteo.net> References: <878rng23aq.fsf@posteo.net> <877d30bmki.fsf@gnus.org> <875yik49ic.fsf@posteo.net> <877d3049c1.fsf@gnus.org> Mime-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="20339"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 57334@debbugs.gnu.org To: Lars Ingebrigtsen Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Aug 22 20:45:23 2022 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 1oQCQN-0005AF-FM for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 22 Aug 2022 20:45:23 +0200 Original-Received: from localhost ([::1]:47346 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oQCQM-0004nt-Gs for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 22 Aug 2022 14:45:22 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:43838) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oQ9ic-0007te-FY for bug-gnu-emacs@gnu.org; Mon, 22 Aug 2022 11:52:05 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:51791) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oQ9ic-00054f-5j for bug-gnu-emacs@gnu.org; Mon, 22 Aug 2022 11:52:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1oQ9ib-0000Pi-Tu for bug-gnu-emacs@gnu.org; Mon, 22 Aug 2022 11:52:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Thierry Volpiatto Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 22 Aug 2022 15:52:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 57334 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: moreinfo Original-Received: via spool by 57334-submit@debbugs.gnu.org id=B57334.16611835151576 (code B ref 57334); Mon, 22 Aug 2022 15:52:01 +0000 Original-Received: (at 57334) by debbugs.gnu.org; 22 Aug 2022 15:51:55 +0000 Original-Received: from localhost ([127.0.0.1]:41540 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oQ9iU-0000PM-JV for submit@debbugs.gnu.org; Mon, 22 Aug 2022 11:51:54 -0400 Original-Received: from mout01.posteo.de ([185.67.36.65]:39551) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oQ9iR-0000P8-50 for 57334@debbugs.gnu.org; Mon, 22 Aug 2022 11:51:52 -0400 Original-Received: from submission (posteo.de [185.67.36.169]) by mout01.posteo.de (Postfix) with ESMTPS id D2D13240028 for <57334@debbugs.gnu.org>; Mon, 22 Aug 2022 17:51:44 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1661183504; bh=lteM5mzp/wVvQSLuTR8fao+WSsLmFCGmhZWXz/P7LZE=; h=From:To:Cc:Subject:Date:Autocrypt:OpenPGP:From; b=SHB4wtpyp2d+pP6vB6DZ+xeLw2H58dT45L7bU3H1kyNX10MnuBYnR8pFyUJ7YBIZF FPAtA3LnSokx6tK2JQAuQJFP9yCqkD7Q+BQPweMWA1l2vYj8H9spZ3UADGyQAEFFUV 0ghIp0bq2KM74XsWhjlZB0+pu/rBcrPHNIq59fuVKXbo9Z0rvyEi3kOZQBe00pq/Yt ne7aTbaFBVFP+5+BtReVD7/m6TPZlaYIJeZTSjy6gcbjb1giGICe0lNkxkWWImNUL8 bP71r0U059RN1fEdkiL2LABHPWkSJqKxag2wkVFEoqc5je0csyWxJ5UJpB3GMlOObO 1OUKtvPDh9Tdw== Original-Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4MBH0b3y8dz6tpL; Mon, 22 Aug 2022 17:51:43 +0200 (CEST) In-reply-to: <877d3049c1.fsf@gnus.org> Autocrypt: addr=thievol@posteo.net; prefer-encrypt=mutual; keydata= mQGNBF8ylcIBDADG+hy+zR6L4/vbdDDZuSaMmSrU3A5QZJpeBCvxTr7MpzzruZbhLPW1K3R6N2MA edi8Y+C8o27FVRIjpdbaKMGu9je7JV/TbUQYo3SOwCK1vM4LUn4V6ZLzSYkuiEt4eyMoiDdyvN0p kcK6P9x9DCetcEVszXzQg+yzCVrQ2hXWDXWT4M18EC3wtO7RHPouMqGiwBFhBAYErCqFWFxQHkfb tG/4yGyJ58rglb65O3qijjMWvYwcWZun9/7qm8Z4/4mHopmo2zgU+OrptnLSZfkZGz3Y7Uf452xQ GVq0Fv75NPvQru7y+DYVhuVXXyAmGxt+vf4rIiixMBbhKEPjcxEPAa2LTzex2IsTZR+QVG9uDnqC WcgaOEQ58fzXNvNhtwwF/Rgio2XWAJVdmFWS59/k9W58CIUSNKBMZh2XeGdEmtHvDtCxW3z6FJha 36RzOM3fMNNiAGdFZJA84gcdloJR+sHCDTTPT3784fjr+V8An7sI581NGFzkRQqPvEQCZbUAEQEA AbQSdGhpZXZvbEBwb3N0ZW8ubmV0iQHOBBMBCgA4AhsDBQsJCAcCBhUKCQgLAgQWAgMBAh4BAheA FiEEI9twfRN7r3nig/xwDsVtFB0W75MFAmL3HCoACgkQDsVtFB0W75OVEAv/f6XxmtIFz08fUb8h Bp/zJP6IC4/rhhh+0GMRIRzLN8DK0jV8JCzYdFHiRJOy2lNIOpmrrCmjRRxferc2G42+ePFIsslx hU46VSz1Z83NwIG3mpdYNV5WUTUdgzxExHTNTFCd7NKv0nlHKQa OpenPGP: url=https://posteo.de/keys/thievol@posteo.net.asc; preference=encrypt 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" Xref: news.gmane.io gmane.emacs.bugs:240449 Archived-At: --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Lars Ingebrigtsen writes: > Thierry Volpiatto writes: > >>>> + (setcdr dired-directory > > [...] > >> Of course it have to be changed, it has been modified by wdired at this = point, >> so if you want to redisplay a dired buffer reflecting your changes you >> have to modify it no ? > > I don't understand what you mean. Well, you dired buffer is not the same before and after editing and saved. >>> which we shouldn't do. >> >> You already do it when DIRNAME is a string isn't it? > > Strings can't be modified. You are speaking of destructive operations, ok, I am just saying you just modify the string non destructively yes, but you modify it. >>> (It may even be a constant.) >> >> Can you elaborate? > > If the list is in purespace, for instance, it can't be modified. Yes but I hardly see how it would be the case for this. > In case there's any misunderstanding here, I'm talking about the > destructive alteration of the list pointed to by dired-directory by that > `setcdr' -- not the altering of the dired-directory variable. So the > safe change here would be something like > > (setq dired-directory (cons (car dired-directory) (mapcar ...))) Ok, so here a new patch which works same as the previous: diff --git a/lisp/wdired.el b/lisp/wdired.el index 106d57174d5..74d05a093b4 100644 =2D-- a/lisp/wdired.el +++ b/lisp/wdired.el @@ -537,15 +537,27 @@ non-nil means return old filename." (wdired-change-to-dired-mode) (if changes (progn =2D ;; If we are displaying a single file (rather than the =2D ;; contents of a directory), change dired-directory if that =2D ;; file was renamed. (This ought to be generalized to =2D ;; handle the multiple files case, but that's less trivial). =2D (when (and (stringp dired-directory) =2D (not (file-directory-p dired-directory)) =2D (null some-file-names-unchanged) =2D (=3D (length files-renamed) 1)) =2D (setq dired-directory (cdr (car files-renamed)))) + (setq dired-directory + (cond (;; If we are displaying a single file (rather than the + ;; contents of a directory), change dired-directory if that + ;; file was renamed. + (and (stringp dired-directory) + (not (file-directory-p dired-directory)) + (null some-file-names-unchanged) + (=3D (length files-renamed) 1)) + (cdr (car files-renamed))) + ;; Fix dired buffers created with + ;; (dired '(foo f1 f2 f3)). + ((and (consp dired-directory) + (cdr dired-directory) + files-renamed) + (cons (car dired-directory) + ;; Replace in `dired-directory' files that ha= ve + ;; been modified with their new name keeping + ;; the ones that are unmodified at the same p= lace. + (cl-loop for f in (cdr dired-directory) + collect (or (assoc-default f files-r= enamed) + f)))))) ;; Re-sort the buffer. (revert-buffer) (let ((inhibit-read-only t)) =2D-=20 Thierry --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQHHBAEBCgAxFiEEI9twfRN7r3nig/xwDsVtFB0W75MFAmMDpgkTHHRoaWV2b2xA cG9zdGVvLm5ldAAKCRAOxW0UHRbvkzXIC/0dFt5gVHVVsn8C72LL4Zh1y/CWk6CQ KRj6MPh4aiXSRBppbLAU6AwyKNilKHdMEjnzyGEMAwsP5dvy1itTP6aqfZoqjRMk 79tN+uVZNtrfX5ER70sQvZn255wOwFeO8iHiS/JSOYCLYuvQRcJsNyGTdsSuhS9m aUcC2Nq+3b+HSVET7qlb+T+BdvdFn7rMBM69f2HHpPm3SjGt62xftbCvw0/8O5LE BAoJRpmQvAGI24XnsPu6Z6ra/bdDAd+ZA82f967++W+LlmvH6IX8+SuS7EMfAH6/ llmzu+6p7o8ZF8pCqjwjODi2qdmkCcm/lZokM0Od3MYCuNJVQ15p2JRzm1GncTVb GcyWa3+x7dKNTPHEio1m4vLtmk4MgTCRl9dsZR29iuRT47L8OVZbHttVTw9FDo6Z +v0N5BCmQ0n2Jk0lPM6WY0PnoMLMybLLq/39MyTjJy4ZHqyBhv7l/qUl9F00hI0h AXrjSQ9eCtAO7xcrtoPNUCQOsjSp2nwfR+4= =/Iff -----END PGP SIGNATURE----- --=-=-=--