From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eshel Yaron via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs 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 Message-ID: References: <86tthzwgsw.fsf@mail.linkov.net> <86msnkyt7c.fsf@mail.linkov.net> <30404984-e7ac-4f92-a194-06438dbf2d03@gutov.dev> Reply-To: Eshel Yaron Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="14974"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: 71466@debbugs.gnu.org, Juri Linkov To: Dmitry Gutov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Jun 18 09:01:25 2024 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 1sJSqK-0003l8-DS for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 18 Jun 2024 09:01:24 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sJSq0-0002cY-MD; Tue, 18 Jun 2024 03:01:06 -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 1sJSpx-0002bc-2Q for bug-gnu-emacs@gnu.org; Tue, 18 Jun 2024 03:01:01 -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 1sJSpw-0003Yw-7E for bug-gnu-emacs@gnu.org; Tue, 18 Jun 2024 03:01:00 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1sJSpy-0006qp-FR for bug-gnu-emacs@gnu.org; Tue, 18 Jun 2024 03:01:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eshel Yaron Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 18 Jun 2024 07:01:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 71466 X-GNU-PR-Package: emacs Original-Received: via spool by 71466-submit@debbugs.gnu.org id=B71466.171869404726304 (code B ref 71466); Tue, 18 Jun 2024 07:01:02 +0000 Original-Received: (at 71466) by debbugs.gnu.org; 18 Jun 2024 07:00:47 +0000 Original-Received: from localhost ([127.0.0.1]:41049 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sJSpi-0006qC-JT for submit@debbugs.gnu.org; Tue, 18 Jun 2024 03:00:47 -0400 Original-Received: from mail.eshelyaron.com ([107.175.124.16]:50822 helo=eshelyaron.com) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sJSpg-0006q4-Pc for 71466@debbugs.gnu.org; Tue, 18 Jun 2024 03:00:45 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=eshelyaron.com; s=mail; t=1718694041; bh=qRhf00TFAhE6FoK4uIp1LUFjzZ/Bc8ZdupBcCLogjjc=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=AZo4ooViOqverMl2jc29cLa/HRdL5TvMUEzkjM0e0wxAmlg/KB6VcVAzabRjN8PfW VmtPSpjwx6I/M+Uoomu1PWvUfcfLfcD2sg3AN6BxPtL8h+lrfI37oCg0smLcAkm4Oo UiLiGNFqaV0AayEVMiUNGBsMuHnXkdJ1UFc84Sm5ziU4ZfPG0pBT2jEDODGNIU0KuP 8PLfOOovkFXi6i4OMScq4vTdcF22/C1LMuBuV6g9GtTkRpslrmt1dC3+qhj5H10ioe C500yhGaP6w8Pw9eSGYQm/5WeXIvpZx8BM6w3TIKIrZliLZWUfSSSU2RYEJmZs0h0p g9lFdzYAEIUiA== In-Reply-To: (Dmitry Gutov's message of "Tue, 18 Jun 2024 01:24:26 +0300") 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:287429 Archived-At: Dmitry Gutov writes: > On 17/06/2024 18:43, Eshel Yaron wrote: >> Dmitry Gutov 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))