emacs-devel
[Top][All Lists]
Advanced

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

Re: Globally apply xref-etags-mode


From: Matt
Subject: Re: Globally apply xref-etags-mode
Date: Sat, 11 Nov 2023 15:15:59 +0100
User-agent: Zoho Mail

 ---- On Sat, 11 Nov 2023 14:58:54 +0100  Eli Zaretskii  wrote --- 

 > The usual way of solving this is with a hooks, like some mode hook or
 > maybe find-file-hook.

Thank you.

It appears like the benefit of using hooks for this is fine grained control.

To help future readers with a similar question, I was able to achieve the 
behavior I want with the following:

;; we want xref to navigate within the checkout directory, not within
;; the currently loaded Org mode (which is not the checkout).

;; generate TAGS file
(call-interactively
 #'(lambda ()
     "Basically calls 'ctags -eR [DIR]' on the given directory."
     (interactive)
     (xc/build-tags "/tmp/org-mode/" nil nil t)))

;; enable `xref-etags-mode' for buffers visiting files in the Org mode
;; clone directory
(add-hook 'xref-after-jump-hook
          (lambda ()
            (if (string= "tmp" (cadr (file-name-split (file-name-directory 
(buffer-file-name)))))
                (xref-etags-mode 1))))

;; open the file of interest
(find-file-other-window "/tmp/org-mode/lisp/ob-shell.el")

;;  Bootstrap the TAGS referencing
(with-current-buffer "ob-shell.el"
  (xref-etags-mode))




reply via email to

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