From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Yuri Khan Newsgroups: gmane.emacs.help Subject: Re: logical not condition in ibuffer config Date: Mon, 12 Mar 2018 16:12:07 +0700 Message-ID: References: <8xxk1ui1i4v.fsf@macross.sdf.jp> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Trace: blaine.gmane.org 1520845871 32088 195.159.176.226 (12 Mar 2018 09:11:11 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 12 Mar 2018 09:11:11 +0000 (UTC) Cc: help-gnu-emacs To: Hikaru Ichijyo Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Mon Mar 12 10:11:07 2018 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1evJU2-00085C-IB for geh-help-gnu-emacs@m.gmane.org; Mon, 12 Mar 2018 10:11:06 +0100 Original-Received: from localhost ([::1]:57247 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1evJW0-0006Nf-CN for geh-help-gnu-emacs@m.gmane.org; Mon, 12 Mar 2018 05:13:08 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:49533) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1evJVT-0006MW-ND for help-gnu-emacs@gnu.org; Mon, 12 Mar 2018 05:12:42 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1evJVN-00005l-Cc for help-gnu-emacs@gnu.org; Mon, 12 Mar 2018 05:12:35 -0400 Original-Received: from mail-ot0-x236.google.com ([2607:f8b0:4003:c0f::236]:33434) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1evJVN-0008Ug-7h for help-gnu-emacs@gnu.org; Mon, 12 Mar 2018 05:12:29 -0400 Original-Received: by mail-ot0-x236.google.com with SMTP id y11so14556363otg.0 for ; Mon, 12 Mar 2018 02:12:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc:content-transfer-encoding; bh=ksKANyZP9qNgNmwhyHqjWRi+TNsXoTwzgZ/OfYbBmLg=; b=rxq0//zzfnJI3WSXZBwBXMWfiDbxvG0Q1GVv2al1YlWlHU/a2NcyyHRgjJbu7RI4KS Eao0sdQ/rpNsEyL3Fnm8IwVajMBePTHkAI9sZDGPWukvbdQviLc3ihTb4ULlQstOPQt/ QL2u9rs9re7KInDPSwZBhrBabSr/jGKX4BHAdAYm06qW40kZvd+0N+lGBBcc97DD7fLc WDXBMJuqirNSswYpOJKP4AHbfa+kFwymWlGWjO3/i8C67Ek8sExrdRgoThekTUwGq4K3 Xcc1NblPtUZmXptGg+93XuItGeito7sfJOHHurGpswsGfJ5CEz86YA2F8GlvFRxDhbr/ XKyA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc:content-transfer-encoding; bh=ksKANyZP9qNgNmwhyHqjWRi+TNsXoTwzgZ/OfYbBmLg=; b=lajEg3uAE7e3emUYCNyM6GjOi98zIlbxDovZ2QSN/VZZ8n8j95qcimMPRB/5tP7WK8 O+Qho6jTCVJAIvK+2xD5mcgXD4CBpMZzN3A4iOiWPp7QmReztBQVi4Qhw+1fIw2SjKit LAf+rr/KWOAWgIGhXywg7Nw0IVXDl5FaEfkqXZW8nTsZ2R5Qlr8eN6PYefH7eY02DzSr p9nimth7/UYlOCaG5CQF7K5cf7vEGXJT3UQedMVnRHGuBkBTp9Yu6gOJQ5AFdDit3nJ7 VROXL9t98NluilpRETjjzpM6HQjxOAXTJ94TLflc0WBoSisEkOgD7WJdpFXiE5StHgjy uSfg== X-Gm-Message-State: AElRT7F9TFYT82j9NdnxFA7cQPb80y8vAJbStVQIPHmoi5cTHPjDwBfa zia9k/Qx0Ri/U3MM3MHhbitjx6/fr46OB92+1c+RPw== X-Google-Smtp-Source: AG47ELu5K5dtV1EURqVys1aGtIT5QbN8uY6GLNypvsbtMel1CLwJG3cC36keNKOQ6TgPI74GW5LiesYykf0INjneL+w= X-Received: by 10.157.86.226 with SMTP id b31mr4723670otj.209.1520845947850; Mon, 12 Mar 2018 02:12:27 -0700 (PDT) Original-Received: by 10.74.211.77 with HTTP; Mon, 12 Mar 2018 02:12:07 -0700 (PDT) In-Reply-To: <8xxk1ui1i4v.fsf@macross.sdf.jp> X-Google-Sender-Auth: Eo890DobGvjcLt_eQXH-PM1U2sE X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4003:c0f::236 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.org gmane.emacs.help:116178 Archived-At: On Mon, Mar 12, 2018 at 3:17 AM, Hikaru Ichijyo wr= ote: > 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=E2=80=99s more, one of them has a file name ending in =E2=80=9C.gz=E2=80=9D. Let=E2=80=99s see how= we can combine these conditions. m, scroll to Filtering commands I see a command to combine two filters with =E2=80=9Cor=E2=80=9D, and a com= mand to invert a filter. I do not see a command to combine with =E2=80=9Cand=E2=80= =9D. Let=E2=80=99s 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=E2=80=99s add another filter, wi= th 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 =E2=80=9C.gz=E2=80=9D. (The header line displays this as [fi= lename: \.gz\'] [major mode in use: emacs-lisp-mode].) Let=E2=80=99s try inverting. / ! Now I see the buffer that is in emacs-lisp-mode and with file name *not* ending =E2=80=9C.gz=E2=80=9D. (The header line updates to [NOT [filen= ame: \.gz\']] [major mode in use: emacs-lisp-mode].) To see how this is represented, I will save this filter: / s test1 RET Emacs says: =E2=80=9CSetting =E2=80=98ibuffer-saved-filter-groups=E2=80=99 = temporarily since "emacs -q" would overwrite customizations=E2=80=9D. I understand it as =E2= =80=9Cyour changes were not saved into your init file and will only be active in this session=E2=80=9D. Okay, let=E2=80=99s see the variable. M-: ibuffer-saved-filters RET =E2=87=92 (("test1" (not filename . "\\.gz\\'") (used-mode . emacs-lisp-mode)) =E2=80=A6more filters=E2=80=A6) And that should answer your questions: * For an =E2=80=9Cand=E2=80=9D, you just write several filter expressions o= ne after another. * You can put =E2=80=9Cnot=E2=80=9D 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\\*$")))