GNU bug report logs - #18859
24.3; ibuffer-mark-by-file-name-regexp does not match displayed name

Previous Next

Package: emacs;

Reported by: Reuben Thomas <rrt <at> sc3d.org>

Date: Mon, 27 Oct 2014 21:21:02 UTC

Severity: minor

Tags: fixed, patch

Found in version 24.3

Fixed in version 27.1

Done: Lars Ingebrigtsen <larsi <at> mouse.gnus.org>

Bug is archived. No further changes may be made.

Full log


Message #24 received at 18859 <at> debbugs.gnu.org (full text, mbox):

From: "Basil L. Contovounesios" <contovob <at> tcd.ie>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: 18859 <at> debbugs.gnu.org, Reuben Thomas <rrt <at> sc3d.org>
Subject: Re: bug#18859: 24.3; ibuffer-mark-by-file-name-regexp does not
 match displayed name
Date: Sun, 17 Jan 2021 16:06:20 +0000
[Message part 1 (text/plain, inline)]
Lars Ingebrigtsen <larsi <at> gnus.org> writes:

> Reuben Thomas <rrt <at> sc3d.org> writes:
>
>> In the *IBuffer*, files in my home directory are displayed with names
>> starting with ā€˜~’, but when I type % f ~ RET I get no matches. If I type
>> instead % f /home/MYUSER RET then all files in my home directory are
>> matched.
>>
>> I’m not convinced that the matches should be made in the second case,
>> even; but certainly they _should_ be made in the first.
>
> The following patch fixes this by matching on the abbreviated file name
> (which is what ibuffer uses to create the displayed file name).
>
> But I guess this could be a controversial change -- does anybody have an
> objection to making this change?  
>
> diff --git a/lisp/ibuf-ext.el b/lisp/ibuf-ext.el
> index 1b69574a39..06a2248d40 100644
> --- a/lisp/ibuf-ext.el
> +++ b/lisp/ibuf-ext.el
> @@ -1846,7 +1846,8 @@ ibuffer-mark-by-file-name-regexp
>  			  (stringp dired-directory)
>  			  dired-directory)))))
>  	 (when name
> -	   (string-match regexp name))))))
> +           ;; Match on the displayed file name (which is abbreviated).
> +	   (string-match regexp (abbreviate-file-name name)))))))

Any objections to this followup fix for master?

[0001-Fix-ibuffer-mark-by-file-name-regexp-abbreviations.patch (text/x-diff, inline)]
From 2a66de550d184728ca281d400538b0954728a69e Mon Sep 17 00:00:00 2001
From: "Basil L. Contovounesios" <contovob <at> tcd.ie>
Date: Sun, 17 Jan 2021 15:53:53 +0000
Subject: [PATCH] Fix ibuffer-mark-by-file-name-regexp abbreviations

* lisp/ibuf-ext.el (ibuffer-mark-by-file-name-regexp): Prefer
read-regexp over read-string for reading regexps.  Determine file
name using ibuffer-buffer-file-name for consistency.  Abbreviate
file name using ibuffer-directory-abbrev-alist (bug#18859).
---
 lisp/ibuf-ext.el | 18 +++++++-----------
 1 file changed, 7 insertions(+), 11 deletions(-)

diff --git a/lisp/ibuf-ext.el b/lisp/ibuf-ext.el
index 7be1b3d16c..53ccd7a96e 100644
--- a/lisp/ibuf-ext.el
+++ b/lisp/ibuf-ext.el
@@ -1823,18 +1823,14 @@ ibuffer-mark-by-mode-regexp
 ;;;###autoload
 (defun ibuffer-mark-by-file-name-regexp (regexp)
   "Mark all buffers whose file name matches REGEXP."
-  (interactive "sMark by file name (regexp): ")
+  (interactive (list (read-regexp "Mark by file name (regexp)")))
   (ibuffer-mark-on-buffer
-   #'(lambda (buf)
-       (let ((name (or (buffer-file-name buf)
-		       (with-current-buffer buf
-			 (and
-			  (boundp 'dired-directory)
-			  (stringp dired-directory)
-			  dired-directory)))))
-	 (when name
-           ;; Match on the displayed file name (which is abbreviated).
-	   (string-match regexp (abbreviate-file-name name)))))))
+   (lambda (buf)
+     (let ((name (with-current-buffer buf (ibuffer-buffer-file-name))))
+       (when name
+         ;; Match on the displayed file name (which is abbreviated).
+         (let ((directory-abbrev-alist ibuffer-directory-abbrev-alist))
+           (string-match-p regexp (abbreviate-file-name name))))))))
 
 ;;;###autoload
 (defun ibuffer-mark-by-content-regexp (regexp &optional all-buffers)
-- 
2.29.2

[Message part 3 (text/plain, inline)]
Thanks,

-- 
Basil

This bug report was last modified 4 years and 206 days ago.

Previous Next


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