[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#20195: 25.0.50; Let Dired commands such as `dired-do-search' (`A') u
bug#20195: 25.0.50; Let Dired commands such as `dired-do-search' (`A') use prefix arg
Tue, 31 Mar 2015 14:22:00 -0700 (PDT)
> >> There is a problem with `dired-do-query-replace-regexp' where a prefix
> >> arg means replace word-delimited matches.
> > So make it so that only a negative prefix arg means delimited.
> A negative prefix arg means backward replacement.
I didn't think so. `d-d-q-r-r' uses `tags-query-replace', and I don't see
where that allows for traversing backward.
I do agree that `d-d-q-r-r' presents a bit of an anomaly, where we will
likely need to make a judgment call (& compromise), to accommodate
whatever is deemed to be the most important subset of possibilities.
Im my own code (dired+.el), I long ago modified
`dired-map-over-marks' and `dired-get-marked-files' to let multiple
plain `C-u' act on all files, ignoring marks, as follows:
Optional second argument ARG specifies files to use instead of marked.
Usually ARG comes from the command's prefix arg.
If ARG is an integer, use the next ARG files (previous -ARG, if < 0).
If ARG is a cons with element 16, 64, or 256, corresponding to
`C-u C-u', `C-u C-u C-u', or `C-u C-u C-u C-u', then use all files
in the Dired buffer, where:
16 includes NO directories (including `.' and `..')
64 includes directories EXCEPT `.' and `..'
256 includes ALL directories (including `.' and `..')
If ARG is otherwise non-nil, use the current file.
So, for example, my version of `dired-do-isearch-regexp' and other
such commands uses a prefix arg this way:
A prefix argument ARG specifies files to use instead of those marked.
* An integer means use the next ARG files (previous -ARG, if < 0).
* Two or more `C-u' (e.g. `C-u C-u') means ignore any marks and use
all files in the Dired buffer.
* Any other prefix arg means use the current file.
(For `dired-do-*' commands that do not act on directories, all
multiples of `C-u' act the same as `C-u C-u': `.' and `..' are
But yes, `dired-do-query-replace-regexp' required a compromise.
This is what I ended up with, but I'm not too pleased that it is
an exception to the rule, and I'm not sure it is the best
NOTE: A prefix arg for this command acts differently than for other
commands, so that you can use it to request word-delimited matches.
With a prefix argument:
* An odd number of plain `C-u': act on the marked files, but replace
only word-delimited matches.
* More than one plain `C-u': act on all files, ignoring whether any
* Any other prefix arg: Act on the next numeric-prefix files.
So for example:
* `C-u C-u C-u': act on all files, replacing word-delimited matches.
* `C-u 4': act on the next 4 files. `C-4' means the same thing.
* `C-u': act on the marked files, replacing word-delimited matches.
Anyway, the point is that I think Emacs can do a bit better wrt the
prefix arg for such commands. I'm open to better suggestions wrt
`dired-do-query-replace-regexp'. And I'm OK, for this bug report,
with whatever you decide.
And should you happen to decide to add multiple `C-u' behavior to the
vanilla code, and if it lets you do whatever you can do with dired+.el,
then I'll be happy to drop that code from dired+.el (except for older
Emacs versions). ;-)
And thanks for taking a look at this, whatever you decide. Personally,
I never use a prefix arg to act on the next (or previous) N files, but
I do often use multiple `C-u C-u' to act on all files (regardless of