From: Juri Linkov <juri@linkov.net>
To: Eshel Yaron <me@eshelyaron.com>
Cc: Dmitry Gutov <dmitry@gutov.dev>, 71466@debbugs.gnu.org
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 [thread overview]
Message-ID: <86msnkyt7c.fsf@mail.linkov.net> (raw)
In-Reply-To: <86tthzwgsw.fsf@mail.linkov.net> (Juri Linkov's message of "Tue, 11 Jun 2024 20:05:51 +0300")
[-- Attachment #1: Type: text/plain, Size: 1226 bytes --]
> 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:
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: xref-revert-buffer-restore-point.patch --]
[-- Type: text/x-diff, Size: 2304 bytes --]
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.
next prev parent reply other threads:[~2024-06-17 6:35 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 [this message]
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
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
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=86msnkyt7c.fsf@mail.linkov.net \
--to=juri@linkov.net \
--cc=71466@debbugs.gnu.org \
--cc=dmitry@gutov.dev \
--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 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).