From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Juri Linkov 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 09:35:11 +0300 Organization: LINKOV.NET Message-ID: <86msnkyt7c.fsf@mail.linkov.net> References: <86tthzwgsw.fsf@mail.linkov.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="40431"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/30.0.50 (x86_64-pc-linux-gnu) Cc: Dmitry Gutov , 71466@debbugs.gnu.org To: Eshel Yaron Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Jun 17 08:37:07 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 1sJ5zH-000AOV-Ei for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 17 Jun 2024 08:37:07 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sJ5zB-0004Tz-V9; Mon, 17 Jun 2024 02:37: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 1sJ5zA-0004Su-LB for bug-gnu-emacs@gnu.org; Mon, 17 Jun 2024 02:37: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 1sJ5zA-00059J-Dn for bug-gnu-emacs@gnu.org; Mon, 17 Jun 2024 02:37:00 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1sJ5zC-0008BQ-66 for bug-gnu-emacs@gnu.org; Mon, 17 Jun 2024 02:37:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 17 Jun 2024 06:37: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.171860618331400 (code B ref 71466); Mon, 17 Jun 2024 06:37:02 +0000 Original-Received: (at 71466) by debbugs.gnu.org; 17 Jun 2024 06:36:23 +0000 Original-Received: from localhost ([127.0.0.1]:59360 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sJ5yZ-0008AO-18 for submit@debbugs.gnu.org; Mon, 17 Jun 2024 02:36:23 -0400 Original-Received: from relay9-d.mail.gandi.net ([217.70.183.199]:50355) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sJ5yW-0008A8-MG for 71466@debbugs.gnu.org; Mon, 17 Jun 2024 02:36:21 -0400 Original-Received: by mail.gandi.net (Postfix) with ESMTPSA id 873EAFF805; Mon, 17 Jun 2024 06:35:51 +0000 (UTC) In-Reply-To: <86tthzwgsw.fsf@mail.linkov.net> (Juri Linkov's message of "Tue, 11 Jun 2024 20:05:51 +0300") X-GND-Sasl: juri@linkov.net 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:287362 Archived-At: --=-=-= Content-Type: text/plain > When point is on an entry, then 'tabulated-list-print' > moves point to the entry with the same ID. > > However, what ID to prefer for outline heading lines > is not quite clear. Possible variants: > > 1. The simplest way would be to remember the position of point > or the line number. But this is not quite reliable > when new entries are inserted before. > > 2. Remembering the outline heading line as a string and searching for it > afterwards would be ambiguous when there are more headings with the > same string. For example, when at the top level there are project names, > and at the second level mode names repeated for every project. > > 3. To remember a complete path like outline-hidden-headings-paths does, > e.g. '("Project1 name" "Mode2 name"). The third variant is implemented now. > 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: --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=xref-revert-buffer-restore-point.patch diff --git a/lisp/progmodes/xref.el b/lisp/progmodes/xref.el index fb6c9dad73b..1ff02d3712a 100644 --- a/lisp/progmodes/xref.el +++ b/lisp/progmodes/xref.el @@ -1017,7 +1017,9 @@ xref--xref-buffer-mode (lambda (&optional bound move backward looking-at) (outline-search-text-property 'xref-group nil bound move backward looking-at))) - (setq-local outline-level (lambda () 1))) + (setq-local outline-level (lambda () 1)) + (add-hook 'revert-buffer-restore-functions + #'xref-revert-buffer-restore-point nil t)) (defvar xref--transient-buffer-mode-map (let ((map (make-sparse-keymap))) @@ -1282,19 +1284,19 @@ xref-revert-buffer (when (boundp 'revert-buffer-restore-functions) (run-hook-wrapped 'revert-buffer-restore-functions (lambda (f) (push (funcall f) restore-functions) nil))) - (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)))) - (user-error - (erase-buffer) - (insert - (propertize - (error-message-string err) - 'face 'error))))))) + (condition-case err + (let ((alist (xref--analyze (funcall xref--fetcher))) + (inhibit-modification-hooks t)) + (erase-buffer) + (prog1 (xref--insert-xrefs alist) + (goto-char (point-min)) + (mapc #'funcall (delq nil restore-functions)))) + (user-error + (erase-buffer) + (insert + (propertize + (error-message-string err) + 'face 'error)))))) (defun xref--auto-jump-first (buf value) (when value @@ -1309,6 +1311,13 @@ xref--auto-jump-first ((eq value 'move) (forward-line 1)))) +(defun xref-revert-buffer-restore-point () + (let ((current-line (buffer-substring-no-properties (pos-bol) (pos-eol)))) + (lambda () + (goto-char (point-min)) + (when (search-forward current-line) + (goto-char (pos-bol)))))) + (defun xref-show-definitions-buffer (fetcher alist) "Show the definitions list in a regular window. --=-=-=--