[Top][All Lists]

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

How to define a prefixed map for a minor mode?

From: Marcin Borkowski
Subject: How to define a prefixed map for a minor mode?
Date: Sun, 07 Jun 2020 08:50:48 +0200
User-agent: mu4e 1.1.0; emacs 27.0.50

Hi all,

continuing my work on a (simplistic) Emacs CAT, I want to define a minor
mode.  However, I'm stuck on defining its keymap.  I want all the
commands prefixed by e.g. `C-c .', and here's what I have:

--8<---------------cut here---------------start------------->8---
(setq ecat-basic-map (make-sparse-keymap))

(define-key ecat-basic-map (kbd "p") #'ecat-highlight-previous-sentence)
(define-key ecat-basic-map (kbd "n") #'ecat-highlight-next-sentence)
(define-key ecat-basic-map (kbd ".") #'ecat-highlight-this-sentence)

(easy-mmode-defmap ecat-mode-map
  `(((kbd "C-c .") . ecat-basic-map))
  "Keymap for `ecat-mode'.")

(define-minor-mode ecat-mode
  "Toggle Emacs CAT mode."
  :lighter " CAT"
  :keymap ecat-mode-map
  (if ecat-mode
    (delete-overlay ecat-sentence-overlay)))
--8<---------------cut here---------------end--------------->8---

Alas, this does not seem to work - after pressing `C-c .' (when the mode
is one!) I get "C-c . is undefined".

What am I doing wrong?  Is there a "canonical" method of defining
a minor mode whose bindings start with some prefix?


Marcin Borkowski

reply via email to

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