From a5fd38c3a6f263185ce5838010e7a0d64b49bec2 Mon Sep 17 00:00:00 2001 From: Dmitry Gutov Date: Sat, 21 Nov 2015 01:57:00 +0200 Subject: [PATCH] Add xref--etags-backend to xref-backing-functions using add-hook * lisp/progmodes/xref.el (xref-backend-functions): Move the default value into a separate `add-hook' call (bug#21964). * lisp/progmodes/elisp-mode.el (emacs-lisp-mode): Don't declare the xref-backend-functions variable. It doesn't make any difference. --- lisp/progmodes/elisp-mode.el | 1 - lisp/progmodes/xref.el | 8 +++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/lisp/progmodes/elisp-mode.el b/lisp/progmodes/elisp-mode.el index bf0f4b0c9b..7e55c8e14b 100644 --- a/lisp/progmodes/elisp-mode.el +++ b/lisp/progmodes/elisp-mode.el @@ -228,7 +228,6 @@ Blank lines separate paragraphs. Semicolons start comments. \\{emacs-lisp-mode-map}" :group 'lisp - (defvar xref-backend-functions) (defvar project-library-roots-function) (lisp-mode-variables nil nil 'elisp) (add-hook 'after-load-functions #'elisp--font-lock-flush-elisp-buffers) diff --git a/lisp/progmodes/xref.el b/lisp/progmodes/xref.el index dcaffa4bbf..c5518907ae 100644 --- a/lisp/progmodes/xref.el +++ b/lisp/progmodes/xref.el @@ -201,15 +201,17 @@ LENGTH is the match length, in characters." ;;; API -;; We make the etags backend the default for now, until something -;; better comes along. -(defvar xref-backend-functions (list #'xref--etags-backend) +(defvar xref-backend-functions nil "Special hook to find the xref backend for the current context. Each functions on this hook is called in turn with no arguments and should return either nil to mean that it is not applicable, or an xref backend, which is a value to be used to dispatch the generic functions.") +;; We make the etags backend the default for now, until something +;; better comes along. +(add-hook 'xref-backend-functions #'xref--etags-backend) + ;;;###autoload (defun xref-find-backend () (run-hook-with-args-until-success 'xref-backend-functions)) -- 2.39.2