Subject: Re: bug#6847: 23.2; ibuffer-filter-by-filename ignores buffer directory names

From: Stefan Kangas <[email-masked]>
Date: Sun, 4 Aug 2019 19:41:16 +0200

tags 6847 + patch
quit

Damyan Pepper <[email-masked]> writes:

> When using ibuffer.el if I set it to filter by filename then dired
> buffers visiting directories are not included in the filter.  This is
> inconsistent with the way that ibuffer displays the buffers.
>
> For example, if I start with emacs -Q, open a few buffers and run M-x ibuffer:
>
> MR Name                    Size Mode             Filename/Process
> -- ----                    ---- ----             ----------------
> [ Default ]
>    README                  5276 Fundamental      c:/emacs-23.2/README
>  % emacs-23.2               857 Dired by name    c:/emacs-23.2/
>  % etc                     5627 Dired by name    c:/emacs-23.2/etc/
>  % bin                     1299 Dired by name    c:/emacs-23.2/bin/
>    *scratch*                191 Lisp Interaction
> *  *Messages*               131 Fundamental
>
>    6 buffers              13381                  4 files, no processes
>
> and then press "/ f emacs" I get:
>
> MR Name                    Size Mode             Filename/Process
> -- ----                    ---- ----             ----------------
> [ Default ]
>    README                  5276 Fundamental      c:/emacs-23.2/README
>
>    1 buffer                5276                  1 file, no processes
>
>
> Note that the emacs-23.2, etc and bin buffers all have an entry in the
> "Filename/Process" column that is ignored by the filter.

I think this use case should be mostly covered by the recently added
ibuffer-filter-by-directory command:

    commit 35aaa6b6aa9a2e7b42465603fb32355a009c510f
    Author: Christopher Genovese <[email-masked]>
    Date:   Tue Dec 20 17:41:56 2016 +0900

        ibuffer: New filters and commands

But it would seem that this command never got a key binding.  This is an
excerpt from C-h f ibuffer-mode:

    Filtering commands:

      ‘M-x ibuffer-filter-chosen-by-completion’ - Select and apply
filter chosen by completion.
      ‘/ RET’ - Add a filter by any major mode.
      ‘/ m’ - Add a filter by a major mode now in use.
      ‘/ M’ - Add a filter by derived mode.
      ‘/ n’ - Add a filter by buffer name.
      ‘/ c’ - Add a filter by buffer content.
      ‘/ b’ - Add a filter by basename.
      ‘M-x ibuffer-filter-by-directory’ - Add a filter by directory name.
      ‘/ f’ - Add a filter by filename.
      ‘/ .’ - Add a filter by file extension.

I suggest to add the keybinding "/ F" for ibuffer-filter-by-directory
and "/ SPC" for ibuffer-filter-chosen-by-completion.  Perhaps "/ d" or
"/ D" would be more natural for the directory case, but alas they are
already taken.

Please see the attached patch.

Thanks,
Stefan Kangas