all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Juri Linkov <juri@jurta.org>
To: Bastien <bzg@altern.org>
Cc: 12399@debbugs.gnu.org
Subject: bug#12399: 24.2.50; dired-do-touch doesn't recognize empty input in minibuffer
Date: Tue, 11 Sep 2012 22:05:01 +0300	[thread overview]
Message-ID: <87sjao5r1y.fsf@mail.jurta.org> (raw)
In-Reply-To: <87k3w01v1y.fsf@altern.org> (Bastien's message of "Tue, 11 Sep 2012 16:41:13 +0200")

> I'm not sure why the simple patch below should not be enough,
> taking the current time instead of the one from the first file
> in the set of marked file.

Sorry, but it removes using the modification time of current file
for editing in the minibuffer via M-n, and what is worse, it uses
the current time as the argument of `touch' that might cause race
conditions as described in
http://thread.gmane.org/gmane.emacs.devel/142449/focus=142494

Fortunately, thanks to `completing-read-function'
it's easy to fix this with a small change that adds
a new function `completing-read-without-default'
that works like `completing-read-default'
but returns the empty string for empty input
like `read-from-minibuffer':

=== modified file 'lisp/dired-aux.el'
--- lisp/dired-aux.el	2012-09-08 14:48:27 +0000
+++ lisp/dired-aux.el	2012-09-11 19:04:20 +0000
@@ -391,10 +391,11 @@ (defun dired-mark-read-string (prompt in
 
 Optional arg COLLECTION is a collection of possible completions,
 passed as the second arg to `completing-read'."
+  (let ((completing-read-function 'completing-read-without-default))
   (dired-mark-pop-up nil op-symbol files
 		     'completing-read
 		     (format prompt (dired-mark-prompt arg files))
-		     collection nil nil initial nil default-value nil))
+		       collection nil nil initial nil default-value nil)))
 \f
 ;;; Cleaning a directory: flagging some backups for deletion.
 
=== modified file 'lisp/minibuffer.el'
--- lisp/minibuffer.el	2012-09-01 04:28:24 +0000
+++ lisp/minibuffer.el	2012-09-11 19:03:14 +0000
@@ -3089,11 +3108,14 @@ (defvar completing-read-function 'comple
   "The function called by `completing-read' to do its work.
 It should accept the same arguments as `completing-read'.")
 
-(defun completing-read-default (prompt collection &optional predicate
+(defun completing-read-without-default (prompt collection &optional predicate
                                        require-match initial-input
                                        hist def inherit-input-method)
-  "Default method for reading from the minibuffer with completion.
-See `completing-read' for the meaning of the arguments."
+  "Read a string with completion and without returning the default value.
+See `completing-read' for the meaning of the arguments.
+Unlike `completing-read-default', for empty input it returns
+the empty string instead of the default value.  Thus it handles
+empty input like `read-from-minibuffer'."
 
   (when (consp initial-input)
     (setq initial-input
@@ -3121,10 +3143,23 @@ (defun completing-read-default (prompt c
                     base-keymap)))
          (result (read-from-minibuffer prompt initial-input keymap
                                        nil hist def inherit-input-method)))
+    result))
+
+(defun completing-read-default (prompt collection &optional predicate
+                                       require-match initial-input
+                                       hist def inherit-input-method)
+  "Default method for reading from the minibuffer with completion.
+See `completing-read' for the meaning of the arguments.
+Unlike `completing-read-without-default', for empty input it returns
+the default value instead of the empty string."
+  (let ((result (completing-read-without-default
+		 prompt collection predicate require-match
+		 initial-input hist def inherit-input-method)))
     (when (and (equal result "") def)
       (setq result (if (consp def) (car def) def)))
     result))





  reply	other threads:[~2012-09-11 19:05 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-09 22:43 bug#12399: 24.2.50; dired-do-touch doesn't recognize empty input in minibuffer Juri Linkov
2012-09-11 14:41 ` Bastien
2012-09-11 19:05   ` Juri Linkov [this message]
2012-09-11 20:46     ` Stefan Monnier
2012-09-11 22:50       ` Juri Linkov
2012-09-13 23:42         ` Juri Linkov
2012-09-14 22:59           ` Juri Linkov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87sjao5r1y.fsf@mail.jurta.org \
    --to=juri@jurta.org \
    --cc=12399@debbugs.gnu.org \
    --cc=bzg@altern.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.