In my .emacs, I tried to use

(global-set-key (kbd "M-r") (kbd "C-x r j")

so I can use M-r to jump to a register. However, doing this and using the command gives

After 0 kbd macro iterations: Args out of range: [], 0

as an error in the minibuffer. Looking up the shortcut with C-h k shows that the keyboard shortcut is bound to jump-to-register. Then, using

(global-set-key (kbd "M-r") 'jump-to-register)

gets the desired behavior, and my shortcut works.

My question is: why doesn't my first attempt work, esp. if it just really seems to be calling the same function?


I can reproduce this in Emacs 25.2.2. The problem is that when jump-to-register attempts to read the character that identifies the register, Emacs still thinks it's running a macro, but it has no more characters available. Your approach would work with a function that doesn't attempt to read extra input.

At the Lisp level, jump-to-register calls read-key which calls read-key-sequence-vector. In this scenario, read-key-sequence-vector returns an empty vector. read-key does not expect this and throws the error you saw. This looks like a bug in read-key-sequence-vector since it isn't documented as ever reading an empty vector and I don't see why it would.

  • Thanks Gilles! Maybe I should submit a bug request. – Yan X Zhang Dec 30 '18 at 18:38

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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