How to insert space in minibuffer while in completing-read ?
  Home FAQ Contact Sign in
gnu.emacs.help only
 
Advanced search
POPULAR GROUPS

more...

gnu.emacs.help Profile…
 Up
How to insert space in minibuffer while in completing-read ?         


Author: Brian Adkins
Date: Mar 7, 2008 12:41

I've been using the Emacs timeclock to track my time on various
activities. When I invoke timeclock-in, I'm unable to enter a project
name containing embedded space characters (unless it's already in the
auto complete list by virtue of me manually editing the timelog file
beforehand).

I think I tracked the problem down to the completing-read function
that eventually gets invoked from timeclock-in. I put the following
snippet (from timeclock.el) in the *scratch* buffer and invoked it via
C-M-x

(completing-read "Enter string (default foo): " '("bar" "fuz") nil nil
nil nil "foo")

If I type b the minibuffer will complete to bar, but I can't
then type a space. My temporary work around was to do the following:

(global-set-key (kbd "C-#") (lambda () (interactive) (insert-char ?\s
1)))

and then press C-# instead of while in the minibuffer, and
that works fine :)
Show full article (1.03Kb)
6 Comments
Re: How to insert space in minibuffer while in completing-read ?         


Author: Pascal Bourguignon
Date: Mar 7, 2008 13:26

Brian Adkins gmail.com> writes:
> I suppose my question is how to unbind the key from the
> minibuffer-complete-word command when invoking the timeclock-in
> command?

C-q SPC

--
__Pascal Bourguignon__ http://www.informatimago.com/
Litter box not here.
You must have moved it again.
I'll poop in the sink.
no comments
Re: How to insert space in minibuffer while in completing-read ?         


Author: Brian Adkins
Date: Mar 7, 2008 13:53

On Mar 7, 4:26 pm, Pascal Bourguignon informatimago.com> wrote:
> Brian Adkins gmail.com> writes:
>> I suppose my question is how to unbind the key from the
>> minibuffer-complete-word command when invoking the timeclock-in
>> command?
>
> C-q SPC

Thanks, that's a much simpler work around than mine :)

That would work for most of my timeclock projects (0 to 2 spaces), but
occasionally I just want to enter a longer description on that line,
such as:

Met with John & Joe to discuss the authentication scheme

so, it would also be nice to get my space bar back from the over
zealous auto completer. I can M-x timeclock-visit-timelog and edit the
line manually, but it would be nicer to just enter it in the
minibuffer.
Show full article (1.04Kb)
no comments
RE: How to insert space in minibuffer while in completing-read ?         


Author: Drew Adams
Date: Mar 7, 2008 14:09

>> I suppose my question is how to unbind the key from the
>> minibuffer-complete-word command when invoking the timeclock-in
>> command?
>
> C-q SPC

Sure, you can quote each space character with `C-q'. Or you can fix Emacs to
do what you want all the time.

Emacs users should be able to type space chars in minibuffer input. Period.
Emacs 22 finally allows that for file-name input, but it should be available
for all minibuffer input. Input completion is not limited to command names.

Solutions:

1. Use Icicles: http://www.emacswiki.org/cgi-bin/wiki/Icicles.

2. If you don't want to use Icicles, but you do want to allow space chars in
minibuffer input, do this:

(define-key minibuffer-local-completion-map
" " 'self-insert-command))
(define-key minibuffer-local-must-match-map
" " 'self-insert-command))
Show full article (1.56Kb)
no comments
Re: How to insert space in minibuffer while in completing-read ?         


Author: Brian Adkins
Date: Mar 7, 2008 15:34

On Mar 7, 5:09 pm, "Drew Adams" oracle.com> wrote:
>>> I suppose my question is how to unbind the key from the
>>> minibuffer-complete-word command when invoking the timeclock-in
>>> command?
>
>> C-q SPC
>
> Sure, you can quote each space character with `C-q'. Or you can fix Emacs to
> do what you want all the time.
>
> Emacs users should be able to type space chars in minibuffer input. Period.
> Emacs 22 finally allows that for file-name input, but it should be available
> for all minibuffer input. Input completion is not limited to command names.
>
> Solutions:
>
> 1. Use Icicles:http://www.emacswiki.org/cgi-bin/wiki/Icicles.
>
> 2. If you don't want to use Icicles, but you do want to allow space chars in
> minibuffer input, do this: ...
Show full article (1.73Kb)
no comments
Re: How to insert space in minibuffer while in completing-read ?         


Author: Stefan Monnier
Date: Mar 8, 2008 13:24

> 2. If you don't want to use Icicles, but you do want to allow space chars in
> minibuffer input, do this:
> (define-key minibuffer-local-completion-map
> " " 'self-insert-command))
> (define-key minibuffer-local-must-match-map
> " " 'self-insert-command))

I think you mean to set those keys to nil rather than to
`self-insert-command'. It may have the same result in 99%% of the cases
in the end, of course.

Stefan
1 Comment
RE: How to insert space in minibuffer while in completing-read ?         


Author: Drew Adams
Date: Mar 8, 2008 14:06

>> 2. If you don't want to use Icicles, but you do want to
>> allow space chars in minibuffer input, do this:
>
>> (define-key minibuffer-local-completion-map
>> " " 'self-insert-command))
>> (define-key minibuffer-local-must-match-map
>> " " 'self-insert-command))
>
> I think you mean to set those keys to nil rather than to
> `self-insert-command'. It may have the same result in 99%% of
> the cases in the end, of course.

Right. It's enough to remove the local binding, to restore the global
binding. Either is OK here, but what you suggest is preferable.
no comments