From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.bugs 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 Organization: JURTA Message-ID: <87sjao5r1y.fsf@mail.jurta.org> References: <878vciakcd.fsf@mail.jurta.org> <87k3w01v1y.fsf@altern.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1347390632 28121 80.91.229.3 (11 Sep 2012 19:10:32 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 11 Sep 2012 19:10:32 +0000 (UTC) Cc: 12399@debbugs.gnu.org To: Bastien Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Sep 11 21:10:35 2012 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1TBVr1-0002yI-4d for geb-bug-gnu-emacs@m.gmane.org; Tue, 11 Sep 2012 21:10:35 +0200 Original-Received: from localhost ([::1]:35337 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TBVqx-0008FK-9Z for geb-bug-gnu-emacs@m.gmane.org; Tue, 11 Sep 2012 15:10:31 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:47677) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TBVqu-0008FA-LP for bug-gnu-emacs@gnu.org; Tue, 11 Sep 2012 15:10:29 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TBVqn-0003Kh-5R for bug-gnu-emacs@gnu.org; Tue, 11 Sep 2012 15:10:28 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:45596) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TBVqn-0003KW-1a for bug-gnu-emacs@gnu.org; Tue, 11 Sep 2012 15:10:21 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1TBVrS-0007ZM-Ce for bug-gnu-emacs@gnu.org; Tue, 11 Sep 2012 15:11:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 11 Sep 2012 19:11:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 12399 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 12399-submit@debbugs.gnu.org id=B12399.134739062629051 (code B ref 12399); Tue, 11 Sep 2012 19:11:02 +0000 Original-Received: (at 12399) by debbugs.gnu.org; 11 Sep 2012 19:10:26 +0000 Original-Received: from localhost ([127.0.0.1]:55140 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TBVqs-0007YW-Ds for submit@debbugs.gnu.org; Tue, 11 Sep 2012 15:10:26 -0400 Original-Received: from ps18281.dreamhost.com ([69.163.218.105]:58350 helo=ps18281.dreamhostps.com) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TBVqn-0007YG-PU for 12399@debbugs.gnu.org; Tue, 11 Sep 2012 15:10:24 -0400 Original-Received: from localhost (ps18281.dreamhostps.com [69.163.218.105]) by ps18281.dreamhostps.com (Postfix) with ESMTP id 71A99451CC7D; Tue, 11 Sep 2012 12:09:37 -0700 (PDT) In-Reply-To: <87k3w01v1y.fsf@altern.org> (Bastien's message of "Tue, 11 Sep 2012 16:41:13 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2.50 (x86_64-pc-linux-gnu) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 140.186.70.43 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.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:64158 Archived-At: > 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))) ;;; 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))