diff options
author | Thomas Voss <mail@thomasvoss.com> | 2024-09-22 15:33:57 +0200 |
---|---|---|
committer | Thomas Voss <mail@thomasvoss.com> | 2024-09-22 15:33:57 +0200 |
commit | dea75596e412c3ae387a4ea08ce818099183807b (patch) | |
tree | d5240003bd8a09947928fddf9e1780cd14444d3e /.config/emacs/init.el | |
parent | fb4071adc5421d2084ea81db696642fb97f221d5 (diff) |
emacs: Add ‘x-set-tabsize’
Diffstat (limited to '.config/emacs/init.el')
-rw-r--r-- | .config/emacs/init.el | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/.config/emacs/init.el b/.config/emacs/init.el index 931ce9a..f966575 100644 --- a/.config/emacs/init.el +++ b/.config/emacs/init.el @@ -363,6 +363,32 @@ indentation-width.") (x-mode-to-hook (x-mode-to-ts-mode mode)))) (add-hook hook callback 95))))) +(defun x-set-tabsize () + "Set the tabsize for the current buffer. If the current buffers major +mode requires settings additional variables, those should be listed in +`x-indentation-settings'." + (interactive) + (let* ((major-mode-2 + (if (string-match-p "-ts-mode\\'" (symbol-name major-mode)) + (x-ts-mode-to-mode major-mode) + (x-mode-to-ts-mode major-mode))) + (prompt-default (number-to-string (default-value 'tab-width))) + (tabsize (string-to-number + (read-string + (format-prompt "Tabsize" prompt-default) + nil nil prompt-default)))) + (setq-local + tab-width tabsize + evil-shift-width tabsize) + (dolist (plist x-indentation-settings) + (let ((mode (car plist)) + (extra (plist-get (cdr plist) :extra-vars))) + (when (or (eq mode major-mode) + (eq mode major-mode-2)) + (mapc (lambda (var) + (set (make-local-variable var) tabsize)) + extra)))))) + (x-set-indentation-settings) ;;; Git Integration |