Question

Continuing my process of migrating the latest & greatest Emacs 23.2, I hit another unpleasant surprise: dynamic expansion in minibuffer no longer works!

By "dynamic expansion in the minibuffer" I mean the feature that lets you blindly hit the spacebar to complete filenames, variables, etc.

I also invoked 'Emacs -Q' (to rule out any .emacs artifacts) and the problem exists not only with Emacs 23.2 on Windows XP, but even with Emacs 22.1 on Ubuntu.

Something has changed in Emacs' default behavior, but what is it?

Was it helpful?

Solution

From the (22.1) NEWS file:

** When Emacs prompts for file names, SPC no longer completes the file name.
This is so filenames with embedded spaces could be input without the
need to quote the space with a C-q.  The underlying changes in the
keymaps that are active in the minibuffer are described below under
"New keymaps for typing file names".

If you want the old behavior back, add these two key bindings to your
~/.emacs init file:

  (define-key minibuffer-local-filename-completion-map
         " " 'minibuffer-complete-word)
  (define-key minibuffer-local-must-match-filename-map
         " " 'minibuffer-complete-word)

OTHER TIPS

The posted solution works, but will break once we get to Emacs v24 and later. I would recommend instead tying your define-key calls to the presence of the new maps, as so:

(if (boundp 'minibuffer-local-filename-completion-map) 
   (define-key minibuffer-local-filename-completion-map " " 'minibuffer-complete-word))

(if (boundp 'minibuffer-local-must-match-filename-map)
   (define-key minibuffer-local-must-match-filename-map " " 'minibuffer-complete-word))

This should work correctly for all Emacs versions.

Answering my 2nd question (in the comment):

(defmacro GNUEmacs23 (&rest body)
  (list 'if (string-match "GNU Emacs 23" (version))
        (cons 'progn body)))

(defmacro GNUEmacs22 (&rest body)
  (list 'if (string-match "GNU Emacs 22" (version))
        (cons 'progn body)))

(GNUEmacs22
  (define-key minibuffer-local-filename-completion-map " " 'minibuffer-complete-word)
  (define-key minibuffer-local-must-match-filename-map " " 'minibuffer-complete-word)
)

(GNUEmacs23
  (define-key minibuffer-local-filename-completion-map " " 'minibuffer-complete-word)
  (define-key minibuffer-local-must-match-filename-map " " 'minibuffer-complete-word)
)

If you come up with a more elegant solution, that would be great, but the above works for me (for now).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top