unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Stefan Kangas <stefankangas@gmail.com>
To: Stephen Berman <stephen.berman@gmx.net>
Cc: 64230@debbugs.gnu.org
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	[thread overview]
Message-ID: <CADwFkmnLD4MQ_NFqS5JyU+Z6PkSUdXw6V73kZZ1aDyxhBFk9yw@mail.gmail.com> (raw)
In-Reply-To: <874jmzo0wv.fsf@gmx.net> (Stephen Berman's message of "Thu, 22 Jun 2023 19:35:28 +0200")

Stephen Berman <stephen.berman@gmx.net> 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





  reply	other threads:[~2023-09-10 14:11 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-22 17:35 bug#64230: 30.0.50; Ibuffer reports 1 file too many with ibuffer-auto-mode enabled Stephen Berman
2023-09-10 14:11 ` Stefan Kangas [this message]
2023-09-11 14:18   ` Stephen Berman
2023-09-11 14:44     ` Stefan Kangas
2023-09-13 18:51     ` Stephen Berman
2023-09-13 20:58       ` Stefan Kangas
2023-09-13 21:49         ` Stephen Berman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CADwFkmnLD4MQ_NFqS5JyU+Z6PkSUdXw6V73kZZ1aDyxhBFk9yw@mail.gmail.com \
    --to=stefankangas@gmail.com \
    --cc=64230@debbugs.gnu.org \
    --cc=stephen.berman@gmx.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).