GNU bug report logs - #20195
25.0.50; Let Dired commands such as `dired-do-search' (`A') use prefix arg

Previous Next

Package: emacs;

Reported by: Drew Adams <drew.adams <at> oracle.com>

Date: Wed, 25 Mar 2015 03:57:03 UTC

Severity: wishlist

Tags: wontfix

Found in version 25.0.50

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 20195 in the body.
You can then email your comments to 20195 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#20195; Package emacs. (Wed, 25 Mar 2015 03:57:03 GMT) Full text and rfc822 format available.

Acknowledgement sent to Drew Adams <drew.adams <at> oracle.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Wed, 25 Mar 2015 03:57:03 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Drew Adams <drew.adams <at> oracle.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 25.0.50; Let Dired commands such as `dired-do-search' (`A') use
 prefix arg
Date: Tue, 24 Mar 2015 20:56:26 -0700 (PDT)
Enhancement request:

Typically in Dired commands that act on the marked files will act on the
next PREFIX-ARG files instead, if a prefix arg is provided.  This is not
true of commands such as `dired-do-search', but it would be good if it
were.

All that is needed is to (a) add an optional argument ARG to each such
command and (b) include ARG in the call to `dired-get-marked-files'.
For example:

(defun dired-do-search (regexp &optional arg) ; <=== Add ARG
  "..."
  (interactive "sSearch marked files (regexp): \nP")
  (tags-search
    regexp (dired-get-marked-files nil arg 'dired-nondirectory-p)))
                                        ^
                                        |
                                     use ARG


In GNU Emacs 25.0.50.1 (i686-pc-mingw32)
 of 2014-10-20 on LEG570
Bzr revision: 118168 rgm <at> gnu.org-20141020195941-icp42t8ttcnud09g
Windowing system distributor `Microsoft Corp.', version 6.1.7601
Configured using:
 `configure --enable-checking=yes,glyphs CPPFLAGS=-DGLYPH_DEBUG=1'




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#20195; Package emacs. (Wed, 25 Mar 2015 21:57:02 GMT) Full text and rfc822 format available.

Message #8 received at 20195 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: Drew Adams <drew.adams <at> oracle.com>
Cc: 20195 <at> debbugs.gnu.org
Subject: Re: bug#20195: 25.0.50;
 Let Dired commands such as `dired-do-search' (`A') use prefix arg
Date: Wed, 25 Mar 2015 23:50:52 +0200
> Enhancement request:
>
> Typically in Dired commands that act on the marked files will act on the
> next PREFIX-ARG files instead, if a prefix arg is provided.  This is not
> true of commands such as `dired-do-search', but it would be good if it
> were.
>
> All that is needed is to (a) add an optional argument ARG to each such
> command and (b) include ARG in the call to `dired-get-marked-files'.
> For example:
>
> (defun dired-do-search (regexp &optional arg) ; <=== Add ARG
>   "..."
>   (interactive "sSearch marked files (regexp): \nP")
>   (tags-search
>     regexp (dired-get-marked-files nil arg 'dired-nondirectory-p)))
>                                         ^
>                                         |
>                                      use ARG

There is a problem with `dired-do-query-replace-regexp' where a prefix arg
means replace word-delimited matches.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#20195; Package emacs. (Wed, 25 Mar 2015 23:09:02 GMT) Full text and rfc822 format available.

Message #11 received at 20195 <at> debbugs.gnu.org (full text, mbox):

From: Drew Adams <drew.adams <at> oracle.com>
To: Juri Linkov <juri <at> linkov.net>
Cc: 20195 <at> debbugs.gnu.org
Subject: RE: bug#20195: 25.0.50; Let Dired commands such as `dired-do-search'
 (`A') use prefix arg
Date: Wed, 25 Mar 2015 16:08:47 -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.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#20195; Package emacs. (Tue, 31 Mar 2015 20:40:03 GMT) Full text and rfc822 format available.

Message #14 received at 20195 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: Drew Adams <drew.adams <at> oracle.com>
Cc: 20195 <at> debbugs.gnu.org
Subject: Re: bug#20195: 25.0.50;
 Let Dired commands such as `dired-do-search' (`A') use prefix arg
Date: Tue, 31 Mar 2015 23:33:54 +0300
>> 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.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#20195; Package emacs. (Tue, 31 Mar 2015 21:23:02 GMT) Full text and rfc822 format available.

Message #17 received at 20195 <at> debbugs.gnu.org (full text, mbox):

From: Drew Adams <drew.adams <at> oracle.com>
To: Juri Linkov <juri <at> linkov.net>
Cc: 20195 <at> debbugs.gnu.org
Subject: RE: bug#20195: 25.0.50; Let Dired commands such as `dired-do-search'
 (`A') use prefix arg
Date: 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.

FWIW -

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
ignored.)

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
compromise:

---

 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
    are marked.
  * 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
any markings).




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#20195; Package emacs. (Tue, 31 Mar 2015 21:55:02 GMT) Full text and rfc822 format available.

Message #20 received at 20195 <at> debbugs.gnu.org (full text, mbox):

From: Filipp Gunbin <fgunbin <at> fastmail.fm>
To: Drew Adams <drew.adams <at> oracle.com>
Cc: 20195 <at> debbugs.gnu.org, Juri Linkov <juri <at> linkov.net>
Subject: Re: bug#20195: 25.0.50;
 Let Dired commands such as `dired-do-search' (`A') use prefix arg
Date: Wed, 01 Apr 2015 00:54:33 +0300
On 31/03/2015 14:22 -0700, Drew Adams wrote:

>   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 `..')

Isn't it simpler to mark all files in a subdir (`* s') or just toggle
everything with `t' and then invoke the command?

A movement command is ok to take argument specifying a number of files,
because that number is related to that command's main purpose.  But here
files are collected according to marks set in the buffer, so it's kind
of duplication to provide the same functionality via prefix argument.

Filipp




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#20195; Package emacs. (Wed, 01 Apr 2015 00:37:02 GMT) Full text and rfc822 format available.

Message #23 received at 20195 <at> debbugs.gnu.org (full text, mbox):

From: Drew Adams <drew.adams <at> oracle.com>
To: Filipp Gunbin <fgunbin <at> fastmail.fm>
Cc: 20195 <at> debbugs.gnu.org, Juri Linkov <juri <at> linkov.net>
Subject: RE: bug#20195: 25.0.50; Let Dired commands such as `dired-do-search'
 (`A') use prefix arg
Date: Tue, 31 Mar 2015 17:36:16 -0700 (PDT)
> >   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 `..')
> 
> Isn't it simpler to mark all files in a subdir (`* s') or just toggle
> everything with `t' and then invoke the command?

That's already available.  Nothing new about that.  Useful, of course.

The point is that you might currently have markings that you want to
keep for a while, and you want to perform an on-the-fly operation on
all files, without fiddling with any existing markings.

IOW, this is an additional possibility.  It takes nothing away from
what you can already do.  In particular, it does not change the behavior
of a single `C-u' (that still acts on the next 4 files, just like `C-4').

> A movement command

I don't think there has been any mention of any movement commands.
What did you have in mind?

> is ok to take argument specifying a number of files,
> because that number is related to that command's main purpose.  But here
> files are collected according to marks set in the buffer, so it's kind
> of duplication to provide the same functionality via prefix argument.

See above.  There are *many* ways to do the same thing in Dired (and
elsewhere in Emacs).  In and of itself, eliminating such "duplication"
is a silly goal (IMHO).

And it is already the case that a numeric prefix arg acts on the next
(or previous) N files, ignoring any existing marks.

To be clear:

1. I don't really care whether Emacs adds that feature (multiple `C-u'
acts on all, ignoring markings).  And that feature is not what this
enhancement request is about.

2. As one user, I use that feature quite often (with Dired+).  If
you don't find it useful, and you prefer to always mark and unmark,
that's fine by me. ;-)




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#20195; Package emacs. (Thu, 02 Apr 2015 13:34:02 GMT) Full text and rfc822 format available.

Message #26 received at 20195 <at> debbugs.gnu.org (full text, mbox):

From: Filipp Gunbin <fgunbin <at> fastmail.fm>
To: Drew Adams <drew.adams <at> oracle.com>
Cc: 20195 <at> debbugs.gnu.org, Juri Linkov <juri <at> linkov.net>
Subject: Re: bug#20195: 25.0.50;
 Let Dired commands such as `dired-do-search' (`A') use prefix arg
Date: Thu, 02 Apr 2015 16:32:59 +0300
On 31/03/2015 17:36 -0700, Drew Adams wrote:

>> A movement command
>
> I don't think there has been any mention of any movement commands.
> What did you have in mind?

I meant other commands like `dired-next-line', just for comparison.

>> is ok to take argument specifying a number of files,
>> because that number is related to that command's main purpose.  But here
>> files are collected according to marks set in the buffer, so it's kind
>> of duplication to provide the same functionality via prefix argument.
>
> See above.  There are *many* ways to do the same thing in Dired (and
> elsewhere in Emacs).  In and of itself, eliminating such "duplication"
> is a silly goal (IMHO).

But it's rather convenient to keep in memory that:

1) First mark files you want to process.  To augment mark behaviour
(e.g. mark all files in a subdir) specify prefix arg to the mark command
or use a corresponding specific command.

2) Perform search/replace.  To augment search/replace behavior (like
toggle word searching) you have to specify prefix argument to the
search/replace command.

> To be clear:
>
> 1. I don't really care whether Emacs adds that feature (multiple `C-u'
> acts on all, ignoring markings).  And that feature is not what this
> enhancement request is about.
>
> 2. As one user, I use that feature quite often (with Dired+).  If
> you don't find it useful, and you prefer to always mark and unmark,
> that's fine by me. ;-)

Yes, my comment was just a note.

Filipp




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#20195; Package emacs. (Thu, 02 Apr 2015 14:02:02 GMT) Full text and rfc822 format available.

Message #29 received at 20195 <at> debbugs.gnu.org (full text, mbox):

From: Drew Adams <drew.adams <at> oracle.com>
To: Filipp Gunbin <fgunbin <at> fastmail.fm>
Cc: 20195 <at> debbugs.gnu.org, Juri Linkov <juri <at> linkov.net>
Subject: RE: bug#20195: 25.0.50; Let Dired commands such as `dired-do-search'
 (`A') use prefix arg
Date: Thu, 2 Apr 2015 07:01:15 -0700 (PDT)
> > See above.  There are *many* ways to do the same thing in Dired (and
> > elsewhere in Emacs).  In and of itself, eliminating such "duplication"
> > is a silly goal (IMHO).
> 
> But it's rather convenient to keep in memory that:
> 1) First mark files you want to process.  To augment mark behaviour
>    (e.g. mark all files in a subdir) specify prefix arg to the mark
>    command or use a corresponding specific command.
> 2) Perform search/replace.  To augment search/replace behavior (like
>    toggle word searching) you have to specify prefix argument to the
>    search/replace command.

Yes, there are multiple ways to do the same thing in Dired.  Nothing
in this enhancement will prevent you from always doing things the way
you prefer.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#20195; Package emacs. (Thu, 03 Feb 2022 21:20:02 GMT) Full text and rfc822 format available.

Message #32 received at 20195 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Juri Linkov <juri <at> linkov.net>
Cc: 20195 <at> debbugs.gnu.org, Drew Adams <drew.adams <at> oracle.com>
Subject: Re: bug#20195: 25.0.50; Let Dired commands such as
 `dired-do-search' (`A') use prefix arg
Date: Thu, 03 Feb 2022 22:19:17 +0100
Juri Linkov <juri <at> linkov.net> writes:

>>> 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.

So I think the conclusion here was that we can't really do the suggested
change (which sounds pretty confusing to me, anyway), so I'm closing
this bug report.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Added tag(s) wontfix. Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Thu, 03 Feb 2022 21:20:02 GMT) Full text and rfc822 format available.

bug closed, send any further explanations to 20195 <at> debbugs.gnu.org and Drew Adams <drew.adams <at> oracle.com> Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Thu, 03 Feb 2022 21:20:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Fri, 04 Mar 2022 12:24:07 GMT) Full text and rfc822 format available.

This bug report was last modified 2 years and 54 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.