GNU bug report logs - #25049
ibuffer bug when saving existing filter, with patches

Previous Next

Package: emacs;

Reported by: Christopher Genovese <genovese <at> cmu.edu>

Date: Mon, 28 Nov 2016 06:57:02 UTC

Severity: normal

Done: Tino Calancha <tino.calancha <at> gmail.com>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: help-debbugs <at> gnu.org (GNU bug Tracking System)
To: Christopher Genovese <genovese <at> cmu.edu>
Subject: bug#25049: closed (Re: bug#25049: ibuffer bug when saving
 existing filter, with patches)
Date: Wed, 07 Dec 2016 10:57:02 +0000
[Message part 1 (text/plain, inline)]
Your bug report

#25049: ibuffer bug when saving existing filter, with patches

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to 25049 <at> debbugs.gnu.org.

-- 
25049: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=25049
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
From: Tino Calancha <tino.calancha <at> gmail.com>
To: 25049-done <at> debbugs.gnu.org
Subject: Re: bug#25049: ibuffer bug when saving existing filter, with patches
Date: Wed, 07 Dec 2016 19:56:39 +0900
Tino Calancha <tino.calancha <at> gmail.com> writes:

> If we don't get further comments to address in 1 week, then let's
> push this fix to the master branch.
Pushed to master branch as commit 20f5a5b.

[Message part 3 (message/rfc822, inline)]
From: Christopher Genovese <genovese <at> cmu.edu>
To: bug-gnu-emacs <at> gnu.org
Cc: Tino Calancha <tino.calancha <at> gmail.com>
Subject: ibuffer bug when saving existing filter, with patches
Date: Mon, 28 Nov 2016 01:54:39 -0500
[Message part 4 (text/plain, inline)]
Hello,

In at least Emacs 25+, the function 'ibuffer-save-filters'
handles saving existing filters and new filters inconsistently.
Specifically, at the following point in the original function:

  (ibuffer-aif (assoc name ibuffer-saved-filters)
      (setcdr it filters)
    (push (list name filters) ibuffer-saved-filters))

the setcdr (existing filters) and the push (new filters)
save different formats for the variable, with the latter
having an extra layer of parentheses.

As a specific example of failure, using the current default
value of 'ibuffer-saved-filters'

        (("gnus"
          ((or
            (mode . message-mode)
            (mode . mail-mode)
            (mode . gnus-group-mode)
            (mode . gnus-summary-mode)
            (mode . gnus-article-mode))))
         ("programming"
          ((or
            (mode . emacs-lisp-mode)
            (mode . cperl-mode)
            (mode . c-mode)
            (mode . java-mode)
            (mode . idl-mode)
            (mode . lisp-mode)))))

and doing

   (ibuffer-save-filters "foo" '((name . "foo") (derived-mode . text-mode)))
   (ibuffer-save-filters "gnus" '((filename . ".")
                                  (or (derived-mode . prog-mode)
                                      (mode . "compilation-mode"))))

gives the following incorrect value for `ibuffer-saved-filters'

        (("foo"
          ((name . "foo")
           (derived-mode . text-mode)))
         ("gnus"
          (filename . ".")
          (or
           (derived-mode . prog-mode)
           (mode . "compilation-mode")))
         ("programming"
          ((or
            (mode . emacs-lisp-mode)
            (mode . cperl-mode)
            (mode . c-mode)
            (mode . java-mode)
            (mode . idl-mode)
            (mode . lisp-mode)))))

because the "foo" and "gnus" entries have different formats,
the latter not consistent with later code to access it
(e.g., in 'ibuffer-included-in-filter-p-1' and 'ibuffer-decompose-filter').

There are two immediate paths for fixing this:

  1. Change the setcdr to add the extra level of nesting.
  2. Change the format of 'ibuffer-saved-filters' to remove
     the level of testing, change the push (list->cons) and
     the later accesses (cadr->cdr).

The first is very simple, but the extra level of nesting
is unsightly, inconsistent with the structure of filter groups,
and mildly annoying when writing filters by hand.  The
second is fairly simple, requiring only a few more small changes,
but introduces the complication of changing an existing
variable's format. (For what it's worth, I prefer the second.)

I have attached a patch file with patches for three commits
as follows:

  1/3: The very simple fix corresponding to choice 1 above.
  2/3: The simple fix corresponding to choice 2 above.
  3/3: Some extra support added for handling the change
       in format for 'ibuffer-saved-filters'.

Let me know if you need any further information.

Thanks, Chris
[Message part 5 (text/html, inline)]
[ibuffer-saved-filters-bug.patch (text/x-diff, attachment)]

This bug report was last modified 8 years and 166 days ago.

Previous Next


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