Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

emacs

elisp

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)?

like image 873
Marius Hofert Avatar asked Jul 04 '13 15:07

Marius Hofert


1 Answers

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 " "))) 
like image 199
Tyler Avatar answered Sep 19 '22 21:09

Tyler