emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/xref-union 316695bd4a 2/7: Rework implementation of 'xr


From: ELPA Syncer
Subject: [elpa] externals/xref-union 316695bd4a 2/7: Rework implementation of 'xref-union-mode'
Date: Sat, 9 Dec 2023 15:58:58 -0500 (EST)

branch: externals/xref-union
commit 316695bd4a8013618a7ad8e180b2cf5b5d513823
Author: Philip Kaludercic <philipk@posteo.net>
Commit: Philip Kaludercic <philipk@posteo.net>

    Rework implementation of 'xref-union-mode'
---
 xref-union.el | 39 ++++++++++++++++++++++-----------------
 1 file changed, 22 insertions(+), 17 deletions(-)

diff --git a/xref-union.el b/xref-union.el
index 986274a5de..9e9c227ac2 100644
--- a/xref-union.el
+++ b/xref-union.el
@@ -100,27 +100,32 @@ PATTERN is specified in `xref-backend-apropos'."
 
 ;;;; Minor mode
 
-(defvar-local xref-union--current nil
-  "Reference to the current union backend.")
+(defun xref-union--backend ()
+  "Generate a Xref backend unifying others."
+  (let (backends)
+    (run-hook-wrapped
+     'xref-backend-functions
+     (lambda (b)
+       (unless (or (funcall xref-union-excluded-backends b)
+                   (eq b #'xref-union--backend))
+         (let ((hook (gensym)))
+           (add-hook hook b)
+           (let ((b (run-hook-with-args-until-success hook)))
+             (when b (push b backends)))))
+       nil))
+    (and backends (cons 'union (delete-dups backends)))))
 
 (define-minor-mode xref-union-mode
   "Enable a Xref backend that combines all others."
   :global nil
-  (when xref-union--current
-    (remove-hook 'xref-backend-functions xref-union--current))
-  (when xref-union-mode
-    (let (backends)
-      ;; Collect all (local and global) functions in
-      ;; `xref-backend-functions' into a local list.
-      (run-hook-wrapped
-       'xref-backend-functions
-       (lambda (b)
-         (setq b (funcall b))
-         (when (and b (funcall xref-union-excluded-backends b))
-           (push b backends))
-         nil))
-      (setq xref-union--current (cons 'union backends))
-      (add-hook 'xref-backend-functions xref-union--current))))
+  (if xref-union-mode
+      (add-hook 'xref-backend-functions
+                #'xref-union--backend
+                xref-union-hook-depth
+                t)
+    (remove-hook 'xref-backend-functions
+                 #'xref-union--backend
+                 t)))
 
 ;; LocalWords: backend backends
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]