Define minor mode in Emacs

One good application of writing your own minor mode is to define a key binding for your own that can't be override by other modes.

To define a minor mode in Emacs, use define-minor-mode command, for example:

(define-minor-mode dvorak-mode
  "Navigation in Dvorak"
  :lighter " dvorak"

(provide 'dvorak-mode)

If you want to make your minor mode available globally, use define-globalized-minor-mode:

(define-globalized-minor-mode global-dvorak-mode dvorak-mode
  (lambda () (dvorak-mode 1)))

Date: 2019-02-20 Wed 00:00

Author: Huy Tran

Created: 2020-02-08 Sat 19:06