Emacs: Xah Fly Keys, Setup Keys for Major Mode
Setup Major Mode Custom Keys
Normally, Major Mode keys start with Ctrl+c.
You can make it so that all commands in the major mode uses a leader key sequence.
For example:
- TAB SPC → completion-at-point
- TAB a → python-shell-send-buffer
- TAB b → python-describe-at-point
- TAB c → python-shell-send-statement
- TAB d → python-eldoc-at-point
- TAB e → imenu
- TAB f → python-shell-send-file
- TAB g → run-python
- TAB h → python-shell-send-region
- TAB i → python-shell-send-string
- TAB j → python-check
- TAB k → python-shell-switch-to-shell
- TAB , → python-indent-shift-left
- TAB . → python-indent-shift-right
Example: Setup Keys for major mode
Here's the best way to do it:
- Get a list of the commands you want. You do this by first activate the major mode, then, Alt+x
describe-mode
, to list all commands of the mode. - Then, decide on a leader key to call them. i recommend Tab.
- Find the keymap name of the major mode. (look at its source code), then do as follows.
;; example of adding a leader key map to python mode (defun my-config-python-mode () "Config python-mode. Version 2024-07-06" (interactive) (progn ;; create a keymap (define-prefix-command 'my-python-leader-map) ;; add keys to it (define-key my-python-leader-map (kbd "SPC" 'completion-at-point)) (define-key my-python-leader-map (kbd "a" 'python-describe-at-point)) (define-key my-python-leader-map (kbd "b" 'python-shell-send-statement)) (define-key my-python-leader-map (kbd "c" 'python-eldoc-at-point)) (define-key my-python-leader-map (kbd "d" 'imenu)) (define-key my-python-leader-map (kbd "e" 'python-shell-send-file)) (define-key my-python-leader-map (kbd "f" 'run-python)) (define-key my-python-leader-map (kbd "g" 'python-shell-send-region)) (define-key my-python-leader-map (kbd "h" 'python-shell-send-string)) (define-key my-python-leader-map (kbd "i" 'python-check)) (define-key my-python-leader-map (kbd "j" 'python-shell-switch-to-shell)) (define-key my-python-leader-map (kbd "," 'python-indent-shift-left)) (define-key my-python-leader-map (kbd "." 'python-indent-shift-right)) ;; more here ) ;; modify the major mode key map, so that a key becomes your leader key (define-key python-mode-map (kbd "TAB") my-python-leader-map) ;; ) (when (fboundp 'python-mode) (add-hook 'python-mode-hook 'my-config-python-mode))
Setup Org-Mode Keys for Xah Fly Keys
emacs, Xah Fly Keys, customization
- Emacs: Xah Fly Keys Customization
- Emacs: Xah Fly Keys, Add Keys to Switch Mode
- Emacs: Xah Fly Keys, Add a Global Leader Key
- Emacs: Xah Fly Keys, Modify Leader Key Sequence
- Emacs: Xah Fly Keys, Setup Keys for Major Mode
- Emacs: Xah Fly Keys, Key for Org-Mode
- Emacs: Xah Fly Keys, Create a New Layout
- Emacs: Xah Fly Keys Escape Key
- Emacs: Xah Fly Keys Mode Status Indicator
- How to Make the CapsLock Key do Home Key
- Emacs: Xah Fly Keys, Emacs Daemon
- Emacs: Xah Fly Keys, How to Indent
- Emacs: Xah Fly Keys, Russian Layout