unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* How to define a prefixed map for a minor mode?
@ 2020-06-07  6:50 Marcin Borkowski
  2020-06-07  7:54 ` Jamie Beardslee
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Marcin Borkowski @ 2020-06-07  6:50 UTC (permalink / raw)
  To: Help Gnu Emacs mailing list

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
      (ecat-highlight-this-sentence)
    (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?

TIA,

-- 
Marcin Borkowski
http://mbork.pl



^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2020-06-08 11:23 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-06-07  6:50 How to define a prefixed map for a minor mode? Marcin Borkowski
2020-06-07  7:54 ` Jamie Beardslee
2020-06-07 20:45   ` Marcin Borkowski
2020-06-07  7:59 ` Michael Heerdegen
2020-06-07  8:16   ` Michael Heerdegen
2020-06-07 20:45     ` Marcin Borkowski
2020-06-08 11:23       ` Michael Heerdegen
2020-06-07 20:44   ` Marcin Borkowski
2020-06-07 10:18 ` Joost Kremers

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).