yPhil
yPhil

Reputation: 8357

How to simulate return in emacs minibuffer

What I want to do is, when I find myself using a function that prompts me for a value, and this value is ALWAYS the right one, to be able to bind the function to a key and auto-accept the answer, simulating a RET in the minibuffer.

Take for instance "ido-switch-buffer". When entered, it prompts you for a buffer name, and proposes the last visited one.

(It can do a lot more, that's why I dont want to re-define it, I just want a wrapper around it)

Say I want to switch between the last visited two buffers, how would I say that in my .emacs ?

Upvotes: 2

Views: 479

Answers (2)

Michael Hoffman
Michael Hoffman

Reputation: 34324

You can do this with:

(switch-to-buffer (other-buffer))

Upvotes: 6

huaiyuan
huaiyuan

Reputation: 26539

You may bind any keyboard macro, which is essentially a sequence of keys, to a key. For example,

(global-set-key (kbd "C-c b") (kbd "C-x b <return>"))

Upvotes: 3

Related Questions