0

Sometimes when using command zz (stash both), the minibuffer to enter a stash message does not allow me to enter whitespace (e.g. space chars). I typically resolve to use dashes or underscores or even the tedious C-q SPC, since it is not really important. Yet on other occasions I am sure I have had no problems to enter space chars.

Can someone explain this? Is it a version problem, mine is 20221208.1848.

EDIT: this is embarrassing. The hints in comments and the answer about checking my setup and using describe-key in the minibuffer prompted me to inspect my startup script for emacs, grown over many years. It explicitly defines (local-set-key " " 'minibuffer-complete-word) for the minibuffer. Obviously I have no idea anymore when and why I had the bright idea to enter this.

I don't think this question can help others, as it is probably too specific to serve even as a hint to carefully check startup scripts and try a clean version first. So I will delete it some time soon, giving the contributors time to have a good laugh at my blunder.

2
  • I guess that's either a bug in this specific version of magit or a problem with your configuration. I can't reproduce this on a fresh installation with the latest Magit (20230131.1151). Feb 1 at 17:41
  • Notwithstanding that this shouldn't be happening, you may find M-SPC slightly less tedious than C-q SPC on such occasions.
    – phils
    Feb 2 at 0:47

1 Answer 1

0

Emacs minibuffers for completion, except file-name completion, bind SPC to minibuffer-complete-word. I'm guessing that's the problem here.

Try either (1) globally binding SPC to self-insert-command in, say minibuffer-local-completion-map or (2) doing that only for the zz command. Here's #1:

(define-key minibuffer-local-map (kbd "SPC") 'self-insert-command)

If you want SPC to self-insert only for must-match completion then do that for minibuffer-local-must-match-map instead.


If, as a comment by @Gilles guesses, the command in question uses a keymap other than a completion keymap -- e.g., if it uses just function read-from-minibuffer, which uses keymap minibuffer-local-map, then just do the same thing I showed above, but with that keymap.

But first, check what the binding of SPC is in that keymap. You can do that with command describe-keymap. If that command is not available in your version of Emacs, you can get it with library help-fns+.el.

7
  • I wouldn't expect completion for the stash message, and the latest version of Magit calls read-from-minibuffer, not completing-read. I haven't checked the version of Magit in the question which is very slightly older. Feb 1 at 17:43
  • @Gilles'SO-stopbeingevil': In that case, what's the keymap used in that call, and what's the binding of SPC in it? If it's the usual minibuffer-local-map, and if the binding is not self-insert-command, then something (Magit?) must have changed the binding there. In any case, whatever the keymap used, the solution is the same: bind SPC to self-insert-command, if self-inserting is what's wanted. Oh, and why the downvote?
    – Drew
    Feb 1 at 18:23
  • In the current version, the keymap argument to read-from-minibuffer is nil, thus it uses minibuffer-local-map where SPC is not bound (and thus defaults to its global binding which is self-insert-command). Changing minibuffer-local-map or minibuffer-local-completion-map would not help (in the first case it's the default setting, in the second case it's not supposed to be used). Feb 1 at 18:48
  • @Gilles: So you're saying that using SPC in the minibuffer does not insert a space char, even though its binding in the minibuffer (here) is self-insert-command? How do you explain that description?
    – Drew
    Feb 1 at 19:19
  • No, on my machine (both with a fresh install with the latest Magit, and with my normal installation that I haven't updated in a long time), SPC at the magit-stash-both “Stash message: ” prompt inserts a space as expected. Feb 1 at 20:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.