unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Thorsten Jolitz <tjolitz@gmail.com>
To: help-gnu-emacs@gnu.org
Subject: Re: How to define minor-mode keybindings conditional on buffer's major-mode?
Date: Sat, 05 Oct 2013 10:03:07 +0200	[thread overview]
Message-ID: <87mwmom9fo.fsf@gmail.com> (raw)
In-Reply-To: jwv38ogd6a0.fsf-monnier+gmane.emacs.help@gnu.org

Stefan Monnier <monnier@iro.umontreal.ca> 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	other threads:[~2013-10-05  8:03 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-04 14:02 How to define minor-mode keybindings conditional on buffer's major-mode? Thorsten Jolitz
2013-10-04 14:13 ` Thorsten Jolitz
2013-10-04 14:27   ` Stefan Monnier
2013-10-04 15:28     ` Thorsten Jolitz
2013-10-04 22:26       ` Stefan Monnier
2013-10-05  8:03         ` Thorsten Jolitz [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87mwmom9fo.fsf@gmail.com \
    --to=tjolitz@gmail.com \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).