commit 387b22de43a0a74e11106558d7552826267f5c5a parent 879d0ac7b5606fca6ce9c33c32db33f2032bb910 Author: Alex Balgavy <alex@balgavy.eu> Date: Thu, 15 Jul 2021 11:02:31 +0200 emacs: set tags file automatically via default-tags-table-function Diffstat:
M | emacs/config.org | | | 13 | ++++++++----- |
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/emacs/config.org b/emacs/config.org @@ -428,11 +428,14 @@ Use hippie expand instead of dabbrev-expand: When opening a file in a git repo, try to discover the etags file: #+begin_src emacs-lisp - (add-hook 'find-file-hook - (lambda () (let* ((tagspath ".git/etags") - (git-root (locate-dominating-file (buffer-file-name) tagspath))) - (if git-root - (visit-tags-table (expand-file-name tagspath git-root) 1))))) + (defun current-tags-file () + "Get current tags file" + (let* ((tagspath ".git/etags") + (git-root (locate-dominating-file (buffer-file-name) tagspath))) + (if git-root + (expand-file-name tagspath git-root)))) + + (setq default-tags-table-function #'current-tags-file) #+end_src There's probably a better way to write this. I need to ask Reddit for feedback at some point.