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: Mon, 17 Jun 2024 17:43:48 +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="31714"; 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 Mon Jun 17 17:44:30 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 1sJEWy-0007zY-Jn for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 17 Jun 2024 17:44:28 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sJEWX-0000Wt-6g; Mon, 17 Jun 2024 11:44:01 -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 1sJEWW-0000Wj-2s for bug-gnu-emacs@gnu.org; Mon, 17 Jun 2024 11:44:00 -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 1sJEWV-0001yz-R6 for bug-gnu-emacs@gnu.org; Mon, 17 Jun 2024 11:43:59 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1sJEWX-0001B0-SJ for bug-gnu-emacs@gnu.org; Mon, 17 Jun 2024 11:44:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eshel Yaron Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 17 Jun 2024 15:44:01 +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.17186390364503 (code B ref 71466); Mon, 17 Jun 2024 15:44:01 +0000 Original-Received: (at 71466) by debbugs.gnu.org; 17 Jun 2024 15:43:56 +0000 Original-Received: from localhost ([127.0.0.1]:35149 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sJEWS-0001AY-2W for submit@debbugs.gnu.org; Mon, 17 Jun 2024 11:43:56 -0400 Original-Received: from mail.eshelyaron.com ([107.175.124.16]:47870 helo=eshelyaron.com) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sJEWP-0001AQ-QB for 71466@debbugs.gnu.org; Mon, 17 Jun 2024 11:43:54 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=eshelyaron.com; s=mail; t=1718639031; bh=fbZjEmualFczSVI1Uj4XzFWH1HSKEC9F2HLuMn6uBKo=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=RDrMPFnSNu+KhP/m7kW8o37VRWQYTL3/WPAvdExBeachllI66yB3/IXQs6uMFR7+s wYKuvBF0krnFLCyxexq3JqdVwO+hR0g+cJElRfm2INUUZavrJ+yqX7sfpvOSHHzHrd 187LahS3qGFxfVhJWkrWqQHvg1n4Q50I3+jOFF6EEC9pSgeqGthN9MD+Ws4tn3jhyd Bpg2RrQI4Mw/rwbLCNMEcCXUD2InCT1SXIxmEn0AggYmbLOl9FVyJ25ICy6gKu2iNp P0x8XzzX8udS2mwrJxrWG05Wl4lQvHbIpsz6Ntcp81CF2Z4e0Le52UJqpj5dGsdZfj s03VTGn+oMtAA== In-Reply-To: <30404984-e7ac-4f92-a194-06438dbf2d03@gutov.dev> (Dmitry Gutov's message of "Mon, 17 Jun 2024 15:27:45 +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:287401 Archived-At: 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: diff --git a/lisp/progmodes/xref.el b/lisp/progmodes/xref.el index fb6c9dad73b..9878806c0de 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,17 @@ 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