reddit / emacs

How to prevent Emacs from asking for keywords?

doloresumbridge42 · 2022-02-01 05:20
Whenver I try to create a new elisp file, a pop-up comes up from the minibuffer asking for keywords, with no way to get out of the pop-up, other than pressing "C-g" or something. But if I do that then it does not insert the complete file template for elisp files. How do I prevent this? ​ https://preview.redd.it/adxn3ld5p5f81.png?width=587&format=png&auto=webp&s=44b7cd24ead7b8a2000466c42b4482c4822f191e
7890yuiop · 2022-02-01 07:06
That *sounds* like `auto-insert-mode`. Just type `RET` at the prompt to include no keywords.
doloresumbridge42 · 2022-02-01 07:35
It is an `auto-insert-mode` issue. When I disable it, this goes away, but I would rather have that on. If I do `RET` at the prompt it just enters the topmost option, but the prompt stays.
Gangsir · 2022-02-01 08:01
You should be able to config the mode to only trigger on files you actually wanna have auto inserts for.
[deleted] · 2022-02-01 08:34
Depending on your completion framework, you need to do something like C-j, M-j, C-M-j to not select an item (RET) but explicitly input an empty string. What you have encountered here is one of those less common examples where an author assumed you were using the default completion system (expanding text, not selecting items), to the detriment of selecting systems. More usually, it is the opposite way around, and the assumption of selecting annoys those who prefer to complete. This is an inherent problem of the way `completing-read` is being used, and you have to keep in mind that there are always situations where you need to explicitly input text, even possibly an empty string.
7890yuiop · 2022-02-01 09:06
It sounds like _pkal has explained it -- you're using a non-default completion system which assumes you always want to enter a value, so `RET` doesn't enter an empty string like it normally would. You'll have to check the docs for your completion system to find out how to enter a blank value. (Run `emacs -Q` and enable `auto-insert-mode` to see how this normally works.)
paretoOptimalDev · 2022-02-01 11:25
Something similar also happens with org-roam-node-find where you can‘t type spaces because 'there is no match'.
T_Verron · 2022-02-01 12:13
Another option for some completion systems is to press C-p or <up> to select the empty input field rather than the first option.
[deleted] · 2022-02-01 14:31
What systems would that be. The issue here is that there is usually a loop in the code like (let (list) (while (not (equal (car list) "")) (push (completing-read "Choose: " '("foo" "bar" "baz")) list)) (cdr list)) that expects you to eventually input something that is not part of the completion table. In most cases be replaced by (completing-read-multiple "Choose: " '("foo" "bar" "baz")) as that usually works better for both approaches.
T_Verron · 2022-02-01 14:59
Right, I probably remember a combination of two problems. A while ago there was this problem with auctex and ivy for inserting \\usepackage declarations, and selecting the empty input was working as a work-around. Now the empty string does not bring any completion so just pressing RET works. On the other hand the keyword insertion of elisp auto-instert bring a list even with an empty input, and indeed there is no way to input something out of the list. But at least the prompt explicitly says "C-M-j to end".
oantolin · 2022-02-01 15:58
> More usually, it is the opposite way around, and the assumption of selecting annoys those who prefer to complete. I used default completion for quite a while and don't think I came across any examples of this. Would you mind listing a couple?
[deleted] · 2022-02-01 16:14
The one I encounter most often is AucTeX's compile menu, that prompts the user to select what they want to do (build a document, update bibtex, clean, clean all, ...). While I have mostly shifted towards C-c C-a, the idea of interrupting something that should be a key chord with completion seems wrong to me. I know I have experienced others, but I cannot recall them right now.
doloresumbridge42 · 2022-02-01 16:14
Thanks a lot /u/7890yuiop, /u/_pkal, and others. That really helped. The issue was with `vertico`, whose exit from the prompt is by default bound to `C-RET`. Guess I should have read the manual properly.
arthurno1 · 2022-02-01 19:13
> Whenver I try to create a new elisp file, a pop-up comes up from the minibuffer asking for keywords This is default auto-insert for elisp files. > with no way to get out of the pop-up, other than pressing "C-g" or something Press Ctrl + Enter > How do I prevent this? At the very first prompt, "Perform Emacs Lisp header auto-insertion? (y or n)", choose n or turn off auto-insert mode. However I suggest you not to, it is useful. It is not very difficult to use it. First when asked to perfom auto-insertion, choose y, then at the second prompt, "Short description: ", type a short sentence what the file is about, or just press Enter to skip it. Even if you don't type description, it will still insert the very first comment for lexical binding, which all new elisp files should have. It is faster to hit Enter, then to type all that yourself later, even if you use something like yasnipet to insert it. On the second prompt, the one you are showing, type Ctrl+Enter to skip entering keywords. You will end up with comments inserted, some basic info about the author (you) if you have configured user-full-name and user-mail-address (I think), the license (Gpl 3) and some basic boilerplate code to save you some typing. > The issue was with vertico, whose exit from the prompt is by default bound to C-RET No, it is not a feature of Vertico. I think it is completing-read which Vertico and nowadays, everyone else uses, that define that shortcut, but honestly I am not 100 about where it comes from.
7890yuiop · 2022-02-01 20:51
`C-q SPC` or `M-SPC` to insert a space during a completing read. And `C-q C-j` to insert a newline, while we're at it.
doloresumbridge42 · 2022-02-01 23:17
Thanks for the explanation. It could be a completiing-read thing. But the Vertico manual said that the exit from Vertico is bound to C-RET, by default, so I assumed that it is a Vertico thing.
arthurno1 · 2022-02-02 07:19
I use Helm, and it is also C-RET that exits the second completion, but yeah, I see now they have remapped C-RET in Vertico to vertico-exit-input. It doesn't matter, just remember how to use it.