I am dissatisfied with current behaviour of Emacs in CC Mode. I'm not sure if this applies to other major modes, but that's one I'm currently struggling with. Here are my problems:
- When I press tab, instead of inserting just one tab, Emacs either inserts enough space to match last line indentation level.
- I also can't insert tab when on empty line.
I believe those are caused by
c-indent-line-or-region function, according to
C-h l, but I don't know what I can do with it. Neither of possible values for
c-tab-always-indent change this situation.
I found something about
tab-to-tab-stop, and using it helped, however, it disabled expanding snippets from yasnippet or
<s in org-mode.
My setup consists of Evil-mode, Company-mode, LSP-mode, and following directives in
(setq-default indent-tabs-mode t) (setq tab-width 8) (defvaralias 'c-basic-offset 'tab-width) (setq-default c-default-style "linux" c-basic-offset 8 c-tab-always-indent nil indent-tabs-mode t)
tab-to-tab-stop has something related to expanding in it's source:
(and abbrev-mode (= (char-syntax (preceding-char)) ?w) (expand-abbrev))
but it doesn't help.
I thought I found solution in using
'complete, and it worked, for some time, but after I restarted emacs, it, again, has no effect.
(setq-default c-tab-always-indent 'complete) ... ;; in configuration for evil mode (define-key evil-insert-state-map (kbd "TAB") 'tab-to-tab-stop)
So is there a way for me to make tabs stupid, i.e. having pressing Tab just insert
\t (or N spaces if configured so), while keeping the ability to expand snippets using it?
After disabling tab-to-tab-stop and seeing with
C-h l what exactly causes snippets to expand (
yas-expand), I'm starting to suspect that there is some kind of function that tries to understand the context and apply specific action, and my evil-state map interferes with it, taking priority or something? Are my guesses wrong?