From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stephen Berman Newsgroups: gmane.emacs.bugs Subject: bug#64230: 30.0.50; Ibuffer reports 1 file too many with ibuffer-auto-mode enabled Date: Thu, 22 Jun 2023 19:35:28 +0200 Message-ID: <874jmzo0wv.fsf@gmx.net> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="552"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) To: 64230@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Jun 22 19:36:24 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 1qCOEJ-000AWE-UW for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 22 Jun 2023 19:36:24 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qCODz-0001i9-9h; Thu, 22 Jun 2023 13:36:03 -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 1qCODy-0001i1-NL for bug-gnu-emacs@gnu.org; Thu, 22 Jun 2023 13:36:02 -0400 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 1qCODy-0008A1-Da for bug-gnu-emacs@gnu.org; Thu, 22 Jun 2023 13:36:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qCODx-0006NO-TY for bug-gnu-emacs@gnu.org; Thu, 22 Jun 2023 13:36:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Stephen Berman Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 22 Jun 2023 17:36:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 64230 X-GNU-PR-Package: emacs X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.168745533624472 (code B ref -1); Thu, 22 Jun 2023 17:36:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 22 Jun 2023 17:35:36 +0000 Original-Received: from localhost ([127.0.0.1]:36662 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qCODX-0006Me-Pc for submit@debbugs.gnu.org; Thu, 22 Jun 2023 13:35:36 -0400 Original-Received: from lists.gnu.org ([209.51.188.17]:45334) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qCODW-0006MV-8i for submit@debbugs.gnu.org; Thu, 22 Jun 2023 13:35:34 -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 1qCODW-0001ZI-0G for bug-gnu-emacs@gnu.org; Thu, 22 Jun 2023 13:35:34 -0400 Original-Received: from mout.gmx.net ([212.227.15.19]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qCODU-000877-0a for bug-gnu-emacs@gnu.org; Thu, 22 Jun 2023 13:35:33 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=s31663417; t=1687455329; x=1688060129; i=stephen.berman@gmx.net; bh=+uOwpYMtYPTKVYE5zQi6tZKsH0lOCksyIxAmqT489vY=; h=X-UI-Sender-Class:From:To:Subject:Date; b=Qamfl+rqodAN4B3JQhW/ieF/4jfiNXAjzEtxqqnzgu6ZWkbRgJaJW0vzZxNJ+YjwwLBCtyQ 7IWJCYnQ6L8qnKlwBGzvu5HP7idS4LVGDJFgpxSGy7Vd5T8jH2kB/hy2HJ2hUs6LEI2YZiJEC V2GqSnSX+RcFHiBBnfO4FckqkNEtZJ0YQ+zfVmTqFAlvkAwWank6OkozqN5COfY0tZ9QG2/2k soSc9cVD4ZhOvOCtXqepUfBw+zWqzFjs+rpubRmVYe7Vyub36vjnnfUxRp4C22CNJW0ayxQeV DujMKVJKNso8MsvPVYwfkXnN7Sku/J//ZvlukPIn2BE0cMMbk5iQ== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Original-Received: from strobelfs ([89.246.37.91]) by mail.gmx.net (mrgmx004 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MXGrE-1qa9zr0C1G-00Ygai for ; Thu, 22 Jun 2023 19:35:29 +0200 X-Provags-ID: V03:K1:Mrg95syKNiw67YBGqyshMQKTFrpQIt1vgwBmJrQ6f2GlZ8Afkm4 WUSyY2q+4rdBwO8urFm1tz1j174CbpTKZGES2YRS4HvIAA3yZgKnnoUwW7WzXJuKrWNa7QB Zd0VHP7DJbD+iGFFoQB/oEivVJ2pZJtQ2PhUFw8gsE31h7LMtsRhymdCir2R71ogfjeQDJG 9dBAvkHhT6ypDvmeLvVww== UI-OutboundReport: notjunk:1;M01:P0:FePz6ShitO0=;Yr2BhjQKQCW75nkKsoagEqv34O8 bzp4PpDEgV/AUQEsKLNTV1iA8dbPV2UH8vKr1dA3bwPR2JzwvgrA1QRXcvU7Pm1CLkiGsn5kz nDD3w6n+7+JQ+1adj76dwEjFUb1/TrtUdrzB3g81E3dTqblBNT9xgS3kDei5ZzL9L3XD0h1Qf NqR9MkztGl7oARPW4d/5UT4G56Kw4oE61WpWAN60U76R+s3WOFEgFLYof2wqAv6as+yaB4A2Y Y/YxZ4oRTi2kgNAfOrGaTryHu4En5HBSxYCyaKegVRcRf6g0dIy0182uoKbkZUqkx04UL7432 EqOINj4WW+VtB7JBlBTicmEn468+Qe4/2EVxPOjUv4HTFylRKEiaDrts9z5Ffl1GLTU7UNTTY 2u5GMVaO6SycnqncPBytEk53jw9rIFFT/4asEam6YMmiWq7PkRFfi+uXW1dsAYQmCIVwNd6ul RC+xnN95P388k1oYp4tPnNHCu0aKUHZznoEVvLeS0UGTiPnrcHtGS3njbjEWSDT+2gXKiBDBO /ZXh9ADYyvvU+LbtcsDZbO8W5j1fT3bhEJY8/iluZcuAlo+g6kPv/0EV4dBlTA2T9bTggHq0x ytSK6ejjsg+04gL0l7pcc44FL+iMF6qO8wxTm9RFvmD20nzVjw5+QwMmr4Wx4dp5hfJG7pDxn 0h3MzBBmX4/OnH+gQdH/Ce5/lCso4CRJbWfHLyrc+pPZezl/AULnAX/VWjz4Udmm5offnHbw3 XTZE0OfkJEIVIB9L+pbaYyEyVig/GLZzyQHs+Qyp2EcAMVX7u+vdRF6S6kclz9gNGVNKx6fH Received-SPF: pass client-ip=212.227.15.19; envelope-from=stephen.berman@gmx.net; helo=mout.gmx.net X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action 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:263902 Archived-At: --=-=-= Content-Type: text/plain 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'). 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 --=-=-= Content-Type: text/x-patch Content-Disposition: attachment Content-Description: Ibuffer patch 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 --=-=-=--