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#64230: 30.0.50; Ibuffer reports 1 file too many with ibuffer-auto-mode enabled Date: Sun, 10 Sep 2023 07:11:07 -0700 Message-ID: References: <874jmzo0wv.fsf@gmx.net> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="40842"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 64230@debbugs.gnu.org To: Stephen Berman Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Sep 10 16:12:14 2023 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 1qfLAb-000ALZ-Pa for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 10 Sep 2023 16:12:13 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qfLAS-0001x2-Ar; Sun, 10 Sep 2023 10:12:04 -0400 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 1qfLAN-0001vW-5Y for bug-gnu-emacs@gnu.org; Sun, 10 Sep 2023 10:11:59 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qfLAM-00006K-Bc for bug-gnu-emacs@gnu.org; Sun, 10 Sep 2023 10:11:58 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qfLAP-0008Oo-M5 for bug-gnu-emacs@gnu.org; Sun, 10 Sep 2023 10:12:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Kangas Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 10 Sep 2023 14:12:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 64230 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 64230-submit@debbugs.gnu.org id=B64230.169435508032225 (code B ref 64230); Sun, 10 Sep 2023 14:12:01 +0000 Original-Received: (at 64230) by debbugs.gnu.org; 10 Sep 2023 14:11:20 +0000 Original-Received: from localhost ([127.0.0.1]:51038 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qfL9k-0008Nh-9f for submit@debbugs.gnu.org; Sun, 10 Sep 2023 10:11:20 -0400 Original-Received: from mail-lf1-x12f.google.com ([2a00:1450:4864:20::12f]:61660) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qfL9h-0008N8-Im for 64230@debbugs.gnu.org; Sun, 10 Sep 2023 10:11:18 -0400 Original-Received: by mail-lf1-x12f.google.com with SMTP id 2adb3069b0e04-502a25ab777so2884915e87.2 for <64230@debbugs.gnu.org>; Sun, 10 Sep 2023 07:11:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694355068; x=1694959868; darn=debbugs.gnu.org; h=cc:to:subject:message-id:date:mime-version:references:in-reply-to :from:from:to:cc:subject:date:message-id:reply-to; bh=uTw/r12BJ6U4Sub+2c16y0Kv9Y5Zvx5Ysn416HO7Z7o=; b=Bd7rFzPes+LigykF6RMcFCjKkh1xmvPwxrYzoidOmeOlo9reAZoL6Px2K9mVo7vlpK RtxFRhvGsEw+J6gax6rh7bnYdLCOqkW78ggyqBnEWtgrGCb+2j9EnoSUNEQzblx2vETZ 5HbAdgGXf/J5Z0ROygDgLNXq0U/WM0c1wqgHLgG4uiE2NxEry3qT2tNn1d0ug2JoaCB3 PJoMKIq0o/vS38QdUiv7A17JJ9fHtTyfw1RuAZ+HcjhVPqIimb0Uf23jdT4KK7RhNGoL JmSNeo4DQZ/w8VkdN/HxPhXSzDTK6d/244WisfMhwyWmI0shwnh80txHBUHx3nCCPvUY gutQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694355068; x=1694959868; h=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=uTw/r12BJ6U4Sub+2c16y0Kv9Y5Zvx5Ysn416HO7Z7o=; b=Ebh1sPKp8QcZhxHisxwxYL4lnHVbbdFlyjNTf5cvuE+hM9Gz0aaKn8KqL9l8hK2i17 vuFjN6jEVIJXnotIOaRJnt8ZGVvxgsA1b4zDCRRb/HWSgU/b/nFE5xEojaaN68qzD3xR cL+ufwcfdXLzpFuTin/yBSPVmjUMFJCPVG8cd1xl3LDlhEgXBDq9s9LiTXLaEX1DO8BI 1dH12SYGIN8KQxBK7wLejsgdlzkl2owbswChnsYvUFRXAQ+OA1r/rIfViKajvd8sqLdD lLq9saZmpljnIOkDhoZkvBXNcoLEVKAtNih5hkfNfEcxvnMZjOXtl5Mv22eJ3almYALi ua7Q== X-Gm-Message-State: AOJu0Ywe/9KCtL39z2UmUmm4gHfYHXpcKJ6AScxQRzJi/TedcLj/D4to tsQc86nlLcRRpSJT6K/0beEZWEN8rMZgvtbOtnim+wQW X-Google-Smtp-Source: AGHT+IGY2Gek6eUPx4O3k9b4sLrTPx/0RmHJktf/kH0MVazmxCWaziRPgMoEeqyCMaIOyE1Rf+g3gCK/IGXHoR3JFi8= X-Received: by 2002:a19:435d:0:b0:500:cb2b:8678 with SMTP id m29-20020a19435d000000b00500cb2b8678mr5457444lfj.40.1694355067659; Sun, 10 Sep 2023 07:11:07 -0700 (PDT) Original-Received: from 753933720722 named unknown by gmailapi.google.com with HTTPREST; Sun, 10 Sep 2023 07:11:07 -0700 In-Reply-To: <874jmzo0wv.fsf@gmx.net> (Stephen Berman's message of "Thu, 22 Jun 2023 19:35:28 +0200") 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:269965 Archived-At: Stephen Berman writes: > 0. emacs -Q > 1. Type `M-x' and then TAB to pop up the *Completions* buffer, then type > `C-g'. > 2. Type `M-x ibuffer'. > 3. Type `d' on the lines for the buffers *scratch* and *Completions* to > flag them for deletion. > 4. Type `C-c C-a' to enable ibuffer-auto-mode. > 5. Type `x' and at the prompt "Really kill 2 buffers? (y or n)" type `y'. > => The *Ibuffer* lines for *scratch* and *Completions* are deleted and > the echo area displays this message: "Operation finished; killed 3 > buffers". > > If you change this recipe by omitting step 4, then after the buffer > lines are deleted the message displayed is "Operation finished; killed 2 > buffers". > > The unexpected message with ibuffer-auto-mode enabled is displayed in > Emacs 27-30 but not in Emacs 26. With Emacs 27+, on typing `x' at step > 5, the buffer *Ibuffer confirmation* pops up and a line for this buffer > immediately appears in the *Ibuffer* display, and this is counted by the > function `ibuffer-map-lines', and on typing `y' not only are the two > flagged buffers deleted, but also *Ibuffer confirmation*, hence "killed > 3 buffers". In contrast, in Emacs 26, the popped up buffer *Ibuffer > confirmation* does not get added to the *Ibuffer* display and thus is > not counted by `ibuffer-map-lines'. > > AFAICT, this difference is not due to any ibuffer code changes after > Emacs 26; rather, there appears to be a timing difference with respect > to when Emacs updates the *Ibuffer* display: when I instrument > `ibuffer-update' for Edebug and then type `x' (step 5 above), what > happens in Emacs 26 is that I can confirm with `y', then the flagged > lines are deleted, and only then does Edebug stop the execution so I can > step into `ibuffer-update'; while in Emacs 27+, as soon as I type `x', > Edebug stops execution, i.e., before the flagged lines are deleted. > > `ibuffer-update' is called in `ibuffer-auto-update-changed', which is > added to post-command-hook in `ibuffer-auto-mode'. So it seems that in > Emacs 26 post-command-hook runs or takes effect later than in Emacs 27+. > Whether this is really the case, and if so, what change it is due to, I > haven't determined, and I don't know how restore the Emacs 26 execution > order (or if that's even desirable). But even if the difference is due > to something else, the message displayed in Emacs 27+ after the deletion > of the *Ibuffer* lines is at least misleading, since it clearly is meant > to refer only to the flagged lines, as in Emacs 26. > > In lieu of a real fix, since it is, AFAICS, only the transient buffer > *Ibuffer confirmation* that results in the problematic message, a > workaround is simply to decrement the line count by one when > ibuffer-auto-mode is enabled, as in the the attached patch (which also > takes the opportunity to wrap an overlong line in `ibuffer-map-lines'). Your analysis and patch makes sense to me. Please install, but add a brief comment explaining why we do that decrement there. Thanks. > In GNU Emacs 30.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version > 3.24.37, cairo version 1.17.6) of 2023-06-22 built on strobelfs > Repository revision: a23a09a82fc59402f1f7c23a46c65fc7001eecdf > Repository branch: master > Windowing system distributor 'The X.Org Foundation', version 11.0.12101008 > System Description: Linux From Scratch r11.3-65 > > Configured using: > 'configure -C --with-xwidgets 'CFLAGS=-Og -g3' > PKG_CONFIG_PATH=/opt/qt5/lib/pkgconfig' > > Configured features: > ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GPM GSETTINGS HARFBUZZ JPEG > JSON LCMS2 LIBSYSTEMD LIBXML2 MODULES NOTIFY INOTIFY PDUMPER PNG RSVG > SECCOMP SOUND SQLITE3 THREADS TIFF TOOLKIT_SCROLL_BARS TREE_SITTER WEBP > X11 XDBE XIM XINPUT2 XPM XWIDGETS GTK3 ZLIB > > diff --git a/lisp/ibuffer.el b/lisp/ibuffer.el > index a26bb1811ec..50c3aeb7f62 100644 > --- a/lisp/ibuffer.el > +++ b/lisp/ibuffer.el > @@ -1872,7 +1872,8 @@ ibuffer-map-lines > (let ((result > (if (buffer-live-p (ibuffer-current-buffer)) > (when (or (null group) > - (when-let ((it (get-text-property (point) 'ibuffer-filter-group))) > + (when-let ((it (get-text-property > + (point) 'ibuffer-filter-group))) > (equal group it))) > (save-excursion > (funcall function > @@ -1897,7 +1898,9 @@ ibuffer-map-lines > (t > (cl-incf ibuffer-map-lines-count) > (forward-line 1))))) > - ibuffer-map-lines-count) > + (if (and (featurep 'ibuf-ext) ibuffer-auto-mode) > + (1- ibuffer-map-lines-count) > + ibuffer-map-lines-count)) > (progn > (setq buffer-read-only t) > (unless nomodify