Based on the clarifications to the question, something like this might do the trick?
(defvar my-leader-map (make-sparse-keymap)
"Prefix binding for custom things.")
(global-set-key (kbd "M-SPC") my-leader-map)
;; My global bindings go here. E.g.:
(define-key my-leader-map (kbd "C-b") 'other-window)
;; etc...
;; Default binding.
(define-key my-leader-map [t] 'my-leader-map-default)
(defun my-leader-map-default ()
"Use the binding under the C-c prefix of `current-local-map'."
(interactive)
(let ((prefix (lookup-key (current-local-map) (kbd "C-c"))))
(when (keymapp prefix)
(let ((map (make-sparse-keymap)))
(set-keymap-parent map prefix)
(define-key map [t] 'undefined)
(set-transient-map map)
(push last-command-event unread-command-events)))))
Or perhaps this, which would make the bindings more discoverable:
(defvar my-leader-map (make-sparse-keymap)
"Prefix binding for custom things.")
(global-set-key (kbd "M-SPC") my-leader-map)
;; My global bindings go here. E.g.:
(define-key my-leader-map (kbd "C-b") 'other-window)
;; etc...
(add-hook 'after-change-major-mode-hook #'my-leader-map-set-local)
(defun my-leader-map-set-local ()
"Set `current-local-map' to include C-c bindings under `my-leader-map'."
(when (current-local-map)
(let ((prefix (lookup-key (current-local-map) (kbd "C-c"))))
(when (keymapp prefix)
(use-local-map
(let ((map (make-sparse-keymap)))
(set-keymap-parent map (current-local-map))
(define-key map (kbd "M-SPC")
(make-composed-keymap my-leader-map prefix))
map))))))
You might cache and re-use the latter maps on a per-major-mode basis.
Edit: One more... this somewhere between the others, functionality-wise: C-hkM-SPC<foo> will work for local-map bindings, but M-SPCC-h will only show your custom bindings.
Caveat: I'm not 100% certain that (lookup-key prefix (vector last-input-event))
is valid for all situations.
(defvar my-leader-map (make-sparse-keymap)
"Prefix binding for custom things.")
(global-set-key (kbd "M-SPC") my-leader-map)
;; My global bindings go here. E.g.:
(define-key my-leader-map (kbd "C-b") 'other-window)
;; etc...
(define-key my-leader-map [t]
`(menu-item "" nil :filter ,#'my-leader-map-default-filter))
(defun my-leader-map-default-filter (_cmd)
"Use the binding under the C-c prefix of `current-local-map'."
(let ((prefix (lookup-key (current-local-map) (kbd "C-c"))))
(when (keymapp prefix)
(lookup-key prefix (vector last-input-event)))))
M-SPC
. Now, the local map in C mode, for example , has a binding ofC-c C-n
toc-forward-conditional
. I would like to bindM-SPC C-n
toc-forward-conditional
in C mode only; and not only that, but also all the parallel bindings, such asM-SPC C-p
toc-backward-conditional
, in a systematic way [1]. And similarly for other major modes I use. Is that more clear?C-c
prefix (and only that prefix) to also be available under theM-SPC
prefix? (And without losing the global bindings you already have underM-SPC
).