unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Manuel Giraud <manuel@ledu-giraud.fr>
To: "emacs-devel" <emacs-devel@gnu.org>
Subject: [Patch] Ibuffer filter display fix
Date: Wed, 15 Jun 2022 17:04:34 +0200	[thread overview]
Message-ID: <87tu8mt1bx.fsf@elite.giraud> (raw)

[-- Attachment #1: Type: text/plain, Size: 288 bytes --]

Hi,

In ibuffer, when using a filter without parameter (like
`ibuffer-filter-by-visiting-file'), the header displays:

"IBuffer by recency [visiting a file: nil]"

The following patch get rid of the "nil" for filters that do not have a
parameter:

"IBuffer by recency [visiting a file]"


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Do-not-display-nil-for-0-ary-filter-qualifier.patch --]
[-- Type: text/x-patch, Size: 2338 bytes --]

From b141854b7e01520e3b760bf1ce7ff8b7e9a31de5 Mon Sep 17 00:00:00 2001
From: Manuel Giraud <manuel@ledu-giraud.fr>
Date: Wed, 15 Jun 2022 15:53:09 +0200
Subject: [PATCH] Do not display 'nil for 0-ary filter qualifier

* lisp/ibuf-ext.el (ibuffer-format-qualifier-1): do not display
nil in header for 0-ary filter qualifier
* lisp/ibuf-macs.el (define-ibuffer-filter): also fix the message
---
 lisp/ibuf-ext.el  |  4 +++-
 lisp/ibuf-macs.el | 12 ++++++++----
 2 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/lisp/ibuf-ext.el b/lisp/ibuf-ext.el
index 30b494f573..822ecbdd99 100644
--- a/lisp/ibuf-ext.el
+++ b/lisp/ibuf-ext.el
@@ -1211,7 +1211,9 @@ ibuffer-format-qualifier-1
      (let ((type (assq (car qualifier) ibuffer-filtering-alist)))
        (unless qualifier
          (error "Ibuffer: Bad qualifier %s" qualifier))
-       (concat " [" (cadr type) ": " (format "%s]" (cdr qualifier)))))))
+       (if (cdr qualifier)
+           (format " [%s: %s]" (cadr type) (cdr qualifier))
+         (format " [%s]" (cadr type)))))))
 
 (defun ibuffer-list-buffer-modes (&optional include-parents)
   "Create a completion table of buffer modes currently in use.
diff --git a/lisp/ibuf-macs.el b/lisp/ibuf-macs.el
index 5d2dd47945..7a519e041a 100644
--- a/lisp/ibuf-macs.el
+++ b/lisp/ibuf-macs.el
@@ -321,10 +321,14 @@ define-ibuffer-filter
          (when (cdr qualifier) ; Compose individual filters with `or'.
            (setq ,filter `(or ,@(mapcar (lambda (m) (cons ',name m)) qualifier))))))
        (if (null (ibuffer-push-filter ,filter))
-           (message ,(format "Filter by %s already applied:  %%s" description)
-                ,qualifier-str)
-         (message ,(format "Filter by %s added:  %%s" description)
-              ,qualifier-str)
+           (if ,qualifier-str
+               (message ,(format "Filter by %s already applied:  %%s" description)
+                        ,qualifier-str)
+             (message ,(format "Filter by %s already applied" description)))
+         (if ,qualifier-str
+             (message ,(format "Filter by %s added:  %%s" description)
+                      ,qualifier-str)
+           (message ,(format "Filter by %s added" description)))
          (ibuffer-update nil t))))
        (push (list ',name ,description
            (lambda (buf qualifier)
-- 
2.36.1


[-- Attachment #3: Type: text/plain, Size: 18 bytes --]

-- 
Manuel Giraud

             reply	other threads:[~2022-06-15 15:04 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-15 15:04 Manuel Giraud [this message]
2022-06-15 15:53 ` [Patch] Ibuffer filter display fix Lars Ingebrigtsen
2022-06-15 16:34   ` Lars Ingebrigtsen
2022-06-15 16:37     ` Lars Ingebrigtsen

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

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87tu8mt1bx.fsf@elite.giraud \
    --to=manuel@ledu-giraud.fr \
    --cc=emacs-devel@gnu.org \
    /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 public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).