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#70725: 29.3; dired-do-touch completion Date: Thu, 23 May 2024 15:42:35 +0000 Message-ID: <878r00h6vo.fsf@posteo.net> References: <871q6kkn5o.fsf@librehacker.com> <87plu38pf6.fsf@posteo.net> <86fruzjudh.fsf@gnu.org> <87fruzwetu.fsf@posteo.net> <8634qwlrii.fsf@mail.linkov.net> <87v83r8pm3.fsf@posteo.net> <86msp38lqm.fsf@mail.linkov.net> <87r0ef8cr9.fsf@posteo.net> <87seyv6ulx.fsf@igel.home> <87msp386vn.fsf@posteo.net> <86zft1h8jt.fsf@mail.linkov.net> <86seyfecil.fsf@gnu.org> <87jzjrt95q.fsf@posteo.net> <86ttird6uf.fsf@mail.linkov.net> <87msoj2u5m.fsf@posteo.net> <87wmnn5j6g.fsf@posteo.net> <86r0dvkrkk.fsf@mail.linkov.net> <87fruaq60n.fsf@posteo.net> <87bk4ypiv7.fsf@posteo.net> <86bk4ycu61.fsf@mail.linkov.net> <87sey993hp.fsf@posteo.net> 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="4951"; mail-complaints-to="usenet@ciao.gmane.io" Cc: christopher@librehacker.com, Eli Zaretskii , 70725@debbugs.gnu.org, schwab@linux-m68k.org, Juri Linkov To: Thierry Volpiatto Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu May 23 17:42:32 2024 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 1sAAaO-00014t-9q for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 23 May 2024 17:42:32 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sAAZA-0004zB-Ee; Thu, 23 May 2024 11:41:20 -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 1sAAYq-0004hi-4g for bug-gnu-emacs@gnu.org; Thu, 23 May 2024 11:40:57 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sAAYp-0003tU-SG for bug-gnu-emacs@gnu.org; Thu, 23 May 2024 11:40:55 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1sAAYw-00047e-8U for bug-gnu-emacs@gnu.org; Thu, 23 May 2024 11:41:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Thierry Volpiatto Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 23 May 2024 15:41:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 70725 X-GNU-PR-Package: emacs Original-Received: via spool by 70725-submit@debbugs.gnu.org id=B70725.171647883715829 (code B ref 70725); Thu, 23 May 2024 15:41:02 +0000 Original-Received: (at 70725) by debbugs.gnu.org; 23 May 2024 15:40:37 +0000 Original-Received: from localhost ([127.0.0.1]:59617 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sAAYU-00047F-R7 for submit@debbugs.gnu.org; Thu, 23 May 2024 11:40:37 -0400 Original-Received: from mout02.posteo.de ([185.67.36.66]:46233) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sAAYR-000479-Jy for 70725@debbugs.gnu.org; Thu, 23 May 2024 11:40:33 -0400 Original-Received: from submission (posteo.de [185.67.36.169]) by mout02.posteo.de (Postfix) with ESMTPS id D8B35240109 for <70725@debbugs.gnu.org>; Thu, 23 May 2024 17:40:18 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1716478818; bh=vV3dclHOnjiVIdtVEh/9Xo/DRps0zJVNpqbOTygzORI=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Content-Type: Autocrypt:OpenPGP:From; b=O9iu17xU6JdpqWbeMHxQBdSCsn1KW0MIzCU7mzR0b4RDkub8HL090nBH1MtsBhRl1 Nz1atmi5MNX+kmPl1w2zRTOmSvAXjlVnAelvHZ3PxR0uKn+nPYyzhm9o+CtBFTdm0p JHDMFvWpx9m2FgPmFycYxc7JA0j7oeojkVlNpnSYp7WDqJ0viwGV72C8pj4lSP8MhL 6gXgickVadIuSs/b7PnPSKRgiTquYHKLwFNc5xtWWJX5viTzyIRCe7CUyqPP9SiAGR h5wWmFDykMUzxEcAoodLDMLNMHjjKzDeTqaWNxeXeXNEY2aXQ5THyMufzSIFk8253L JRmPsFuPCABCA== Original-Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4VlXS003Hjz6tm8; Thu, 23 May 2024 17:40:15 +0200 (CEST) In-Reply-To: <87sey993hp.fsf@posteo.net> (Thierry Volpiatto's message of "Wed, 22 May 2024 17:10:42 +0000") Autocrypt: addr=thievol@posteo.net; prefer-encrypt=mutual; keydata=xsDNBF8ylcIBDADG+hy+zR6L4/vbdDDZuSaMmSrU3A5QZJpeBCvxTr7MpzzruZbhLPW1K3R6N2MA edi8Y+C8o27FVRIjpdbaKMGu9je7JV/TbUQYo3SOwCK1vM4LUn4V6ZLzSYkuiEt4eyMoiDdyvN0p kcK6P9x9DCetcEVszXzQg+yzCVrQ2hXWDXWT4M18EC3wtO7RHPouMqGiwBFhBAYErCqFWFxQHkfb tG/4yGyJ58rglb65O3qijjMWvYwcWZun9/7qm8Z4/4mHopmo2zgU+OrptnLSZfkZGz3Y7Uf452xQ GVq0Fv75NPvQru7y+DYVhuVXXyAmGxt+vf4rIiixMBbhKEPjcxEPAa2LTzex2IsTZR+QVG9uDnqC WcgaOEQ58fzXNvNhtwwF/Rgio2XWAJVdmFWS59/k9W58CIUSNKBMZh2XeGdEmtHvDtCxW3z6FJha 36RzOM3fMNNiAGdFZJA84gcdloJR+sHCDTTPT3784fjr+V8An7sI581NGFzkRQqPvEQCZbUAEQEA Ac0SdGhpZXZvbEBwb3N0ZW8ubmV0wsEOBBMBCgA4AhsDBQsJCAcCBhUKCQgLAgQWAgMBAh4BAheA FiEEI9twfRN7r3nig/xwDsVtFB0W75MFAmL3HCoACgkQDsVtFB0W75OVEAv/f6XxmtIFz08fUb8h Bp/zJP6IC4/rhhh+0GMRIRzLN8DK0jV8JCzYdFHiRJOy2lNIOpmrrCmjRRxferc2G42+ePFIsslx hU46VSz1Z83NwIG3mpdYNV5WUTUdgzxExHTNTFCd7NKv0nlHKQaA 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-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:285718 Archived-At: --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Thierry Volpiatto writes: > Juri Linkov writes: > >>>>>>>>>>> > However this doesn't explain why dired-do-touch uses a comple= ting-read >>>>>>>>>>> >>>>>>>>>>> Indeed, this was an oversight. Here is the patch >>>>>>>>>>> that replaces 'completing-read' with 'read-string': >>>>>>>>>> >>>>>>>>>> Thierry, is this solution okay with you? >>>>>>>>> >>>>>>>>> This fix one issue, >>>>>>>> >>>>>>>> Thanks, so I pushed the fix. >>>>>>> >>>>>>> Thanks. >>>>>>> >>>>>>>>> but default is still wrong IMHO: >>>>>>>>> >>>>>>>>> When pressing RET with an empty prompt the value is different tha= n what >>>>>>>>> is inserted in minibuffer with M-n. Why do we bother setting the >>>>>>>>> timesamp at the exact time when pressing RET instead of when pres= sing >>>>>>>>> "T", I mean user would consider the timestamp is set once "T" is >>>>>>>>> pressed, with this the behavior would be consistent with RET and = M-n and >>>>>>>>> the code much simpler. >>>>>>>> >>>>>>>> There is no need to make the value used by RET and the value inser= ted by M-n >>>>>>>> consistent in 100% of cases. >>>>>>> >>>>>>> Sorry but I disagree on this. >>>>>> >>>>>> Same question as with previous issue: >>>>>> >>>>>> How do I guess (as a third party package maintainer) what DEFAULT is= if >>>>>> you do such things in Emacs? >>>>>> >>>>>> We had a similar bug recently where a completing-read was specifying= the >>>>>> default in prompt (with format-prompt) but the DEFAULT arg was not >>>>>> provided, instead DEFAULT was computed later in the function... How = do I >>>>>> guess what DEFAULT is in such cases? From the prompt? This is not a >>>>>> valid solution, like this issue prove. >>>>> >>>>> The docstring of 'read-string' says: >>>>> >>>>> Fourth arg DEFAULT-VALUE is the default value or the list of defaul= t values. >>>>> If non-nil, it is used for history commands, and as the value (or = the first >>>>> element of the list of default values) to return if the user enter= s the >>>>> empty string. >>>>> >>>>> So it never returns an empty string. It always returns the default v= alue >>>>> that is quite confusing in this case. >>>>> >>>>> OTOH, the docstring of 'read-from-minibuffer' says: >>>>> >>>>> Sixth arg DEFAULT-VALUE, if non-nil, should be a string, which is u= sed >>>>> as the default to read if READ is non-nil and the user enters >>>>> empty input. But if READ is nil, this function does _not_ return >>>>> DEFAULT-VALUE for empty input! Instead, it returns the empty str= ing. >>>>> >>>>> Unlike 'read-string', 'read-from-minibuffer' does not return >>>>> the default value for empty input. >>>>> >>>>> So indeed it would be clearer to use 'read-from-minibuffer' >>>>> instead of 'read-string' to return an empty string for RET. >>>>> This is now fixed as well. >>>> >>>> In why returning an empty string fix the issue? We are now back at >>>> initial point, no? >> >> No, the accidental completing-read that caused you trouble >> was removed completely, so your problem is solved now. > > Yes it is solved, thank you, but I was speaking of the M-n behavior vs > RET. It can be easily fixed with a default set to ("now" > current_file_timestamp) where "now" is the string "now", but I will now > stop posting about this. Here a possible patch in case you are interested to fix this (fully not tested as I am on 29.3 actually): diff --git a/lisp/dired-aux.el b/lisp/dired-aux.el index 22c6881ae35..954cfdd27cb 100644 =2D-- a/lisp/dired-aux.el +++ b/lisp/dired-aux.el @@ -434,10 +434,11 @@ List has a form of (file-name full-file-name (attribu= te-list))." (default-file (dired-get-filename t t)) (default (when default-file (cond ((eq op-symbol 'touch) =2D (format-time-string =2D "%Y%m%d%H%M.%S" =2D (file-attribute-modification-time =2D (file-attributes default-file)))) + (list "now" + (format-time-string + "%Y%m%d%H%M.%S" + (file-attribute-modification-time + (file-attributes default-file))))) ((eq op-symbol 'chown) (file-attribute-user-id (file-attributes default-file 'string))) @@ -473,8 +474,9 @@ List has a form of (file-name full-file-name (attribute= -list))." ;; Use `eq' instead of `equal' ;; to detect empty input (bug#12399). (eq new-attribute default)) =2D (if (eq op-symbol 'touch) =2D (list "-t" new-attribute) + (if (and (eq op-symbol 'touch) + (not (string=3D new-attribute "now"))) + (list "-t" new-attribute) (list new-attribute))) (if (string-match-p "gnu" system-configuration) '("--") nil)) =2D-=20 Thierry --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQHHBAEBCgAxFiEEI9twfRN7r3nig/xwDsVtFB0W75MFAmZPY+wTHHRoaWV2b2xA cG9zdGVvLm5ldAAKCRAOxW0UHRbvk6TGDACM09ESssNgCH5QfX15ayZVigEMBQBU t2cqqa3pjKIqgEZTllXXyd4VvSLt8Omek7nE1MZHQX+pfn1zcFgVauSoTArW7yM6 SWiajOIAHeMrSwWInhHktNrZLxwmxQObT2PIf2bD0uaKyzhedGZ60FleKNxDrmbK mln+fqJHNpsYkcxzmeCZ1AVmN89o4QtsbRRNey4Tog5JjF5t7H9AZOu3JDDKUY3V 6FA2zSueQjNDFMXxbOGJ7MucViO6DihG41GG3/1//snyxGKKYYkLNp7LnhTk/0LP vzGiGTdZeQqHTCTrmzFk1NwJshggMkwsWDaxpv9o1EXpD4C4oelr54r77xKRPnaX wDOQthmpgw3+gUwYIE0dOA6lB+yRHE9WTArx/PZcKFX17eXJGVTlYYPrX0iMTqgA HDx4jZCAheNzm4DBVC9PLVzDJ9BWvocxohqR9Shb3K6MDbu2JnevL7FkDTxF2hsa RU+uhYlXr1u2vCpaHj6Xfswl1eGSyLWFJ64= =syo3 -----END PGP SIGNATURE----- --=-=-=--