From: Daimrod <daimrod@gmail.com>
To: help-gnu-emacs@gnu.org
Subject: Re: view-mode keymap
Date: Thu, 03 Jan 2013 12:10:46 +0100 [thread overview]
Message-ID: <87y5gafrnt.fsf@casa.home> (raw)
In-Reply-To: mailman.16584.1357194301.855.help-gnu-emacs@gnu.org
Jambunathan K <kjambunathan@gmail.com> writes:
> Daimrod <daimrod@gmail.com> writes:
>
>> Jambunathan K <kjambunathan@gmail.com> writes:
>>
>>> I think, `make-composed-keymap' can help here.
>>>
>>>
>>>> I like `view-mode' but it conflicts with others minor mode map (paredit
>>>> in my case).
>>>>
>>>> I would like to know if there is a better way to make a keymap that
>>>> takes precedence over the others than manipulating
>>>> `minor-mode-map-alist'.
>>>>
>>>> Here is my current implementation:
>>>>
>>>> (add-hook 'view-mode-hook
>>>> (lambda ()
>>>> ;; Makes sure `view-mode-map' is the first minor mode map
>>>> ;; available in `minor-mode-map-alist', because in case of
>>>> ;; conflicting bindings, the first one is used.
>>>> (unless (eq 'view-mode (caar minor-mode-map-alist))
>>>> (setf minor-mode-map-alist
>>>> (cons (cons 'view-mode view-mode-map)
>>>> (cl-remove 'view-mode minor-mode-map-alist
>>>> :key #'car))))))
>>
>> I've looked at it but I don't see how it can help. I don't want to
>> create a new keymap, I want `view-mode-map' to take priority over other
>> keymaps.
>
> I was hoping that something like this
>
> (use-local-map
> (make-composed-keymap view-mode-map
> (current-local-map)))
>
> will put `view-mode-map' on top of the keymap stack and thus overwrite
> paredit's bindings.
>
> I see that DEL (backspace) key is shared between view-mode and paredit.
> My little experimentation that the above snippet failst to produce the
> effect expected by me.
>
> Do you think I am reading the doc of the APIs (used above) incorrectly?
No, the problem is not the way you're building the keymap, but how
keymaps are searched.
From (info "(elisp) Searching Keymaps")
> (or (cond
> (overriding-terminal-local-map
> (FIND-IN overriding-terminal-local-map))
> (overriding-local-map
> (FIND-IN overriding-local-map))
> ((or (FIND-IN (get-char-property (point) 'keymap))
> (FIND-IN TEMP-MAP)
> (FIND-IN-ANY emulation-mode-map-alists)
> (FIND-IN-ANY minor-mode-overriding-map-alist)
> (FIND-IN-ANY minor-mode-map-alist)
> (if (get-text-property (point) 'local-map)
> (FIND-IN (get-char-property (point) 'local-map))
> (FIND-IN (current-local-map))))))
> (FIND-IN (current-global-map)))
It searches through `minor-mode-map-alist' _before_ looking at
`current-local-map'.
I could use `overriding-local-map' instead of `current-local-map' if it
was a buffer local variable. But it's not, and I'm afraid that making it
buffer local might break things in a weird way.
>>
>> I've looked at the documentation and it seems that changing the order in
>> `minor-mode-map-alist' is the only way to manage priorities between
>> keymap, because they shouldn't conflict in there first place.
--
Daimrod/Greg
next prev parent reply other threads:[~2013-01-03 11:10 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-12-31 15:04 view-mode keymap Daimrod
2012-12-31 16:15 ` Jambunathan K
[not found] ` <mailman.16432.1356970328.855.help-gnu-emacs@gnu.org>
2013-01-02 14:22 ` Daimrod
2013-01-03 6:28 ` Jambunathan K
[not found] ` <mailman.16584.1357194301.855.help-gnu-emacs@gnu.org>
2013-01-03 11:10 ` Daimrod [this message]
2013-01-03 12:21 ` Daimrod
2013-01-03 13:10 ` Eric Abrahamsen
[not found] ` <mailman.16601.1357218351.855.help-gnu-emacs@gnu.org>
2013-01-03 15:45 ` Daimrod
2013-01-02 16:43 ` Michael Heerdegen
[not found] ` <mailman.16535.1357144973.855.help-gnu-emacs@gnu.org>
2013-01-02 17:08 ` Daimrod
2013-01-03 14:43 ` William Xu
[not found] ` <mailman.16604.1357224259.855.help-gnu-emacs@gnu.org>
2013-01-03 15:44 ` Daimrod
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87y5gafrnt.fsf@casa.home \
--to=daimrod@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.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.