all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Eshel Yaron via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: Dmitry Gutov <dmitry@gutov.dev>
Cc: 71466@debbugs.gnu.org, Juri Linkov <juri@linkov.net>
Subject: bug#71466: 30.0.50; Buffer-menu-group-by non-nil resets point when Buffer List is reverted
Date: Tue, 18 Jun 2024 09:00:38 +0200	[thread overview]
Message-ID: <m1r0cupwfd.fsf@dazzs-mbp.home> (raw)
In-Reply-To: <ef2c6f7a-b939-4b78-8279-d4b0accc0e4b@gutov.dev> (Dmitry Gutov's message of "Tue, 18 Jun 2024 01:24:26 +0300")

Dmitry Gutov <dmitry@gutov.dev> writes:

> On 17/06/2024 18:43, Eshel Yaron wrote:
>> Dmitry Gutov <dmitry@gutov.dev> writes:
>> 
>>> On 17/06/2024 10:40, Eshel Yaron wrote:
>>>>>> But this will not handle modes that don't use tabulated-list.
>>>>>> For example, reverting an xref buffer with outlines now restores
>>>>>> visibility of outlines, but doesn't restore point.  OTOH, maybe it's
>>>>>> not responsibility of outline-minor-mode to restore point when it's
>>>>>> not on a heading line.
>>>>> For xref I propose a separate patch that keeps point on the same line
>>>>> after reverting the xref buffer:
>>>> LGTM, but FWIW the situation with xref-revert-buffer is not ideal IMO:
>>>> it might be cleaner to leave 'g' bound to the usual revert-buffer and
>>>> set revert-buffer-function to (a slightly modified) xref-revert-buffer.
>>>> That way xref-revert-buffer wouldn't need to duplicate generic parts of
>>>> revert-buffer, such as running revert-buffer-restore-functions.  WDYT?
>>>
>>> I'm okay with that.
>> Here's a concrete proposal:
>
> Thanks, works for me, with some caveats.
>
>> diff --git a/lisp/progmodes/xref.el b/lisp/progmodes/xref.el
>> [...]
>
> It seems like the interactive use of 'xref-revert-buffer' would suffer
> with this change (it wouldn't call the restore functions). And it
> might be used where people rebind it to a different key in their
> configs.

Right, good point.

> Perhaps instead xref-revert-buffer should become an obsolete alias to
> 'revert-buffer'. And the current definition would be renamed to
> xref--revert-buffer (which we'll set revert-buffer-function to).

SGTM, here's an updated diff, also with a NEWS entry and doc updates:

diff --git a/doc/emacs/maintaining.texi b/doc/emacs/maintaining.texi
index 3a9bef9884a..3e5f3831260 100644
--- a/doc/emacs/maintaining.texi
+++ b/doc/emacs/maintaining.texi
@@ -2467,9 +2467,8 @@ Xref Commands
 all the relevant files.  @xref{Identifier Search}.
 
 @item g
-@findex xref-revert-buffer
-Refresh the contents of the @file{*xref*} buffer
-(@code{xref-revert-buffer}).
+Refresh the contents of the @file{*xref*} buffer (@code{revert-buffer}).
+@xref{Reverting}.
 
 @item M-,
 @findex xref-quit-and-pop-marker-stack
diff --git a/etc/NEWS b/etc/NEWS
index b2fdbc4a88f..b5dcd87e005 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -1895,6 +1895,13 @@ options of GNU 'ls'.
 If non-nil, moving point forward or backward between widgets by typing
 'TAB' or 'S-TAB' skips over inactive widgets.  The default value is nil.
 
+** Xref
+
+*** 'xref-revert-buffer' is obsolete, prefer 'revert-buffer' instead.
+The former is now an alias of the latter.  The Xref results buffer sets
+up 'revert-buffer-function' such that 'revert-buffer' behaves like
+'xref-revert-buffer' did in previous Emacs versions.
+
 ** Ruby mode
 
 *** New user option 'ruby-rubocop-use-bundler'.
diff --git a/lisp/progmodes/xref.el b/lisp/progmodes/xref.el
index fb6c9dad73b..37f5220cec3 100644
--- a/lisp/progmodes/xref.el
+++ b/lisp/progmodes/xref.el
@@ -993,7 +993,6 @@ xref--xref-buffer-mode-map
     ;; suggested by Johan Claesson "to further reduce finger movement":
     (define-key map (kbd ".") #'xref-next-line)
     (define-key map (kbd ",") #'xref-prev-line)
-    (define-key map (kbd "g") #'xref-revert-buffer)
     (define-key map (kbd "M-,") #'xref-quit-and-pop-marker-stack)
     map))
 
@@ -1011,6 +1010,7 @@ xref--xref-buffer-mode
         #'xref--imenu-extract-index-name)
   (setq-local add-log-current-defun-function
               #'xref--add-log-current-defun)
+  (setq-local revert-buffer-function #'xref--revert-buffer)
   (setq-local outline-minor-mode-cycle t)
   (setq-local outline-minor-mode-use-buttons 'insert)
   (setq-local outline-search-function
@@ -1273,22 +1273,16 @@ xref--show-common-initialize
           xref--original-window-intent (assoc-default 'display-action alist))
     (setq xref--fetcher fetcher)))
 
-(defun xref-revert-buffer ()
+(defun xref--revert-buffer (&rest _)     ; Ignore `revert-buffer' args.
   "Refresh the search results in the current buffer."
-  (interactive)
   (let ((inhibit-read-only t)
-        (buffer-undo-list t)
-        restore-functions)
-    (when (boundp 'revert-buffer-restore-functions)
-      (run-hook-wrapped 'revert-buffer-restore-functions
-                        (lambda (f) (push (funcall f) restore-functions) nil)))
+        (buffer-undo-list t))
     (save-excursion
       (condition-case err
           (let ((alist (xref--analyze (funcall xref--fetcher)))
                 (inhibit-modification-hooks t))
             (erase-buffer)
-            (prog1 (xref--insert-xrefs alist)
-              (mapc #'funcall (delq nil restore-functions))))
+            (xref--insert-xrefs alist))
         (user-error
          (erase-buffer)
          (insert
@@ -1296,6 +1290,8 @@ xref-revert-buffer
            (error-message-string err)
            'face 'error)))))))
 
+(define-obsolete-function-alias 'xref-revert-buffer #'revert-buffer "30.1")
+
 (defun xref--auto-jump-first (buf value)
   (when value
     (select-window (get-buffer-window buf))





  reply	other threads:[~2024-06-18  7:00 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-10  8:49 bug#71466: 30.0.50; Buffer-menu-group-by non-nil resets point when Buffer List is reverted Eshel Yaron via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-06-11 17:05 ` Juri Linkov
2024-06-17  6:35   ` Juri Linkov
2024-06-17  7:40     ` Eshel Yaron via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-06-17 12:27       ` Dmitry Gutov
2024-06-17 15:43         ` Eshel Yaron via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-06-17 22:24           ` Dmitry Gutov
2024-06-18  7:00             ` Eshel Yaron via Bug reports for GNU Emacs, the Swiss army knife of text editors [this message]
2024-06-18 12:58               ` Eli Zaretskii
2024-06-18 14:01                 ` Eshel Yaron via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-06-18 14:46                   ` Eli Zaretskii
2024-06-18 16:55                     ` Eshel Yaron via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-06-18 17:05                     ` Dmitry Gutov
2024-06-18 17:36                       ` Eli Zaretskii
2024-06-18 17:47                         ` Dmitry Gutov
2024-06-20 16:38                           ` Juri Linkov
2024-06-20 17:35                             ` Dmitry Gutov
2024-06-24  6:27                               ` Juri Linkov
2024-06-24 22:42                                 ` Dmitry Gutov
2024-06-25  6:54                                   ` Juri Linkov
2024-06-25 12:54                                   ` Eli Zaretskii
2024-06-25 23:14                                     ` Dmitry Gutov
2024-06-26 11:25                                       ` Eli Zaretskii
2024-06-26 16:56                                         ` Eshel Yaron via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-06-26 18:33                                           ` Eli Zaretskii
2024-06-26 21:05                                             ` Eshel Yaron via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-06-27  6:39                                               ` Juri Linkov
2024-06-27  7:19                                                 ` Eli Zaretskii
2024-06-27  0:11                                           ` Dmitry Gutov
2024-06-17 12:32     ` Dmitry Gutov
2024-06-17 16:31       ` Juri Linkov
2024-06-17 22:16         ` Dmitry Gutov
2024-06-27  6:43           ` Juri Linkov

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

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

  git send-email \
    --in-reply-to=m1r0cupwfd.fsf@dazzs-mbp.home \
    --to=bug-gnu-emacs@gnu.org \
    --cc=71466@debbugs.gnu.org \
    --cc=dmitry@gutov.dev \
    --cc=juri@linkov.net \
    --cc=me@eshelyaron.com \
    /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 external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.