1

I am frequently running multiple Emacs servers. When I am in a particular client I sometimes want to check which Emacs server I am connected to.

So I do:

`C-h v`

… and the enter in the mini-buffer server-name.

Is there a way to define a keybinding that also includes the input that should be entered in the mini-buffer?

1

Every key runs an Emacs command. You make an Emacs command (a special kind of function) then bind some key to it. For example, in your case, C-h v runs the describe-variable commands and takes 'server-name as its argument, thus you can make a command for your need using something like:

(defun describe-server-name ()
  (interactive)
  (describe-variable 'server-name))

You can test this new command using M-x describe-server-name RET, if you are happy with it, you can bind some key (for example C-h C-s) to it:

(global-set-key (kbd "C-h C-s") 'describe-server-name)

Another way is using (emacs) Keyboard Macros, I think minibuffer input is supported in vanilla Emacs. You can also fake the keyboard macro (which is a special kind of Emacs command) but I don't recommend this way:

(global-set-key (kbd "C-h C-s") (kbd "C-h v server-name RET"))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.