summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKyle Meyer <kyle@kyleam.com>2017-06-24 12:44:11 -0400
committerKyle Meyer <kyle@kyleam.com>2017-06-24 12:54:23 -0400
commit285188b61ac1383a747165ce90174082fbe4124b (patch)
tree491b37b408eb4d82549c0895e2396ab40d177cd4
parent90d926b984f35dc9240b104a87106c3897047888 (diff)
downloademacs.d-285188b61ac1383a747165ce90174082fbe4124b.tar.gz
emacs-lisp-mode-hook: Enable xref-etags-mode inside Git repos
This makes it easier to jump to definitions in the repository rather than definitions for symbols defined in the current Emacs session. Aside from needing to generate a TAGS file, the tradeoff is that I have to use describe-variable or {find,describe}-function for symbols outside of repo.
-rw-r--r--init.el10
1 files changed, 10 insertions, 0 deletions
diff --git a/init.el b/init.el
index 26a0b2b..da48d8a 100644
--- a/init.el
+++ b/init.el
@@ -1875,6 +1875,16 @@
(setq outline-level #'km/elisp-outline-level))
(add-hook 'emacs-lisp-mode-hook #'km/elisp-set-outline-vars)
+ (defun km/elisp-use-xref-etags-inside-git ()
+ (when (and (executable-find "git")
+ (equal (with-temp-buffer
+ (call-process "git" nil t nil
+ "rev-parse" "--is-inside-work-tree")
+ (buffer-string))
+ "true\n"))
+ (xref-etags-mode 1)))
+ (add-hook 'emacs-lisp-mode-hook #'km/elisp-use-xref-etags-inside-git)
+
;; Modified from usepackage's issue #80.
(defun km/imenu-add-use-package ()
(when (string= (buffer-file-name (buffer-base-buffer))