* Need help with minor-mode-map/menu-map
@ 2013-03-28 10:10 Thorsten Jolitz
2013-03-28 14:31 ` Stefan Monnier
0 siblings, 1 reply; 4+ messages in thread
From: Thorsten Jolitz @ 2013-03-28 10:10 UTC (permalink / raw)
To: help-gnu-emacs
Hi List,
I copied and adapted the following code from other libraries where
things (keybindings & menus) work, but something must have gone wrong,
neither the keybindings nor the menu works - and I just don't see where
the problem is.
It should be really easy, since its about a minor-mode with only 2
commands, thus 2 keybindings and menu-entries.
Maybe somebody could have a quick look at the code and give me a hint
where the problem might be? Thanks in advance!
(the library is here: https://github.com/tj64/outorg)
minor-mode definition:
,-----------------------------------------------------------------
| (define-minor-mode outorg-edit-mode
| "Minor mode for Org-mode buffers generated by outorg.
| There is a mode hook, and two commands:
| \\[outorg-copy-edits-and-exit] outorg-copy-edits-and-exit
| \\[outorg-save-edits-to-tmp-file] outorg-save-edits-to-tmp-file"
| nil " Outorg")
`-----------------------------------------------------------------
menu-map definition:
,---------------------------------------------------------------------
| (defvar outorg-edit-menu-map (make-sparse-keymap))
| (define-key outorg-edit-menu-map [outorg-copy-edits-and-exit]
| `(menu-item ,(purecopy "Copy and Exit") outorg-copy-edits-and-exit
| :help ,(purecopy "Copy edits to original-buffer
| and exit outorg")))
| (define-key outorg-edit-menu-map [outorg-save-edits-to-tmp-file]
| `(menu-item ,(purecopy "Save") outorg-save-edits-to-tmp-file
| :help ,(purecopy "Save edit buffer to temporary
| file in the OS tmp directory")))
`---------------------------------------------------------------------
minor-mode-map definition:
,---------------------------------------------------------
| (defvar outorg-edit-minor-mode-map (make-sparse-keymap))
| (define-key outorg-edit-minor-mode-map "\M-#"
| 'outorg-copy-edits-and-exit)
| (define-key outorg-edit-minor-mode-map "\C-x\C-s"
| 'outorg-save-edits-to-tmp-file)
| (define-key outorg-edit-minor-mode-map [menu-bar]
| (cons (purecopy "Outorg-Edit") outorg-edit-menu-map))
`---------------------------------------------------------
--
cheers,
Thorsten
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Need help with minor-mode-map/menu-map
2013-03-28 10:10 Need help with minor-mode-map/menu-map Thorsten Jolitz
@ 2013-03-28 14:31 ` Stefan Monnier
2013-03-28 17:54 ` Thorsten Jolitz
0 siblings, 1 reply; 4+ messages in thread
From: Stefan Monnier @ 2013-03-28 14:31 UTC (permalink / raw)
To: help-gnu-emacs
> | nil " Outorg")
I recommend you replace this line with
:lighter " Outorg")
> ,---------------------------------------------------------------------
> | (defvar outorg-edit-menu-map (make-sparse-keymap))
> | (define-key outorg-edit-menu-map [outorg-copy-edits-and-exit]
> | `(menu-item ,(purecopy "Copy and Exit") outorg-copy-edits-and-exit
> | :help ,(purecopy "Copy edits to original-buffer
> | and exit outorg")))
> | (define-key outorg-edit-menu-map [outorg-save-edits-to-tmp-file]
> | `(menu-item ,(purecopy "Save") outorg-save-edits-to-tmp-file
> | :help ,(purecopy "Save edit buffer to temporary
> | file in the OS tmp directory")))
> `---------------------------------------------------------------------
Here, I recommend
(defvar outorg-edit-menu-map
(let ((map (make-sparse-keymap)))
(define-key map [outorg-copy-edits-and-exit]
'(menu-item "Copy and Exit" outorg-copy-edits-and-exit
:help "Copy edits to original-buffer
and exit outorg"))
(define-key map [outorg-save-edits-to-tmp-file]
'(menu-item "Save" outorg-save-edits-to-tmp-file
:help "Save edit buffer to temporary
file in the OS tmp directory"))
map))
> ,---------------------------------------------------------
> | (defvar outorg-edit-minor-mode-map (make-sparse-keymap))
> | (define-key outorg-edit-minor-mode-map "\M-#"
> | 'outorg-copy-edits-and-exit)
> | (define-key outorg-edit-minor-mode-map "\C-x\C-s"
> | 'outorg-save-edits-to-tmp-file)
> | (define-key outorg-edit-minor-mode-map [menu-bar]
> | (cons (purecopy "Outorg-Edit") outorg-edit-menu-map))
> `---------------------------------------------------------
And here, I'd recommend the same rewrite, plus the actual fix which is
to be careful with the name: it should be outorg-edit-mode-map
(i.e. the minor mode's name plus "-map").
Stefan
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Need help with minor-mode-map/menu-map
2013-03-28 14:31 ` Stefan Monnier
@ 2013-03-28 17:54 ` Thorsten Jolitz
2013-03-29 14:48 ` Stefan Monnier
0 siblings, 1 reply; 4+ messages in thread
From: Thorsten Jolitz @ 2013-03-28 17:54 UTC (permalink / raw)
To: help-gnu-emacs
Stefan Monnier <monnier@iro.umontreal.ca> writes:
> And here, I'd recommend the same rewrite, plus the actual fix which is
> to be careful with the name: it should be outorg-edit-mode-map
> (i.e. the minor mode's name plus "-map").
thanks, I applied all that, and additionally figured out that the other
mode I copied form defined a derived minor-mode, while mine wasn't
derived, so I had to do a lot of other stuff too (minor-mode
conventions) that define-derived-mode did implicitly in the other mode.
now it works.
--
cheers,
Thorsten
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Need help with minor-mode-map/menu-map
2013-03-28 17:54 ` Thorsten Jolitz
@ 2013-03-29 14:48 ` Stefan Monnier
0 siblings, 0 replies; 4+ messages in thread
From: Stefan Monnier @ 2013-03-29 14:48 UTC (permalink / raw)
To: help-gnu-emacs
> conventions) that define-derived-mode did implicitly in the other mode.
define-derived-mode defines a *major* mode.
Stefan
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2013-03-29 14:48 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-03-28 10:10 Need help with minor-mode-map/menu-map Thorsten Jolitz
2013-03-28 14:31 ` Stefan Monnier
2013-03-28 17:54 ` Thorsten Jolitz
2013-03-29 14:48 ` Stefan Monnier
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).