reddit / emacs

Some times in Insert mode space and tab doesnt insert space and tab.

Ethan045627 路 2022-07-23 02:11
I am using vanilla emacs and I configured it myself but sometimes when I try to insert space in insert mode the space key doesn't work and when I want to i dent a line tab just give company suggestions. I tried to check where things go wrong but was unable to find out. THANKS IN ADVANCE 馃槂. Here is my config: [Emacs.git](https://github.com/Ethan0456/Emacs.git)
snubbyJspreaker 路 2022-07-23 02:29
run emacs -Q and try to replicate the error post your config somewhere so others can look at it and try to help sus out to problem you might also check the \*Messages\* buffer for clues and run emacs --debug-init
Faerryn 路 2022-07-23 02:36
Are you using `evil-mode`?
Ethan045627 路 2022-07-23 02:48
Yes Brother
Ethan045627 路 2022-07-23 02:50
Yes Sure Brother Here is my config: [Emacs.git](https://github.com/Ethan0456/Emacs.git) Sorry took some minutes to make public
snubbyJspreaker 路 2022-07-23 03:31
first, were you able to reproduce the error with emacs -Q I see you've commented a bunch from bindings.el That's the next thing I'd do is take bindings.el out of init.el then in a scratch buffer eval one at a time the keybindings until you can reproduce there error. I don't know that it means anything but you use TAB a lot even in your qtile config. I'd next just load a bear minimum of use-package and from there try loading packages one at a time until you find the package that conflicts with some keybind. If you are using use-package you don't exactly need general.el because use-package include bind-keys and key-chords if I remember correctly and it might help to simplify your config (re the number of packages) especially when two packages duplicate functionality like general.el and bind-keys. I poked though your config hoping something would jump out at me (not that I am an elisp master) but nothing did. So generally what I do is exactly what I am telling you to do. Start with a blank slate, slowly eval your config a block at a time, until you get the error. Keep narrowing it down until you isolate the problem. After that you'll most likely be able to fix it yourself, if not this will allow you to ask a more narrow question that might get a better answer. For what it is worth I am willing to help in any way I am able.
[deleted] 路 2022-07-23 03:45
[deleted]
Ethan045627 路 2022-07-23 04:54
ya sure mate I am working as suggested I will surely ask if I get stuck 馃槂 Thanks a lot mate
jimehgeek 路 2022-07-23 07:17
Not sure about the issue with space. I鈥檇 suggest inspecting what function is bound to it with `C-h k`/`M-x describe-key RET` followed by `<space>`. This should give you a buffer that describes what function is bound to space. As for your TAB issue though, looking at your config, the differing behavior with TAB is because of your setup for company. Specifically, in `lsp-mode-map` (which is active whenever `lsp-mode` is active) you have bound TAB to `company-indent-or-complete-common`. This will change current indentation level if it鈥檚 not already what emacs thinks is the correct level, and if it does not need to change indentation, it triggers completion instead. This explains why you inconsistent behavior, as it鈥檚 only within files where you enable lsp-mode. Now my advice here, is actually to always have TAB bound to `company-indent-or-complete-common`. The reason is that default TAB behavior in Emacs is not to simply indent one level to the right, but rather to change current indent to the correct level left/right as needed. I find this stupidly useful, and removes the manual managing of indentation levels. However, when you do just want to change indentation level left/right regardless of what Emacs thinks is the correct level, have a look at the `smart-shift` package. It has methods for shifting indentation left/right. Personally in [my config](https://github.com/jimeh/.emacs.d/blob/master/modules/text-editing/siren-smart-shift.el) I have left bound to `C-c [`/`M-{`, and right to `C-c ]`/`M-}`.
Ethan045627 路 2022-07-23 10:29
Thanks Brother, nice observation. Sorry for late reply I have a lecture :) I wanted <space> as prefix key like doom emacs thats why describe key just waits for other key input after space. Yes you are right <tab> with company is causing problem but I find <tab> completion handy. Now I think I just have to bind the indentation function to other key (by using smart-shift or emacs indentation feature as you described) Did I miss anything?
jimehgeek 路 2022-07-23 11:04
Yeah, pretty much. I鈥檇 recommend you bind TAB globally (or during insert mode since you鈥檙e using evil) to `company-indent-or-complete-common`. That way pressing tab will trigger completion of current line is already intended to the correct level, and if not it will shift indentation left/right as needed to make it correct. In case it鈥檚 of any use to you, here鈥檚 my setup for company: https://github.com/jimeh/.emacs.d/blob/master/modules/completion/siren-company.el
Ethan045627 路 2022-07-23 11:17
Thanks Brother 馃槂 Now its working properly, your config is highly amazing I have one last question, I want "spc l" to give me lsp mode keybindings I tried to set it with general like (space is prefix, for whole general.el) "l" ((lambda () (lsp-command-map))) but its not giving me which-key panel and gives this error (I have lsp which key integration on) Error: Debugger entered--Lisp error: (wrong-type-argument commandp (lambda nil (lsp-command-map)))call-interactively((lambda nil (lsp-command-map)) nil nil)command-execute((lambda nil (lsp-command-map))) How can I map all lsp command map with <spc> l binding?
jimehgeek 路 2022-07-23 17:43
Ah, right. Key maps (named `*-map` by convention) are not thing you call like functions. They鈥檙e typically associated with major and minor modes, and automatically active while the associated mode is active. So in your config for example, you bind TAB in the `lsp-mode-map` to company. This key map is active while `lsp-mode` is enabled. So only in buffers where you鈥檝e turned on/enabled lsp-mode. All other buffers that key map will not be active. There鈥檚 quite a lot of reading about it you can do about it here: https://www.gnu.org/software/emacs/manual/html_node/emacs/Key-Bindings.html Also, since you pulling in general.el already, have a look at its evil examples: https://github.com/noctuid/general.el General seems to have nice integration with evil making it much easier to define custom keybindings. I don鈥檛 use modal editing myself though, so I鈥檝e got hardly no experience with configuring evil I鈥檓 afraid.
Ethan045627 路 2022-07-24 04:32
Thanks Bro 馃槂 Key bindings page provided detailed info Isp-command-map is a variable containing keymaps for lsp-mode, It is partially working, lsp bindings are just mixed with other bindings like "SPC w" has my evil-window bindings but after now it also contains lsp bindings for "SPC w'. I will find out and thanks for you help brother. 鉁岋笍鉁岋笍