I am writing an elisp function that constantly associates a given key with a given command in the current key map of the main mode. For instance,
(define-key python-mode-map [C-f1] 'python-describe-symbol)
The command and key sequence are collected interactively from the user. However, I am having trouble creating a KEYMAP name (for example, "python-mode-map") that matches the current main mode.
I tried the function (current-local-map), but this function returns the keymap object itself, not its name.
I understand that many basic layouts of mode keys are named according to the convention '' main-mode-name '-mode-map', however this is not always the case (e.g. python-shell-map), so I would prefer that my the code did not rely on this convention. (I'm not even sure how to access the name of the current main mode).
(define-key ...) should be added to the initialization file, therefore, although
(define-key (current-local-map) key command)
seems to work, it doesn't work like code in the initialization file.
source share