How can I use a number in a register after
For example my register looks like
1: 24, and I want to do
C-u 24 x.
Emacs Stack Exchange is a question and answer site for those using, extending or developing Emacs. It only takes a minute to sign up.Sign up to join this community
This should do the trick.
(defun reg-as-pref-arg (register) "Use numeric register as prefix arg for next command You are prompted for the register, showing preview of registers." (interactive (list (register-read-with-preview "Increment register: "))) (let ((reg-val (get-register register))) (when (numberp reg-val) (setq prefix-arg reg-val))))
C-u 42 C-x r n a ; Put 42 in register `a' M-x reg-as-pref-arg a X ; Use 42 as prefix arg for command to insert `X': 42 X's
Bind it to a key.
(global-set-key (kbd "C-o") #'reg-as-pref-arg)
Then use it.
C-o a X ; Insert 42 X's. C-o a C-M-f ; Move forward 42 words.