Subject: Re: bug#10624: 24.0.92; default value of `dired-do-ch*'

From: Juri Linkov <[email-masked]>
Date: Sat, 15 Sep 2012 02:47:41 +0300

This request for enhancement is implemented with the following patch
where the user will be able to mark the target file with the mark.
Otherwise, the marked file is used as target only when it is a single file
in the list of marked files:

=== modified file 'lisp/dired-aux.el'
--- lisp/dired-aux.el	2012-09-13 23:42:39 +0000
+++ lisp/dired-aux.el	2012-09-14 23:45:05 +0000
@@ -223,10 +237,16 @@ (defun dired-do-chxxx (attribute-name pr
   ;; 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))
+	 (default-file (or (if (and transient-mark-mode mark-active)
+			       (save-excursion (goto-char (mark t))
+					       (dired-get-filename t t)))
+			   (if (and (= (length files) 1)
+				    (stringp (car files)))
+			       (car files))))
 	 (default (and (eq op-symbol 'touch)
-		       (stringp (car files))
+		       default-file
 		       (format-time-string "%Y%m%d%H%M.%S"
-					   (nth 5 (file-attributes (car files))))))
+					   (nth 5 (file-attributes default-file)))))
 	 (prompt (concat "Change " attribute-name " of %s to"
 			 (if (eq op-symbol 'touch)
 			     " (default now): "