by akkartik · 4y ago · 0 comments
And in 5 years I can't for the life of me configure this! No solution transparently sets this default for all time. Every new fucking file type I try to edit needs me to go around in circles fixing this stupid behavior.
Sigh. Back to Vim, I guess. I don't understand why this doesn't come up more often in all the blog posts about transitioning to/from Emacs.
1. Bind the behavior you want in the global map. (global-set-key (kbd "<key-here>") #'the-action-you-want)
2. Any time you encounter a mode which overrides this key, press C-h k <key-here>. It will tell you the name of the map in which the key is bound (usually foo-mode-map). Then, add: (define-key foo-mode-map (kbd "<key-here>") nil). This will unmap the key from the mode's map, revealing the binding in the global map.
Because most people who use Emacs like this behaviour.
Also considering that this post promises a relatively vanilla editing experience, you shouldn't expect a solution to your particular problem.
> And in 5 years I can't for the life of me configure this!
It is not that hard to solve this. It is extremely easy to map any key in Emacs. You can just map Tab key to insert a tab if that is what you want. It will be like two lines of elisp.
Edit: The reason most Emacs users don't find the tab behaviour a problem is: a, Emacs indents correctly more often than not and b, you can insert a literal tab character when you want using 'C-q Tab'.
(require 'bind-key)
(bind-key* (kbd "tab") (lambda () (insert " ")))
And you should probably construct the number of spaces from the tab-width variable.There's also general-override-mode-map from the "general" package.
edit: Looking at the code I don't think bind-key* creates a minor-mode but it still does what you want (and is probably the recommended way).
Edit: Try this:
(defun indent-for-tab-command ()
(interactive)
(insert-char #x20 4))