commit f59bd54e81aea5921203eb36016d37cbdbefce32
parent 316b8ce63753df32ce00a5bd0e463c5880454d3e
Author: Alex Balgavy <alex@balgavy.eu>
Date: Fri, 9 Jul 2021 17:02:13 +0200
emacs: set up semantic navigation
Semantic-mode and tags. I'll have two tags files: .git/tags for Vim
tags, and .git/etags for Emacs tags.
Diffstat:
1 file changed, 38 insertions(+), 4 deletions(-)
diff --git a/emacs/config.org b/emacs/config.org
@@ -236,10 +236,10 @@ And I'm not gonna be a heretic and open Vim inside of Emacs.
#+begin_src emacs-lisp
(let ((mode-hooks '(doc-view-mode-hook vterm-mode-hook)))
- (mapc
- (lambda (mode-name)
- (add-hook mode-name (lambda () (display-line-numbers-mode 0))))
- mode-hooks))
+ (mapc
+ (lambda (mode-name)
+ (add-hook mode-name (lambda () (display-line-numbers-mode 0))))
+ mode-hooks))
#+end_src
*** Modeline
I want to show the time and date in the modeline:
@@ -424,6 +424,40 @@ Use hippie expand instead of dabbrev-expand:
(setq load-prefer-newer t)
#+end_src
+** Automatically find tags file
+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)))))
+#+end_src
+
+There's probably a better way to write this. I need to ask Reddit for feedback at some point.
+
+** Semantic mode
+Set default submodes:
+
+#+begin_src emacs-lisp
+ (setq semantic-default-submodes '(global-semantic-idle-scheduler-mode ; reparse buffer when idle
+ global-semanticdb-minor-mode ; maintain database
+ global-semantic-idle-summary-mode ; show information (e.g. types) about tag at point
+ global-semantic-stickyfunc-mode)) ; show current funt in header line
+#+end_src
+
+SemanticDB is written into ~/.emacs.d/semanticdb/.
+
+Enable semantic mode for major modes:
+
+#+begin_src emacs-lisp
+ (let ((mode-hooks '(c-mode-common-hook)))
+ (mapc (lambda (mode-name)
+ (add-hook mode-name (lambda () (semantic-mode 1))))
+ mode-hooks))
+#+end_src
+
* Misc settings
** Enable all commands
By default, Emacs disables some commands.