GNU bug report logs -
#49731
28.0.50; Filter xref results by filename
Previous Next
Reported by: Daniel MartÃn <mardani29 <at> yahoo.es>
Date: Sun, 25 Jul 2021 08:21:02 UTC
Severity: normal
Found in version 28.0.50
Fixed in version 30.0.50
Done: Juri Linkov <juri <at> linkov.net>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
> Also there is an additional helper function that is needed
> to keep hidden outlines and restore them after reverting the
> xref buffer with 'g' (xref-revert-buffer).
> This is an example of advice that does this.
> Later when xref will use revert-buffer-function,
> this advice could be replaced by a simple hook call:
>
> #+begin_src emacs-lisp
> (define-advice xref-revert-buffer (:around (ofun &rest args) keep-outlines)
> "Keep hidden outlines after xref revert."
> (let ((regexp (outline-hidden-headings-regexp))
> (value (apply ofun args)))
> (outline-hide-by-heading-regexp regexp)
> value))
> #+end_src
So here is the patch for xref:
diff --git a/lisp/progmodes/xref.el b/lisp/progmodes/xref.el
index 0025f1f9479..0a5c9243027 100644
--- a/lisp/progmodes/xref.el
+++ b/lisp/progmodes/xref.el
@@ -1277,13 +1277,18 @@ xref-revert-buffer
"Refresh the search results in the current buffer."
(interactive)
(let ((inhibit-read-only t)
- (buffer-undo-list 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)))
(save-excursion
(condition-case err
(let ((alist (xref--analyze (funcall xref--fetcher)))
(inhibit-modification-hooks t))
(erase-buffer)
- (xref--insert-xrefs alist))
+ (prog1 (xref--insert-xrefs alist)
+ (mapc #'funcall (delq nil restore-functions))))
(user-error
(erase-buffer)
(insert
This bug report was last modified 1 year and 49 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.