From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Kangas Newsgroups: gmane.emacs.bugs Subject: bug#59165: 29.0.50; [PATCH] Ibuffer directory filter not buffer aware Date: Thu, 10 Nov 2022 16:49:49 -0800 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="21531"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Christopher Genovese To: Gabriel , 59165@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Nov 11 01:50:10 2022 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1otIFG-0005Ug-1K for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 11 Nov 2022 01:50:10 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1otIFA-0007Zc-PM; Thu, 10 Nov 2022 19:50:04 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1otIF8-0007Z7-Kv for bug-gnu-emacs@gnu.org; Thu, 10 Nov 2022 19:50:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1otIF8-0007pK-5e for bug-gnu-emacs@gnu.org; Thu, 10 Nov 2022 19:50:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1otIF8-0000lA-0k for bug-gnu-emacs@gnu.org; Thu, 10 Nov 2022 19:50:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Kangas Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 11 Nov 2022 00:50:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 59165 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 59165-submit@debbugs.gnu.org id=B59165.16681277982900 (code B ref 59165); Fri, 11 Nov 2022 00:50:01 +0000 Original-Received: (at 59165) by debbugs.gnu.org; 11 Nov 2022 00:49:58 +0000 Original-Received: from localhost ([127.0.0.1]:44697 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1otIF3-0000ki-Rm for submit@debbugs.gnu.org; Thu, 10 Nov 2022 19:49:58 -0500 Original-Received: from mail-oi1-f182.google.com ([209.85.167.182]:38542) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1otIF1-0000kO-Qt for 59165@debbugs.gnu.org; Thu, 10 Nov 2022 19:49:56 -0500 Original-Received: by mail-oi1-f182.google.com with SMTP id v81so3617123oie.5 for <59165@debbugs.gnu.org>; Thu, 10 Nov 2022 16:49:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:cc:to:subject:message-id:date :mime-version:references:in-reply-to:from:from:to:cc:subject:date :message-id:reply-to; bh=+H2Hs4MHEFvFR4SN/xFbI+6ZOEqUsxNP5xliRPJyjWc=; b=a/3jy5GOPIPoPuTG2tH8FDGsg4WxBetxok0pJqcVHK4PLJQFlKygqwo90RFmls8jB2 UUibVYGspBbUzORx35j3jaImqmhF2LIWQi9OTJqZgreg+jEp0NATJ1H2pbZQWBSZXbc6 Q8QHYj+B1hgWNw8dVHZGoCRSWXjMLcuygKAedv+YYzbArucmKXAFYzp4BEWusI7bGFSg 8f+QfJ3HENWhIJF1sA41p0fBEi61VRNfnx4A/8dZCdISa/oiEs86Z2IDuXOMcCkrK5YK rIewiYkKQWNFWcqOwGNwHgGDV29A3FK311me9aqbQb/jVlFMnMSGPdUxYCHLY0horEzl 5zyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:cc:to:subject:message-id:date :mime-version:references:in-reply-to:from:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=+H2Hs4MHEFvFR4SN/xFbI+6ZOEqUsxNP5xliRPJyjWc=; b=HTcU+k1XV4lmXg7N6C+m9AtpaGECQ3Y6cYwOZfaQZjGftiomHQDWYYpprBxq/jk7L3 M41IXbggLp8Da89oAStW6zocITIOWU3VFeVLq9qOWEpqs8ijpt5YvHOdRrJvaRgUl0q9 AKDeQnZ+jnhbmCRqsysKYvY1jVXuhJxtdWEBiHxRheL3x92OGEML9MxVvpGEZWPPjZeO GHCc8bhbLhnSbHyaOt2aSzdqC06QXrUKias0yCR49zydCudtem2myD10o6faj7vxnoVl pzWszp46S5RyQQOkTWPbjIRCpeRqrB9eCUNWI62BNuUVpB/tFFfErdFsWo9L3ThR7wLS BlaQ== X-Gm-Message-State: ACrzQf34KaWXy+XLj7MufFY3Mj1ueY7tmEKHzQ+U8fPgFk8PdEUUfoc4 UwMvqt23XAJuoscilwXLyjbypqwQEatbEkWPpl8= X-Google-Smtp-Source: AMsMyM4XodAbJ7Kdj/6pfWvloLLmjc6rXOfYRhuYYNmMjOrg10K49wCh62Xtq+hTwrsZd7P04Q9NqbYGKVt4iwtlF0k= X-Received: by 2002:a54:410c:0:b0:35a:6524:3c1b with SMTP id l12-20020a54410c000000b0035a65243c1bmr2328381oic.199.1668127790105; Thu, 10 Nov 2022 16:49:50 -0800 (PST) Original-Received: from 753933720722 named unknown by gmailapi.google.com with HTTPREST; Thu, 10 Nov 2022 16:49:49 -0800 In-Reply-To: X-Hashcash: 1:20:221111:genovese@cmu.edu::Tx02Zubi41P7sbxQ:0FvV X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:247563 Archived-At: tags 59165 + confirmed found 59165 27.1 thanks Gabriel writes: > Description: > The ibuffer directory filter is not buffer aware for buffers not > visiting files. This bug seems to be introduced by commit 3ef18c7a213, > which made the `default-directory` no longer run within > `with-current-buffer`. > > Steps: > 1. emacs -Q (29.0.50 master d04433b96215d7d3387573f19cc315de86f2341a) > 2. M-x dired /home/myuser/foo > 3. M-x compile ls -lha > 4. M-x ibuffer > 5. / F /home/myuser/foo > > Expected: filter is applied and two buffers are shown: `foo` and > `*compilation*`. I can reproduce this behavior, but I don't think I see how it could have been introduced by commit 3ef18c7a213: - I can reproduce it after reverting 3ef18c7a213 - I can reproduce it on Emacs 27.1 I therefore believe this behavior might have been there since the directory filter was introduced in commit 35aaa6b6aa. > Actual: only buffer `foo` is shown. > > Patch: > Below there is a proposed patch. I did a quick inspection and could not > find similar regressions in other ibuffer filters. I can verify that the patch below changes the behavior to work like you expect. I don't know if it is the right thing to do, but the docstring seems to suggest that it is: Limit current view to buffers with directory matching QUALIFIER. For a buffer associated with file =E2=80=99/a/b/c.d=E2=80=99, this matc= hes against =E2=80=99/a/b=E2=80=99. For a buffer not associated with a fil= e, this matches against the value of =E2=80=98default-directory=E2=80=99 in tha= t buffer. So your patch looks right to me, but I've Cced Christopher Genovese in case he has anything to add. > From 94e2f3f37b1d807af50c9014b57d24661fb3c5bd Mon Sep 17 00:00:00 2001 > From: Gabriel do Nascimento Ribeiro > Date: Thu, 10 Nov 2022 06:11:03 -0300 > Subject: [PATCH 1/1] Make ibuffer directory filter buffer aware > > * lisp/ibuf-ext.el (define-ibuffer-filter): Make ibuffer directory > filter buffer aware for buffer not visiting files. > --- > lisp/ibuf-ext.el | 10 ++++++---- > 1 file changed, 6 insertions(+), 4 deletions(-) > > diff --git a/lisp/ibuf-ext.el b/lisp/ibuf-ext.el > index 6b5cccec51..adffef4325 100644 > --- a/lisp/ibuf-ext.el > +++ b/lisp/ibuf-ext.el > @@ -1336,10 +1336,12 @@ directory > matches against the value of `default-directory' in that buffer." > ( :description "directory name" > :reader (read-from-minibuffer "Filter by directory name (regex): ")) > - (if-let ((it (with-current-buffer buf (ibuffer-buffer-file-name)))) > - (when-let ((dirname (file-name-directory it))) > - (string-match qualifier dirname)) > - (when default-directory (string-match qualifier default-directory)))= ) > + (with-current-buffer buf > + (if-let* ((filename (ibuffer-buffer-file-name)) > + (dirname (file-name-directory filename))) > + (string-match qualifier dirname) > + (when default-directory > + (string-match qualifier default-directory))))) > > ;;;###autoload (autoload 'ibuffer-filter-by-size-gt "ibuf-ext") > (define-ibuffer-filter size-gt > -- > 2.34.1