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

From: "Drew Adams" <[email-masked]>
Date: Fri, 14 Sep 2012 17:37:10 -0700

> 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:
> 
> +	 (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 

Thanks for working on this, but I'm not crazy about that approach at all, IIUC.
And it does not implement the enhancement requested.

The Emacs mark is not something that is very useful in this context, IMO.  It's
not obvious and visible.  And why use the mark only when transient-mark-mode is
enabled?  That obviates use of the region for something more useful in Dired
(e.g., Dired-marking all files in the region).

What's more, if I read your code correctly, when there is no active mark you are
still picking up the first of the marked files and using its data as the
default.

That is precisely the behavior that I filed this bug against.  It makes no sense
to use the 1st of the marked files, or the 13th, or any other file except the
current-line file.  That _is_ this bug.

I stand by my alternative suggestions:

1. Do not provide any default value at all.  (Easiest to do, but least
helpful improvement.)

2. Minimal, easy to do now: Use the attributes of the file on the current line,
providing them as the default for the marked files according to the particular
command (mod time, various permission fields, etc.).

3. More complex, but more useful: Let the user hit a key to "copy" the
attributes of a given file (on the current line - the "source" file), as if to a
clipboard.  Then use those attributes for subsequent "paste" operations,
transferring the appropriate attributes (mod time, various permission fields,
etc.) to the "target" (i.e., marked) files according to the particular command.

For example (for #3), for `dired-do-chmod', the file permissions copied from the
source file would be the default value.  For `dired-do-touch', the mod time of
the source file would be the default value for the operation.  And so on.

See the original bug report for more details.

The point is to (a) have a reasonable source-file choice from which attributes
are taken for the default and (b) push those attributes to the marked files as
defaults for an operation, in a operation-pertinent way.

If you cannot or do not want to do something like #3, please do #1 or something
like #2.  In the latter case (#1 or #2), or if you decide to do something
altogether different from what I suggested, please keep this enhancement request
open.

Thx.