Skip to main content
may not work on text terminal
Source Link
JeanPierre
  • 7.5k
  • 1
  • 21
  • 39

It is perfectly possible to bind C-digit, at least in a "graphical terminal". Actually In a text terminal, theythings may be different because the terminal may itself generate characters from a key combo, which then can't be seen by emacs. See this answer for discussion and links.

Actually, C-0, C-1 etc are already bound in the global map, as can be seen with the command describe-key:

M-x describe-key CTRL 1

C-1 runs the command digit-argument (found in global-map), which is an interactive compiled Lisp function in ‘simple.el’.

It is bound to C-9, C-8, C-7, C-6, C-5, C-4, C-3, C-2, C-1, C-0, ESC 0..9, C-M-9, C-M-8, C-M-7, C-M-6, C-M-5, C-M-4, C-M-3, C-M-2, C-M-1, C-M-0.

(digit-argument ARG)

Part of the numeric argument for the next command. C-u following digits or minus sign ends the argument.

You can rebind it, eg:

(global-set-key [(control ?1)] 'save-buffer)

You can do the same for #:

(global-set-key [(control ?#)] 'save-buffer)

For information on how to rebind keys, see the elisp manual chapter on keymaps.

It is perfectly possible to bind C-digit. Actually, they are already bound in the global map, as can be seen with the command describe-key:

M-x describe-key CTRL 1

C-1 runs the command digit-argument (found in global-map), which is an interactive compiled Lisp function in ‘simple.el’.

It is bound to C-9, C-8, C-7, C-6, C-5, C-4, C-3, C-2, C-1, C-0, ESC 0..9, C-M-9, C-M-8, C-M-7, C-M-6, C-M-5, C-M-4, C-M-3, C-M-2, C-M-1, C-M-0.

(digit-argument ARG)

Part of the numeric argument for the next command. C-u following digits or minus sign ends the argument.

You can rebind it, eg:

(global-set-key [(control ?1)] 'save-buffer)

You can do the same for #:

(global-set-key [(control ?#)] 'save-buffer)

For information on how to rebind keys, see the elisp manual chapter on keymaps.

It is perfectly possible to bind C-digit, at least in a "graphical terminal". In a text terminal, things may be different because the terminal may itself generate characters from a key combo, which then can't be seen by emacs. See this answer for discussion and links.

Actually, C-0, C-1 etc are already bound in the global map, as can be seen with the command describe-key:

M-x describe-key CTRL 1

C-1 runs the command digit-argument (found in global-map), which is an interactive compiled Lisp function in ‘simple.el’.

It is bound to C-9, C-8, C-7, C-6, C-5, C-4, C-3, C-2, C-1, C-0, ESC 0..9, C-M-9, C-M-8, C-M-7, C-M-6, C-M-5, C-M-4, C-M-3, C-M-2, C-M-1, C-M-0.

(digit-argument ARG)

Part of the numeric argument for the next command. C-u following digits or minus sign ends the argument.

You can rebind it, eg:

(global-set-key [(control ?1)] 'save-buffer)

You can do the same for #:

(global-set-key [(control ?#)] 'save-buffer)

For information on how to rebind keys, see the elisp manual chapter on keymaps.

Source Link
JeanPierre
  • 7.5k
  • 1
  • 21
  • 39

It is perfectly possible to bind C-digit. Actually, they are already bound in the global map, as can be seen with the command describe-key:

M-x describe-key CTRL 1

C-1 runs the command digit-argument (found in global-map), which is an interactive compiled Lisp function in ‘simple.el’.

It is bound to C-9, C-8, C-7, C-6, C-5, C-4, C-3, C-2, C-1, C-0, ESC 0..9, C-M-9, C-M-8, C-M-7, C-M-6, C-M-5, C-M-4, C-M-3, C-M-2, C-M-1, C-M-0.

(digit-argument ARG)

Part of the numeric argument for the next command. C-u following digits or minus sign ends the argument.

You can rebind it, eg:

(global-set-key [(control ?1)] 'save-buffer)

You can do the same for #:

(global-set-key [(control ?#)] 'save-buffer)

For information on how to rebind keys, see the elisp manual chapter on keymaps.