help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Multiple keymaps for a minor mode


From: Tim Johnson
Subject: Re: Multiple keymaps for a minor mode
Date: Fri, 24 Jan 2020 09:47:57 -0900
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0

On 1/23/20 9:57 AM, Tim Johnson wrote:

Using GNU Emacs 26.1 on ubuntu

;; I use the following code to establish a minor mode

(defvar tj-mode-map (make-sparse-keymap)
  "Keymap for `tj-mode'.")

;;;###autoload
(define-minor-mode tj-minor-mode
  "This minor mode enables my key settings to override conflicting modes."
  :init-value t
  :lighter " -tj-"
  :keymap tj-mode-map)

;;;###autoload
(define-globalized-minor-mode global-tj-minor-mode tj-minor-mode tj-minor-mode)

(add-to-list 'emulation-mode-map-alists `((tj-minor-mode . ,tj-mode-map)))
;; End code

I wish to separate `tj-mode-map into a number of individual mode maps that are configured by category. This would give me the advantage of using a function called

which-key--create-buffer-and-show  from the which-key package to implement a menu showing commands bound to keys by functionality or category.

the :keymap member of define-mode-map is what binds the keymap to the mode.

Can I use multiple :keymap entries, one for each keymap or must I define a minor mode for each of my custom keymaps?

Certainly the latter is doable, but I like to save keystrokes :)

No worries ... it is an easy enough pattern to follow.

cheers

--
Tim
tj49.com




reply via email to

[Prev in Thread] Current Thread [Next in Thread]