Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you move the prefix argument to a different key in Emacs?

Tags:

emacs

colemak

I'm using an alternate keyboard layout (Colemak) and I want to move the universal-argument command to a different key in Emacs, C-l instead of C-u. I tried the following, but it doesn't let me chain multiple universal arguments together multiplicatively (C-l C-l C-l) and it breaks C-l C-u too (which should move up 4 lines):

(global-set-key "\C-l" 'universal-argument)
(global-set-key "\C-u" 'previous-line)
like image 560
ninjudd Avatar asked Jan 26 '11 19:01

ninjudd


1 Answers

When you use the prefix argument, Emacs uses a keymap temporarily to handle the universal argument functionality. So, you need to make the changes you've made there too:

(define-key universal-argument-map "\C-l" 'universal-argument-more)
(define-key universal-argument-map "\C-u" nil)

The first sets up C-l to be the continuation of universal-argument, and the second un-defines the C-u from that map b/c you no longer want it to be the universal argument.

like image 143
Trey Jackson Avatar answered Oct 11 '22 11:10

Trey Jackson