[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#71466: 30.0.50; Buffer-menu-group-by non-nil resets point when Buffe
From: |
Juri Linkov |
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 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/30.0.50 (x86_64-pc-linux-gnu) |
> 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:
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.
- bug#71466: 30.0.50; Buffer-menu-group-by non-nil resets point when Buffer List is reverted, Eshel Yaron, 2024/06/10
- bug#71466: 30.0.50; Buffer-menu-group-by non-nil resets point when Buffer List is reverted, Juri Linkov, 2024/06/11
- bug#71466: 30.0.50; Buffer-menu-group-by non-nil resets point when Buffer List is reverted,
Juri Linkov <=
- bug#71466: 30.0.50; Buffer-menu-group-by non-nil resets point when Buffer List is reverted, Eshel Yaron, 2024/06/17
- bug#71466: 30.0.50; Buffer-menu-group-by non-nil resets point when Buffer List is reverted, Dmitry Gutov, 2024/06/17
- bug#71466: 30.0.50; Buffer-menu-group-by non-nil resets point when Buffer List is reverted, Eshel Yaron, 2024/06/17
- bug#71466: 30.0.50; Buffer-menu-group-by non-nil resets point when Buffer List is reverted, Dmitry Gutov, 2024/06/17
- bug#71466: 30.0.50; Buffer-menu-group-by non-nil resets point when Buffer List is reverted, Eshel Yaron, 2024/06/18
- bug#71466: 30.0.50; Buffer-menu-group-by non-nil resets point when Buffer List is reverted, Eli Zaretskii, 2024/06/18
- bug#71466: 30.0.50; Buffer-menu-group-by non-nil resets point when Buffer List is reverted, Eshel Yaron, 2024/06/18
- bug#71466: 30.0.50; Buffer-menu-group-by non-nil resets point when Buffer List is reverted, Eli Zaretskii, 2024/06/18
- bug#71466: 30.0.50; Buffer-menu-group-by non-nil resets point when Buffer List is reverted, Eshel Yaron, 2024/06/18
- bug#71466: 30.0.50; Buffer-menu-group-by non-nil resets point when Buffer List is reverted, Dmitry Gutov, 2024/06/18