From: Yuri Khan <yuri.v.khan@gmail.com>
To: Hikaru Ichijyo <ichijyo@macross.sdf.jp>
Cc: help-gnu-emacs <help-gnu-emacs@gnu.org>
Subject: Re: logical not condition in ibuffer config
Date: Mon, 12 Mar 2018 16:12:07 +0700 [thread overview]
Message-ID: <CAP_d_8VMmS+nk-NYe-LvjYFRQMYcNa-K2OBQ_7r=nxXXLpuqDA@mail.gmail.com> (raw)
In-Reply-To: <8xxk1ui1i4v.fsf@macross.sdf.jp>
On Mon, Mar 12, 2018 at 3:17 AM, Hikaru Ichijyo <ichijyo@macross.sdf.jp> wrote:
> I've been setting up ibuffer to group my buffer listing into
> categories. I've encountered a situation where I may want to make an
> exception to one of the rules. This is my config:
>
> --8<---------------cut here---------------start------------->8---
> ("Lisp & Emacs" (or
> (mode . emacs-lisp-mode)
> (mode . bookmark-bmenu-mode)
> (name . "^\\*Packages\\*$")))
> --8<---------------cut here---------------end--------------->8---
>
> I am finding that the "Lisp & Emacs" group catches my bbdb buffer,
> because it is in Emacs-Lisp mode, but I would rather this went to
> Default, since I rarely edit it directly.
The filtering/grouping feature in Ibuffer is written and documented
with interactive use, rather than long-term init-file-based
configuration, in mind. But you can use that to find out how it
represents filter intersection and inversion.
I will use predicates that are easier to test in an uncustomized
emacs, but the results should apply to your case as well.
So, first, I want a few buffers in emacs-lisp-mode, with a secondary
difference that I could intersect and invert.
$ emacs -Q
C-x C-f ~/.emacs.d/init.el RET
M-x find-library RET ibuffer RET
M-x ibuffer RET
Now, I have two buffers using emacs-lisp-mode. What’s more, one of
them has a file name ending in “.gz”. Let’s see how we can combine
these conditions.
<f1> m, scroll to Filtering commands
I see a command to combine two filters with “or”, and a command to
invert a filter. I do not see a command to combine with “and”. Let’s
try adding a filter.
/ m emacs-lisp-mode RET
Something happened. I now see only buffers in emacs-lisp-mode. (The
header line shows the currently applied filter as [major mode in use:
emacs-lisp-mode].) So far so good. Now let’s add another filter, with
a condition on file name.
/ f \.gz\' RET
Now I only see the buffer that is in emacs-lisp-mode *and* with file
name ending in “.gz”. (The header line displays this as [filename:
\.gz\'] [major mode in use: emacs-lisp-mode].) Let’s try inverting.
/ !
Now I see the buffer that is in emacs-lisp-mode and with file name
*not* ending “.gz”. (The header line updates to [NOT [filename:
\.gz\']] [major mode in use: emacs-lisp-mode].)
To see how this is represented, I will save this filter:
/ s test1 RET
Emacs says: “Setting ‘ibuffer-saved-filter-groups’ temporarily since
"emacs -q" would overwrite customizations”. I understand it as “your
changes were not saved into your init file and will only be active in
this session”. Okay, let’s see the variable.
M-: ibuffer-saved-filters RET
⇒ (("test1" (not filename . "\\.gz\\'")
(used-mode . emacs-lisp-mode))
…more filters…)
And that should answer your questions:
* For an “and”, you just write several filter expressions one after another.
* You can put “not” before the filter predicate.
> So, I want to use a 'not' condition in these rules, to say, "Put
> anything in 'Lisp & Emacs' that's in emacs-lisp-mode,
> bookmark-bmenu-mode, or is named '*Packages*', except for buffers named
> 'bbdb'."
This should be it:
("Lisp & Emacs"
(not name . "^bbdb$")
(or (mode . emacs-lisp-mode)
(mode . bookmark-bmenu-mode)
(name . "^\\*Packages\\*$")))
next prev parent reply other threads:[~2018-03-12 9:12 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-11 20:17 logical not condition in ibuffer config Hikaru Ichijyo
2018-03-11 20:29 ` Emanuel Berg
2018-03-12 5:17 ` Hikaru Ichijyo
2018-03-12 5:30 ` Emanuel Berg
2018-03-12 6:27 ` Emanuel Berg
2018-03-13 17:05 ` Emanuel Berg
2018-03-12 9:12 ` Yuri Khan [this message]
[not found] ` <mailman.10449.1520845963.27995.help-gnu-emacs@gnu.org>
2018-03-12 14:15 ` Hikaru Ichijyo
2018-03-12 18:52 ` Emanuel Berg
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAP_d_8VMmS+nk-NYe-LvjYFRQMYcNa-K2OBQ_7r=nxXXLpuqDA@mail.gmail.com' \
--to=yuri.v.khan@gmail.com \
--cc=help-gnu-emacs@gnu.org \
--cc=ichijyo@macross.sdf.jp \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.