Subject: bug#46992: xref-after-update-hook

From: Juri Linkov <[email-masked]>
Date: Sun, 07 Mar 2021 20:50:25 +0200

Version: 28.0.50
Severity: wishlist
Tags: patch

As suggested in https://lists.gnu.org/archive/html/emacs-devel/2021-03/msg00161.html
here is a patch that adds such hook:

diff --git a/lisp/progmodes/xref.el b/lisp/progmodes/xref.el
index 18fdd963fb..ba4e48faf8 100644
--- a/lisp/progmodes/xref.el
+++ b/lisp/progmodes/xref.el
@@ -415,6 +415,10 @@ xref-after-return-hook
   "Functions called after returning to a pre-jump location."
   :type 'hook)
 
+(defcustom xref-after-update-hook nil
+  "Functions called after the xref buffer is updated."
+  :type 'hook)
+
 (defvar xref--marker-ring (make-ring xref-marker-ring-length)
   "Ring of markers to implement the marker stack.")
 
@@ -919,7 +933,8 @@ xref--insert-xrefs
                                        "RET or mouse-1: follow reference"))
                          prefix new-summary)
                         (setq prev-line-key line-key)))
-                    (insert "\n"))))
+                    (insert "\n")))
+  (run-hooks 'xref-after-update-hook))
 
 (defun xref--analyze (xrefs)
   "Find common filenames in XREFS.