Subject: bug#9361: 24.0.50; default value of `dired-do-chmod'

From: Chong Yidong <[email-masked]>
Date: Sun, 11 Sep 2011 17:41:24 -0400

I think there's a problem here, indeed.  It's a bad idea to take an
empty input to mean a certain default permission---especially when that
default permission is not displayed in the prompt.

The following patch makes dired-do-chmod demand a non-empty input.  The
precomputed permission is still available in the M-n `future history'.

*** lisp/dired-aux.el	2011-08-04 00:58:07 +0000
--- lisp/dired-aux.el	2011-09-11 21:38:35 +0000
***************
*** 267,272 ****
--- 267,280 ----
  	 (format "%s: error" operation)
  	 nil))))
  
+ (defun dired--read-permission-string (prompt default)
+   (let ((result ""))
+     (while (equal result "")
+       (setq result
+ 	    (read-from-minibuffer prompt nil nil
+ 				  nil nil default)))
+     result))
+ 
  ;;;###autoload
  (defun dired-do-chmod (&optional arg)
    "Change the mode of the marked (or next ARG) files.
***************
*** 284,292 ****
  			 (match-string 1 modestr)
  			 (match-string 2 modestr)
  			 (match-string 3 modestr)))))
! 	 (modes (dired-mark-read-string
! 		 "Change mode of %s to: " nil
! 		 'chmod arg files default))
  	 (num-modes (if (string-match "^[0-7]+" modes)
  			(string-to-number modes 8))))
      (dolist (file files)
--- 292,303 ----
  			 (match-string 1 modestr)
  			 (match-string 2 modestr)
  			 (match-string 3 modestr)))))
! 	 (modes
! 	  (dired-mark-pop-up nil 'chmod files
! 			     'dired--read-permission-string
! 			     (format "Change mode of %s to: "
! 				     (dired-mark-prompt arg files))
! 			     default))
  	 (num-modes (if (string-match "^[0-7]+" modes)
  			(string-to-number modes 8))))
      (dolist (file files)