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

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

[elpa] externals/xref-union 0d585d722e 2/5: Fix construction of union ba


From: ELPA Syncer
Subject: [elpa] externals/xref-union 0d585d722e 2/5: Fix construction of union backends
Date: Sun, 26 Mar 2023 08:01:54 -0400 (EDT)

branch: externals/xref-union
commit 0d585d722e7b5ea57f379979337604bda69191e3
Author: Philip Kaludercic <philip.kaludercic@fau.de>
Commit: Philip Kaludercic <philip.kaludercic@fau.de>

    Fix construction of union backends
    
    We cannot just directly use xref-backend-functions, since a hook is
    not just a list of functions that are to executed.  Quoting from
    (elisp) Running Hooks,
    
         If the hook variable is buffer-local, the buffer-local variable
         will be used instead of the global variable.  However, if the
         buffer-local variable contains the element ‘t’, the global hook
         variable will be run as well.
    
    Hence we need to collect all the functions that we want to add to the
    union backend, in this case by using `run-hook-wrapped' and storing
    the backends the hook generates.
---
 xref-union.el | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/xref-union.el b/xref-union.el
index 8bb486b28e..a8246672ad 100644
--- a/xref-union.el
+++ b/xref-union.el
@@ -106,12 +106,18 @@ PATTERN is specified in `xref-backend-apropos'."
   (when xref-union--current
     (remove-hook 'xref-backend-functions xref-union--current))
   (when xref-union-mode
-    (thread-last
-      xref-union-excluded-backends
-      (seq-difference xref-backend-functions)
-      (cons 'union)
-      (setq xref-union--current)
-      (add-hook 'xref-backend-functions))))
+    (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))
+         (unless (and b (member b xref-union-excluded-backends))
+           (push b backends))
+         nil))
+      (setq xref-union--current (cons 'union backends))
+      (add-hook 'xref-backend-functions xref-union--current))))
 
 ;; LocalWords: backend backends
 



reply via email to

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