mathlete
mathlete

Reputation: 6692

How to enter a space in the minibuffer instead of completing a word?

I would like to print from dired-mode by using P. This works fine for the default print command I have set up via lpr-switches, but I often want to edit the command. For example, if P suggests lpr, I would like to add -o number-up=2. The problem is that this contains a space after -o and hitting the space bar gives me No match. How can one adjust the lpr (or other commands facing the same problem)?

Upvotes: 8

Views: 2619

Answers (2)

Drew
Drew

Reputation: 30708

You can also bind SPC to self-insert-command in each of the minibuffer keymaps. Then you do not need to use C-q.

(There is no reason in the 21st century for SPC in the minibuffer to complete. Emacs finally got rid of this vestige for file-name completion, but it has not yet wised up wrt other kinds of completion. No printable character should be bound to a command that completes --- they should all self-insert. Not being able to insert a ? or SPC without using C-q is archaic.)

Upvotes: 4

Tyler
Tyler

Reputation: 10032

In the mini-buffer, space is bound to a completion command. If you want to enter an actual ' ', you need to quote it: C-q <space>. This comes up a lot for me, so I've bound M-<space> to enter a literal space in the minibuffer:

EDIT: following phils comment, the following code snippet is really pointless. You can get the desired behaviour with M-space without any keybindings.

(define-key minibuffer-local-completion-map "\M- " 
    (lambda () (interactive) (insert " "))) 

Upvotes: 11

Related Questions