unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* [Patch] Ibuffer filter display fix
@ 2022-06-15 15:04 Manuel Giraud
  2022-06-15 15:53 ` Lars Ingebrigtsen
  0 siblings, 1 reply; 4+ messages in thread
From: Manuel Giraud @ 2022-06-15 15:04 UTC (permalink / raw)
  To: emacs-devel

[-- 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

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [Patch] Ibuffer filter display fix
  2022-06-15 15:04 [Patch] Ibuffer filter display fix Manuel Giraud
@ 2022-06-15 15:53 ` Lars Ingebrigtsen
  2022-06-15 16:34   ` Lars Ingebrigtsen
  0 siblings, 1 reply; 4+ messages in thread
From: Lars Ingebrigtsen @ 2022-06-15 15:53 UTC (permalink / raw)
  To: Manuel Giraud; +Cc: emacs-devel

Manuel Giraud <manuel@ledu-giraud.fr> writes:

> 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]"

Thanks; pushed to Emacs 29.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Patch] Ibuffer filter display fix
  2022-06-15 15:53 ` Lars Ingebrigtsen
@ 2022-06-15 16:34   ` Lars Ingebrigtsen
  2022-06-15 16:37     ` Lars Ingebrigtsen
  0 siblings, 1 reply; 4+ messages in thread
From: Lars Ingebrigtsen @ 2022-06-15 16:34 UTC (permalink / raw)
  To: Manuel Giraud; +Cc: emacs-devel

Lars Ingebrigtsen <larsi@gnus.org> writes:

>> "IBuffer by recency [visiting a file]"
>
> Thanks; pushed to Emacs 29.

This unfortunately led to a test failure in ibuffer-format-qualifier.
Can you have a look at that?

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Patch] Ibuffer filter display fix
  2022-06-15 16:34   ` Lars Ingebrigtsen
@ 2022-06-15 16:37     ` Lars Ingebrigtsen
  0 siblings, 0 replies; 4+ messages in thread
From: Lars Ingebrigtsen @ 2022-06-15 16:37 UTC (permalink / raw)
  To: Manuel Giraud; +Cc: emacs-devel

Lars Ingebrigtsen <larsi@gnus.org> writes:

> This unfortunately led to a test failure in ibuffer-format-qualifier.
> Can you have a look at that?

Never mind -- it was obvious what to fix, so I just did that.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-06-15 16:37 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-15 15:04 [Patch] Ibuffer filter display fix Manuel Giraud
2022-06-15 15:53 ` Lars Ingebrigtsen
2022-06-15 16:34   ` Lars Ingebrigtsen
2022-06-15 16:37     ` Lars Ingebrigtsen

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).