by tabemacsthrow · 4y ago · 0 comments
(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).
* I installed Emacs 26.3 using `sudo apt install emacs`
* I installed Melpa by following https://github.com/melpa/melpa/blob/master/README.md#usage
* I installed use-package using `M-x package-install use-package`
Now I'm trying to make sense of your instructions while reading https://github.com/jwiegley/use-package#readme. I don't see a bind-key*, but I do see:
- bind-key
- bind-keymap
- bind-keymap*
Should I try one of those instead? They all seem to be in the context of a `(use-package ...)` declaration.
Edit: Never mind, I do see it now at https://github.com/jwiegley/use-package/blob/master/bind-key...
Edit 2: I just tried it and it didn't work. Turns out I've tried this approach in the past: https://lobste.rs/s/whaez0/emacs_everywhere#c_l6ez9w (edit 2 there, heh)
Wait, the suggestion at the top of that comment now works for me on a few different file extensions!
(setq-default tab-width 2)
(setq-default indent-tabs-mode nil) ; to insert a tab anyway: C-q TAB
(define-key global-map [tab]
(lambda () (interactive) (insert-tab)))
Thank you!