When I do C-h k M-1, I get
M-1 runs the command digit-argument (found in global-map), which is an interactive byte-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-1and 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.
When I do C-h w digit-argument, you get
digit-argument is on
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
Whenever there is a multiple key binding for the same command, it is usually to accommodate emacs -nw (terminal emacs) users.
Try running C-h k C-1 etc, C-h k M-1 etc, and C-h k C-M-1 etc on a emacs -nw and see what you get.
The C-1...C-9, M-1...M-9, C-M-1...C-M-9 are convenient ways to get single decimal digits.
And you can always input digit arguments using C-u 123 etc.. So yes, you can override the above keys.
I do have plenty of key bindings on the numeric keys.
For the sake of completion, this is what C-h k C-u shows
C-u runs the command universal-argument (found in global-map), which is an interactive byte-compiled Lisp function in simple.el.
It is bound to C-u.
(universal-argument)
Begin a numeric argument for the following command.
Digits or minus sign following C-u make up the numeric argument.
C-u following the digits or minus sign ends the argument.
C-u without digits or minus sign provides 4 as argument.
Repeating C-u without digits or minus sign multiplies the argument by 4 each time.
For some commands, just C-u by itself serves as a flag that is different in effect from any particular numeric argument.
These commands include C-SPC and M-x start-kbd-macro.
Following the leads in
Here is an "attempt" to get more BONUS keys ... The snippet is works on GUI Emacs.
(cl-loop for (x . fmt-string) in `( ;; ????: The `C-xxx` keys are problematic to generate in ;; terminal. If you type it, `Emacs` may report a ;; different thing. The behaviour varies with the ;; terminal. ("C" . "C-%s") ("M" . "M-%s") ;; ????: The previous comment applies ("C-M" . "C-M-%s") ,@(when (display-graphic-p) '(("ESCAPE" . "<escape> %s")))) do (cl-loop for digit in (number-sequence 0 9) for key = (format fmt-string digit) for sym = (intern (format "BLAH-%s-%s" x digit)) do (condition-case err (progn (message "%s -> %s" key sym) (define-key input-decode-map (kbd key) (vector sym))) (error (message "Error %S" err))))) ;; Bind `C-1' to `find-file' (global-set-key (kbd "<BLAH-C-1> f") 'find-file) (add-hook 'emacs-lisp-mode-hook 'outline-minor-mode) ;; Bind `C-0' as `outline-minor-mode-prefix' (custom-set-variables ;; Key zero look like `o` (for outline) '(outline-minor-mode-prefix (kbd "<BLAH-C-0>"))) ;; Use `C-0 C-0' to to enable `outline-minor-mode' (global-set-key (kbd "<BLAH-C-0> <BLAH-C-0>") 'outline-minor-mode) (add-hook 'hs-minor-mode-hook (defun my-hs-minor-mode-hook () ;; Overwrite `hs-minor-mode-map'. `C-c @' is difficult to ;; type. (setq hs-minor-mode-map (let ((map (make-sparse-keymap))) ;; These bindings roughly imitate those used by Outline mode. (define-key map (kbd "C-S-b") 'hs-show-block) (define-key map (kbd "C-b") 'hs-hide-block) (define-key map (kbd "C-a") 'hs-hide-all) (define-key map (kbd "C-S-a") 'hs-show-all) (define-key map (kbd "C-l") 'hs-hide-level) (define-key map (kbd "C-c") 'hs-toggle-hiding) (define-key map (kbd "<BLAH-C-2>") 'hs-minor-mode) map)) ;; Put `hs-' commands on `C-2' prefix; ;; 2 and `@' are on the same key on the keyboard. (fset 'hs-minor-mode-map hs-minor-mode-map) (global-set-key (kbd "<BLAH-C-2>") 'hs-minor-mode-map))) ;; Use `C-2 C-2' to toggle `hs-minor-mode' (global-set-key (kbd "<BLAH-C-2> <BLAH-C-2>") 'hs-minor-mode)
Apropos the remark "some C-xxx keys are problematic to generate in terminal" in the snippet above,
On gnome-terminal, with emacs -Q -nw, when I do C-h k C-1, Emacs says
1 runs the command self-insert-command (found in global-map)
On xterm, with emacs -Q when I do C-h k C-2, Emacs says
C-@ runs the command set-mark-command (found in global-map)
Similar observations can be made for "some"(?) C-M-xxx bindings. C-M-xxx is essentially M- and C-xxx and M- is emitted with ESC and if you have issues with C-xxx it shouldn't be surprising that there are issues with C-M-xxx.
Comprehensive keyboard handling in terminals is a good introduction to terminals, and with a quick glimpse one can reasonably anticipate which key sequences are going to give you problematic on the terminal Emacs.
I understand none of what I say, so take what I say with a grain of salt. But the behavioural observations I make can be independently verified. I am on Debian / sid, btw.
C-c <letter>and function keys<F5>-<F9>without modifiers - see Key Binding Conventions). Defining some to be prefix keys vastly increases the number of keybindings available at the cost of one extra keystroke.keymap)?global-map. They might not be the same in other keymaps, which override theglobal-mapin various situations. Are you asking only about overriding keys in theglobal-map? You included tagsmajor-modeandminor-mode- why? Please consider clarifying your question.