GNU bug report logs -
#71466
30.0.50; Buffer-menu-group-by non-nil resets point when Buffer List is reverted
Previous Next
Reported by: Eshel Yaron <me <at> eshelyaron.com>
Date: Mon, 10 Jun 2024 10:26:02 UTC
Severity: normal
Found in version 30.0.50
Fixed in version 30.1
Done: Eshel Yaron <me <at> eshelyaron.com>
Bug is archived. No further changes may be made.
Full log
Message #26 received at 71466 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
>> +(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))))))
>
> Perhaps it would make sense to save the current group as well, for
> additional precision.
Ok, so this is implemented here:
[xref-revert-buffer-restore-point_2.patch (text/x-diff, inline)]
diff --git a/lisp/progmodes/xref.el b/lisp/progmodes/xref.el
index fb6c9dad73b..987571b92c5 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)))
@@ -1309,6 +1311,24 @@ xref--auto-jump-first
((eq value 'move)
(forward-line 1))))
+(defun xref-revert-buffer-restore-point ()
+ (let* ((item
+ (when (xref--item-at-point)
+ (buffer-substring-no-properties (pos-bol) (pos-eol))))
+ (group
+ (save-excursion
+ (when (or (get-text-property (point) 'xref-group)
+ (and item (xref--search-property 'xref-group t)
+ (get-text-property (point) 'xref-group)))
+ (buffer-substring-no-properties (pos-bol) (pos-eol))))))
+ (when (or item group)
+ (lambda ()
+ (goto-char (point-min))
+ (when (and group (search-forward (concat "\n" group "\n") nil t))
+ (goto-char (pos-bol 0)))
+ (when (and item (search-forward (concat "\n" item "\n") nil t))
+ (goto-char (pos-bol 0)))))))
+
(defun xref-show-definitions-buffer (fetcher alist)
"Show the definitions list in a regular window.
This bug report was last modified 329 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.