GNU bug report logs - #46882
26.3; Let `dired-omit-mode' match lines, as well as file names

Previous Next

Package: emacs;

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

Date: Wed, 3 Mar 2021 00:40:01 UTC

Severity: wishlist

Found in version 26.3

Fixed in version 29.1

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 46882 in the body.
You can then email your comments to 46882 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#46882; Package emacs. (Wed, 03 Mar 2021 00:40:01 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, 03 Mar 2021 00:40:01 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" <bug-gnu-emacs <at> gnu.org>
Subject: 26.3; Let `dired-omit-mode' match lines, as well as file names
Date: Wed, 3 Mar 2021 00:39:42 +0000
[Message part 1 (text/plain, inline)]
`dired-omit-mode' matches file names against regexps, and removes their
lines from the Dired listing.

It can also be useful to match other things on a file's line, besides
its name.  For example, match the `x' permission to omit executable files.

The attached code implements this.  It adds a new option,
`dired-omit-line-regexp', which is a regexp to match lines.

It redefines `dired-omit-mode', `dired-omit-expunge', and
`dired-do-kill-lines'.  It adds optional args LINEP and INIT-COUNT to
`dired-omit-expunge', and optional arg INIT-COUNT to
`dired-do-kill-lines'.

When the new option is non-nil, `dired-omit-mode' calls
`dired-omit-expunge' a second time, to omit matching lines.

The updated doc of `dired-do-kill-lines' speaks only of removing lines
from the listing, not of "killing" lines, to avoid confusion with kills
(the `kill-ring' is unaffected by this command).  We should consider
renaming the command altogether, but then the key binding of `k' would
no longer be mnemonic'.  At the very least, if the doc continues to
speak of "killing" lines then it should explicitly say that the
`kill-ring' is unaffected.

If this improvement is OK (try it) then I can send a patch.  Otherwise,
I won't bother.

The improvement was inspired by this user question:

https://emacs.stackexchange.com/q/63659/105


In GNU Emacs 26.3 (build 1, x86_64-w64-mingw32)
 of 2019-08-29
Repository revision: 96dd0196c28bc36779584e47fffcca433c9309cd
Windowing system distributor `Microsoft Corp.', version 10.0.19041
Configured using:
 `configure --without-dbus --host=x86_64-w64-mingw32
 --without-compress-install 'CFLAGS=-O2 -static -g3''

[throw-dir-omit.el (application/octet-stream, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#46882; Package emacs. (Wed, 03 Mar 2021 18:11:01 GMT) Full text and rfc822 format available.

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

From: Drew Adams <drew.adams <at> oracle.com>
To: Drew Adams <drew.adams <at> oracle.com>, "46882 <at> debbugs.gnu.org"
 <46882 <at> debbugs.gnu.org>
Subject: RE: 26.3; Let `dired-omit-mode' match lines, as well as file names
Date: Wed, 3 Mar 2021 18:10:20 +0000
I changed the option so its value can also be a var
whose value is such a regexp.

(defcustom dired-omit-lines-regexp nil
  "Regexp matching lines to be omitted by `dired-omit-mode'.
The value can also be a variable whose value is such a regexp.
The value can also be nil, which means do no line matching.

See command `dired-omit-mode' (\\[dired-omit-mode]).

Some predefined regexp variables for Dired, which you can use as the
option value:

* `dired-re-inode-size'
* `dired-re-mark'
* `dired-re-maybe-mark'
* `dired-re-dir'
* `dired-re-sym'
* `dired-re-exe'
* `dired-re-perms'
* `dired-re-dot'
* `dired-re-no-dot'"
  :type `(choice
          (const  :tag "Do not match lines to omit" nil)
          (regexp
            :tag "Regexp to match lines to omit (default omits executables)" 
            :value ,dired-re-exe)
          (restricted-sexp
            :tag "Variable with regexp value (default: `dired-re-exe')"
            :match-alternatives
            ((lambda (obj) (and (symbolp obj) (boundp obj))))
            :value dired-re-exe))
  :group 'dired-x)




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#46882; Package emacs. (Sun, 19 Jun 2022 23:51:02 GMT) Full text and rfc822 format available.

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

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Drew Adams <drew.adams <at> oracle.com>
Cc: 46882 <at> debbugs.gnu.org
Subject: Re: bug#46882: 26.3; Let `dired-omit-mode' match lines, as well as
 file names
Date: Mon, 20 Jun 2022 01:49:50 +0200
Drew Adams <drew.adams <at> oracle.com> writes:

> When the new option is non-nil, `dired-omit-mode' calls
> `dired-omit-expunge' a second time, to omit matching lines.

Seems to work well; I've now pushed to Emacs 29 (with some changes).

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




