-->

In Emacs, how do I select the completion list with

2020-03-20 10:42发布

问题:

When I tab-complete in a minibuffer and Emacs displays a completion list in a new buffer, how do I switch to that buffer without using the mouse?

I tried C-x o, but that just switched to the first buffer, out of which I entered the minibuffer.

I also tried C-x b, but that gives me command attempted to use minibuffer while in minibuffer.

Lastly I tried C-x <C-right>, which gives me cannot switch buffers in minibuffer window.

EDIT: I spoke about minibuffer completion in my example, but being able to access the completion list (using the keyboard) from within a regular buffer is also important to me, and not working. The M-v shortcut was suggested, but it only seems to work inside the minibuffer accessed by M-x, in every other buffer I've tried, M-v is bound to scroll down command and does not switch to the completion list. I doesn't even seem to work in other minibuffers. For example, it doesn't work in the shell command minibuffer invoked by M-! either.

回答1:

You can use M-v (documented here) which switches to the completion buffer and puts the cursor on the first completion:

Typing M-v, while in the minibuffer, selects the window showing the completion list (switch-to-completions). This paves the way for using the commands below. <PageUp> or <prior> does the same. You can also select the window in other ways...

EDIT: It looks like based on your edit to the original question that what you're asking for is a way to switch to the completions buffer more globally. There is a function switch-to-completions that selects the completions list - you might consider binding that function to a key of your choosing, e.g.:

(define-key global-map (kbd "C-x t") 'switch-to-completions)

For example, such a binding allows me to switch to completions from "Shell command: " invoked by M-!, and places the cursor on the first possible completion.



回答2:

You can use C-xo twice, or use M--C-xo, which switches to the previous buffer instead of the next one.