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

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

Re: How to define minor-mode keybindings conditional on buffer's major-m


From: Thorsten Jolitz
Subject: Re: How to define minor-mode keybindings conditional on buffer's major-mode?
Date: Sat, 05 Oct 2013 10:03:07 +0200
User-agent: Gnus/5.130002 (Ma Gnus v0.2) Emacs/24.3 (gnu/linux)

Stefan Monnier <address@hidden> writes:

>> so, is it as simple as putting something like this
>
>> ,----------------------------------------------
>> | (progn
>> | (add-to-list 'minor-mode-overriding-map-alist
>> |  (cons 'major-mode-A A-specific-keymap))
>> | (add-to-list 'minor-mode-overriding-map-alist
>> |  (cons 'major-mode-B B-specific-keymap)) )
>> `----------------------------------------------
>
> No, you'd put
>
>    (add-to-list 'minor-mode-overriding-map-alist
>        (cons 'my-minor-mode (if (eq major-mode 'xyz-mode)
>                                 xyz-specific-map
>                               other-minor-map)))
>
> in your minor mode function.  Or
>
>    (when (eq major-mode 'xyz-mode)
>      (add-to-list 'minor-mode-overriding-map-alist
>          (cons 'my-minor-mode xyz-specific-map)))

Thanks, that works - the doc for 'minor-mode-overriding-map-alist' is
actually a bit sparse (or I'm a bit thick ;)

BTW - I just sent a patch (not yet accepted and applied at the time of
this writing) to the emacs-w3m maintainer that adds functionality to the
textarea section of w3m-form.el - which opens a dedicated, minimal size
text-mode edit buffer for the content of a html textarea by default -
for editing textareas containing text in Org-mode syntax in a
(full-size) Org-mode edit buffer.

You can use `w3m-form-textarea-toggle-major-mode' to toggle between
'text-mode and 'org-mode as major modes for the edit buffer. Since the
original keybindings for 'text-mode clash with important Org-mode
keybindings, a specialised keymap is activated for the 'org-mode case. 

This makes emacs-w3m a very good Emacs UI for interactive web apps based
on Org-mode markup syntax - to be announced soon, I hope. 

-- 
cheers,
Thorsten




reply via email to

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