bug marked as fixed in version 29.1, send any further explanations to 46882 <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. (Sun, 19 Jun 2022 23:51:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#46882; Package emacs. (Mon, 20 Jun 2022 16:54:02 GMT) Full text and rfc822 format available.

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

From: Juri Linkov <juri <at> linkov.net>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: 46882 <at> debbugs.gnu.org, Drew Adams <drew.adams <at> oracle.com>
Subject: Re: bug#46882: 26.3; Let `dired-omit-mode' match lines, as well as
 file names
Date: Mon, 20 Jun 2022 19:49:22 +0300
>> When the new option is non-nil, `dired-omit-mode' calls
>> `dired-omit-expunge' a second time, to omit matching lines.
>
> Seems to work well; I've now pushed to Emacs 29 (with some changes).

Its counterpart variable is `dired-omit-files' that is a regexp.
Shouldn't the new variable be named with the same naming scheme
for consistency?  I.e. just `dired-omit-lines'.  Even so that
it's not just a regexp, but can be a symbol of a function name.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#46882; Package emacs. (Mon, 20 Jun 2022 19:38:01 GMT) Full text and rfc822 format available.

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

From: Drew Adams <drew.adams <at> oracle.com>
To: Juri Linkov <juri <at> linkov.net>, Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: "46882 <at> debbugs.gnu.org" <46882 <at> debbugs.gnu.org>
Subject: RE: [External] : Re: bug#46882: 26.3; Let `dired-omit-mode' match
 lines, as well as file names
Date: Mon, 20 Jun 2022 19:36:56 +0000
> Its counterpart variable is `dired-omit-files' that is a regexp.
> Shouldn't the new variable be named with the same naming scheme
> for consistency?  I.e. just `dired-omit-lines'.  Even so that
> it's not just a regexp, but can be a symbol of a function name.

It's a valid question, but it opens a can of
worms.  There's no consistency already. ;-)

Consider option `dired-garbage-files-regexp',
for example.

Generally, an option whose value is a regexp
is better named with `regexp' in the name.

`dired-omit-files' would be better named
`dired-omit-files-regexp' or similar.

FWIW, Dired+ has these additional options:

diredp-visit-ignore-regexps
diredp-omit-files-font-lock-regexp

And of course diredp-omit-lines-regexp.

If you really want to aim for consistency
then consider renaming `dired-omit-files'
to `dired-omit-files-regexp'. ;-)




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#46882; Package emacs. (Tue, 21 Jun 2022 10:45:01 GMT) Full text and rfc822 format available.

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

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Juri Linkov <juri <at> linkov.net>
Cc: 46882 <at> debbugs.gnu.org, Drew Adams <drew.adams <at> oracle.com>
Subject: Re: bug#46882: 26.3; Let `dired-omit-mode' match lines, as well as
 file names
Date: Tue, 21 Jun 2022 12:44:10 +0200
Juri Linkov <juri <at> linkov.net> writes:

> Its counterpart variable is `dired-omit-files' that is a regexp.
> Shouldn't the new variable be named with the same naming scheme
> for consistency?  I.e. just `dired-omit-lines'.  Even so that
> it's not just a regexp, but can be a symbol of a function name.

Makes sense; now renamed.

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




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#46882; Package emacs. (Tue, 21 Jun 2022 14:34:02 GMT) Full text and rfc822 format available.

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

From: Drew Adams <drew.adams <at> oracle.com>
To: Lars Ingebrigtsen <larsi <at> gnus.org>, Juri Linkov <juri <at> linkov.net>
Cc: "46882 <at> debbugs.gnu.org" <46882 <at> debbugs.gnu.org>
Subject: RE: [External] : Re: bug#46882: 26.3; Let `dired-omit-mode' match
 lines, as well as file names
Date: Tue, 21 Jun 2022 14:33:02 +0000
> > Its counterpart variable is `dired-omit-files' that is a regexp.
> > Shouldn't the new variable be named with the same naming scheme
> > for consistency?  I.e. just `dired-omit-lines'.  Even so that
> > it's not just a regexp, but can be a symbol of a function name.
                                                ^^^^^^^^^^^^^^^^^^
Ah, so you _didn't_ use the code I sent, which
supports a symbol as a _variable_, whose value
is a regexp.  Too bad.

And what kind of function are we talking about?
A function that returns a regexp?  A function
that does something else?

> Makes sense; now renamed.

Too bad.  Guess that changes this from "done"
to "won't fix".

Guess this is hidden behind your "I've now
pushed to Emacs 29 (with some changes)."
                    ^^^^^^^^^^^^^^^^^

Guess I'll have to keep the original option
`diredp-omit-lines-regexp' around.  I was
hoping Emacs would absorb it, so renaming
`diredp-' to `dired-' would suffice.

For your "consistency" maybe you'll now want
to change `dired-omit-files' to also support
a function symbol...  I mean, _consistency_,
right?

And while you're at it, for "consistency"
consider renaming `dired-garbage-files-regexp'.
Oh, and add support for it to be a function
symbol...  Consistency.

Consistency is a wonderful, hobgoblinny thing.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Wed, 20 Jul 2022 11:24:10 GMT) Full text and rfc822 format available.

This bug report was last modified 1 year and 273 days ago.

Previous Next


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