by akkartik · 4y ago · 0 comments
* 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!I'm not at a computer with an emacs installation so I can't try it out myself. I would try binding to a regular key (e.g. "q") while debugging to try to reduce the possible problems.
I think you'll find that remapping tab everywhere like that is going to break a lot of things though (navigating fields/links, expanding sections, etc). You might want to just remap the key by explicitly listing the modes you care about.
The #emacs channel on libera (previously freenode) used to be amazing but since IRC waned it's become less good but if you're lucky and during busy times you might still find someone there that can give you a better solution.
I think I can now give Emacs another try!
The other thing you might want to try is to remap the function indent-for-tab-command to insert-tab.
"If the value is t (the default), the command normally just indents the current line. If the value is nil, the command indents the current line only if point is at the left margin or in the line’s indentation; otherwise, it inserts a tab character." (https://www.gnu.org/software/emacs/manual/html_node/elisp/Mo...)
Unfortunately this doesn't immediately work as described (Mac OS, GNU Emacs 27.2). When the buffer x.c looks like this (^ showing point):
int main(void) {
aaa
^
Pressing Tab now does nothing. I wonder if I need to do something to add this to c-major-mode. I also don't yet understand `setq-default`.There is one obvious conclusion to draw from that.