emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] /srv/bzr/emacs/trunk r105747: * dired-aux.el (dired-mark-r


From: Chong Yidong
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r105747: * dired-aux.el (dired-mark-read-string): Don't use default value on empty input.
Date: Mon, 12 Sep 2011 16:45:56 -0400
User-agent: Bazaar (2.3.1)

------------------------------------------------------------
revno: 105747
fixes bug(s): http://debbugs.gnu.org/9361
committer: Chong Yidong <address@hidden>
branch nick: trunk
timestamp: Mon 2011-09-12 16:45:56 -0400
message:
  * dired-aux.el (dired-mark-read-string): Don't use default value on empty 
input.
  (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.
modified:
  lisp/ChangeLog
  lisp/dired-aux.el
  lisp/dired.el
  lisp/files.el
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2011-09-12 02:18:23 +0000
+++ b/lisp/ChangeLog    2011-09-12 20:45:56 +0000
@@ -1,3 +1,14 @@
+2011-09-12  Chong Yidong  <address@hidden>
+
+       * 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  <address@hidden>
 
        * international/mule-cmds.el (ucs-completions): Remove.

=== modified file 'lisp/dired-aux.el'
--- a/lisp/dired-aux.el 2011-08-04 00:58:07 +0000
+++ b/lisp/dired-aux.el 2011-09-12 20:45:56 +0000
@@ -236,18 +236,16 @@
   ;; 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 @@
                             (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 @@
                         (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 @@
                   '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))
 
 ;;; Cleaning a directory: flagging some backups for deletion.
 

=== modified file 'lisp/dired.el'
--- a/lisp/dired.el     2011-09-11 17:08:17 +0000
+++ b/lisp/dired.el     2011-09-12 20:45:56 +0000
@@ -3663,7 +3663,7 @@
 ;;;;;;  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" "\

=== modified file 'lisp/files.el'
--- a/lisp/files.el     2011-09-03 01:41:27 +0000
+++ b/lisp/files.el     2011-09-12 20:45:56 +0000
@@ -6301,7 +6301,7 @@
   "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,


reply via email to

[Prev in Thread] Current Thread [Next in Thread]