Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set enable-recursive-minibuffers automatically #100

Closed
ashton314 opened this issue May 28, 2020 · 12 comments
Closed

Set enable-recursive-minibuffers automatically #100

ashton314 opened this issue May 28, 2020 · 12 comments

Comments

@ashton314
Copy link

Expected Behavior

Let's say I want to evaluate the variable magit-completing-read-function from the minibuffer. I'd hit M-: to bring up the Eval: prompt, then I'd type magit- and expect to see a list of viable variable candidates.

Current Behavior

After bringing up the Eval: prompt, I type magit-, hit TAB and I get an error saying Command attempted to use minibuffer while in minibuffer.

Steps to reproduce

  1. Start Emacs with emacs -q
  2. Load Selectrum (I ran load-file and found selectrum.el in my .emacs.d/ directory)
  3. Type M-: ema TAB (I'm not sure what the completion candidates are here

It seems to only happen if there are candidates to complete. If you type a string like asdfasdf it will just say no matches in the minibuffer.

@Raphus-cucullatus
Copy link

I met the same issue. Here is the backtrace (with some long line truncated):

Debugger entered--Lisp error: (error "Command attempted to use minibuffer while in minibuffer")
  read-from-minibuffer("Completion: " nil (keymap (9 . selectrum-insert-current-candidate) (10 . selectrum-submit-exact...
  selectrum-read("Completion: " (... ... ... ... ... ... ... ... ... ... ... ... ... ... ...) :may-modify-candidates t)...
  selectrum-completion-in-region(#<marker at 8 in  *Minibuf-1*> 11 [0 0 ansi-color-apply-overlay-face isearch--state-po...
  completion-in-region(#<marker at 8 in  *Minibuf-1*> 11 [0 0 ansi-color-apply-overlay-face isearch--state-pop-fun--cma...
  completion-at-point()
  funcall-interactively(completion-at-point)
  call-interactively(completion-at-point nil nil)
  command-execute(completion-at-point)
  read-from-minibuffer("Eval: " nil (keymap (9 . completion-at-point) (27 keymap (9 . completion-at-point)) keymap (rem...
  read--expression("Eval: ")
  byte-code("\301\302!\303\10!B\207" [current-prefix-arg read--expression "Eval: " eval-expression-get-print-arguments]...
  call-interactively(eval-expression nil nil)
  command-execute(eval-expression)

Completion in minibuffer incurs selectrum-completion-in-region who calls selecttrum-read who itself uses the minibuffer.

Completion in minibuffer is useful: when type elisp with"M-:", when enter shell command with "M-!", etc. So it is quite frustrating that selectrum makes completion in minibuffer not work.

As a temporary workaround, I checkout to commit prior to 8857a8f. Hope this can be fixed soon.

@clemera
Copy link
Collaborator

clemera commented May 31, 2020

I think you both forgot to set enable-recursive-minibuffers to t? @raxod502 Maybe selectrum-mode should do this by default?

@Raphus-cucullatus
Copy link

You are right! After setting enable-recursive-minibuffers to t, it works. Thanks!

@Raphus-cucullatus
Copy link

Hi @clemera , but here comes another issue when in a remote buffer (TRAMP),

  • If I checkout 2b49ab4 (so that no selectrum-completion-in-region), if I use "M-! ls ~/" then "<TAB>", home files on this remote machine are shown. This is expected.
  • But if I use master and set enable-recursive-minibuffers to t, home files on my local machine are shown.

Do you experience this, or it is again due to my incorrect config?

@clemera
Copy link
Collaborator

clemera commented May 31, 2020

Thanks for discovering this, that seems to be a bug with file completion for selectrum-completion-in-region. Could you open another issue for that?

@Raphus-cucullatus
Copy link

Raphus-cucullatus commented May 31, 2020

OK, thanks again for your timely reply!

@raxod502
Copy link
Member

raxod502 commented Jun 12, 2020

I am a little reluctant to automatically bind enable-recursive-minibuffers. After all, some people want the default behavior (perhaps it was Stefan Monnier who said he liked it?), and if we bind the variable to non-nil automatically, then there's no way for the user to enforce that setting.

On the other hand, I suppose we could have a variable selectrum-enable-recursive-minibuffers which, if non-nil, means enable-recursive-minibuffers gets set to non-nil. I think that would be a fine idea, and quite easy to add. The value of this new variable could be non-nil by default.

@ashton314
Copy link
Author

I think that's a good idea. If I get some time tomorrow I can try my hand at creating a PR for that.

@clemera clemera changed the title Completing variable names from M-: not working Set enable-recursive-minibuffers automatically Aug 6, 2020
@DivineDominion
Copy link

Ran into this today and was puzzled :) Couldn't selectrum catch the error defensively (checking if that's enabled) and then display a more helpful error message in the minibuffer? Like

Requires enable-recursive-minibuffers to be non-nil for completion to work here

@raxod502
Copy link
Member

Yes, that seems like a good idea, I agree.

@mathrick
Copy link

I just ran into this issue now that I've switched over to selectrum. Couldn't selectrum automatically bind it to t when it's asked to do completion, ie. if I'm inside M-: and press <TAB>, I clearly want to get completion. I think at this point selectrum should simply make sure that won't error out with (let ((enable-recursive-minibuffers t)) ...), so that it can provide the user with the requested functionality without changing the defaults elsewhere.

Alternatively, maybe use a popup buffer if recursive minibuffers are disabled, the way default completion (and icomplete) do in this situation? I don't know how much of a rewrite making selectrum able to use a non-minibuffer buffer would be.

@clemera
Copy link
Collaborator

clemera commented Jan 26, 2021

Thanks @mathrick for bringing my attention to this issue again. With #397 the value is let bound for the commands which need it, this is also what the built-in describe-... commands do.

@clemera clemera closed this as completed Jan 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

6 participants