]> git.eshelyaron.com Git - emacs.git/commitdiff
* dired-aux.el (dired-mark-read-string): Don't use default value on empty input.
authorChong Yidong <cyd@stupidchicken.com>
Mon, 12 Sep 2011 20:45:56 +0000 (16:45 -0400)
committerChong Yidong <cyd@stupidchicken.com>
Mon, 12 Sep 2011 20:45:56 +0000 (16:45 -0400)
(dired-do-chxxx): Treat empty input for "touch" as no -t option.
Omit initial minibuffer contents.
(dired-do-chmod): Signal an error on empty input.
(dired-mark-read-string): Don't return default on empty input.

* files.el (file-modes-symbolic-to-number): Doc fix.

Fixes: debbugs:9361
lisp/ChangeLog
lisp/dired-aux.el
lisp/dired.el
lisp/files.el

index 139863e4a584abedfa0e0ea0fcd61dac96064e6a..b96b2a4a5421e108a97b92e5621c54f8bb55115e 100644 (file)
@@ -1,3 +1,14 @@
+2011-09-12  Chong Yidong  <cyd@stupidchicken.com>
+
+       * dired-aux.el (dired-mark-read-string): Don't return default
+       value on empty input (Bug#9361).
+       (dired-do-chxxx): Treat empty input for "touch" as no -t option.
+       Omit initial minibuffer contents.
+       (dired-do-chmod): Signal an error on empty input.
+       (dired-mark-read-string): Don't return default on empty input.
+
+       * files.el (file-modes-symbolic-to-number): Doc fix.
+
 2011-09-12  Stefan Monnier  <monnier@iro.umontreal.ca>
 
        * international/mule-cmds.el (ucs-completions): Remove.
index ec157fc4939e7df518e2dd622a1376b104ae1e71..2f2d28e596cb8ad95ed47ea52bd62efa3a307d27 100644 (file)
@@ -236,18 +236,16 @@ List has a form of (file-name full-file-name (attribute-list))."
   ;; OP-SYMBOL is the type of operation (for use in `dired-mark-pop-up').
   ;; ARG describes which files to use, as in `dired-get-marked-files'.
   (let* ((files (dired-get-marked-files t arg))
-        (initial
-         (if (eq op-symbol 'touch)
-             (format-time-string "%Y%m%d%H%M.%S")))
-        (default
-          (if (eq op-symbol 'touch)
-              (and (stringp (car files))
-                   (format-time-string "%Y%m%d%H%M.%S"
-                                       (nth 5 (file-attributes (car files)))))))
-        (new-attribute
-         (dired-mark-read-string
-          (concat "Change " attribute-name " of %s to: ")
-          initial op-symbol arg files default))
+        (default (and (eq op-symbol 'touch)
+                      (stringp (car files))
+                      (format-time-string "%Y%m%d%H%M.%S"
+                                          (nth 5 (file-attributes (car files))))))
+        (prompt (concat "Change " attribute-name " of %s to"
+                        (if (eq op-symbol 'touch)
+                            " (default now): "
+                          ": ")))
+        (new-attribute (dired-mark-read-string prompt nil op-symbol
+                                               arg files default))
         (operation (concat program " " new-attribute))
         failures)
     (setq failures
@@ -255,9 +253,10 @@ List has a form of (file-name full-file-name (attribute-list))."
                             (function dired-check-process)
                             (append
                              (list operation program)
-                             (if (eq op-symbol 'touch)
-                                 '("-t") nil)
-                             (list new-attribute)
+                             (unless (string-equal new-attribute "")
+                               (if (eq op-symbol 'touch)
+                                   (list "-t" new-attribute)
+                                 (list new-attribute)))
                              (if (string-match "gnu" system-configuration)
                                  '("--") nil))
                             files))
@@ -285,10 +284,19 @@ Symbolic modes like `g+w' are allowed."
                         (match-string 2 modestr)
                         (match-string 3 modestr)))))
         (modes (dired-mark-read-string
-                "Change mode of %s to: " nil
+                "Change mode of %s to: "
+                ;; Insert initial input if there's only one file.
+                (unless (cadr files) default)
                 'chmod arg files default))
-        (num-modes (if (string-match "^[0-7]+" modes)
-                       (string-to-number modes 8))))
+        num-modes)
+
+    (cond ((equal modes "")
+          ;; We used to treat empty input as DEFAULT, but that is not
+          ;; such a good idea (Bug#9361).
+          (error "No file mode specified"))
+         ((string-match "^[0-7]+" modes)
+          (setq num-modes (string-to-number modes 8))))
+
     (dolist (file files)
       (set-file-modes
        file
@@ -379,22 +387,24 @@ Uses the shell command coming from variables `lpr-command' and
                   'print arg file-list)))
     (dired-run-shell-command (dired-shell-stuff-it command file-list nil))))
 
-;; Read arguments for a marked-files command that wants a string
-;; that is not a file name,
-;; perhaps popping up the list of marked files.
-;; ARG is the prefix arg and indicates whether the files came from
-;; marks (ARG=nil) or a repeat factor (integerp ARG).
-;; If the current file was used, the list has but one element and ARG
-;; does not matter. (It is non-nil, non-integer in that case, namely '(4)).
-
-(defun dired-mark-read-string (prompt initial op-symbol arg files &optional default)
-  ;; PROMPT for a string, with INITIAL input and DEFAULT value.
-  ;; Other args are used to give user feedback and pop-up:
-  ;; OP-SYMBOL of command, prefix ARG, marked FILES.
-  (dired-mark-pop-up
-   nil op-symbol files
-   (function read-string)
-   (format prompt (dired-mark-prompt arg files)) initial nil default))
+(defun dired-mark-read-string (prompt initial op-symbol arg files
+                              &optional standard-value)
+  "Read args for a Dired marked-files command, prompting with PROMPT.
+Return the user input (a string).
+
+INITIAL, if non-nil, is the initial minibuffer input.
+OP-SYMBOL is an operation symbol (see `dired-no-confirm').
+ARG is normally the prefix argument for the calling command.
+FILES should be a list of file names.
+
+STANDARD-VALUE, if non-nil, should be a \"standard\" value or
+list of such values, available via history commands.  Note that
+if the user enters empty input, this function returns the empty
+string, not STANDARD-VALUE."
+  (dired-mark-pop-up nil op-symbol files
+                    'read-from-minibuffer
+                    (format prompt (dired-mark-prompt arg files))
+                    initial nil nil nil standard-value))
 \f
 ;;; Cleaning a directory: flagging some backups for deletion.
 
index ecb626a275e466df31bb844025a44870cadc6d71..3428f5bef8b9b6ab071b3d137dfacd327c2e9ac2 100644 (file)
@@ -3663,7 +3663,7 @@ Ask means pop up a menu for the user to select one of copy, move or link."
 ;;;;;;  dired-run-shell-command dired-do-shell-command dired-do-async-shell-command
 ;;;;;;  dired-clean-directory dired-do-print dired-do-touch dired-do-chown
 ;;;;;;  dired-do-chgrp dired-do-chmod dired-compare-directories dired-backup-diff
-;;;;;;  dired-diff) "dired-aux" "dired-aux.el" "bbb53a5b6bf56c413fe0f898559bef8d")
+;;;;;;  dired-diff) "dired-aux" "dired-aux.el" "bbc9babe193843cad535d73492326c48")
 ;;; Generated autoloads from dired-aux.el
 
 (autoload 'dired-diff "dired-aux" "\
index a0f55517546a4c75889915b85226cdc57890c188..5ca9af6783d54fe26514a0d4b8dfb01afd865a8f 100644 (file)
@@ -6301,7 +6301,7 @@ as in \"og+rX-w\"."
   "Convert symbolic file modes to numeric file modes.
 MODES is the string to convert, it should match
 \"[ugoa]*([+-=][rwxXstugo]*)+,...\".
-See (info \"(coreutils)File permissions\") for more information on this
+See Info node `(coreutils)File permissions' for more information on this
 notation.
 FROM (or 0 if nil) gives the mode bits on which to base permissions if
 MODES request to add, remove, or set permissions based on existing ones,