unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Alex Kost <alezost@gmail.com>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: help-gnu-emacs@gnu.org
Subject: Re: unexpected result with keymap inheritance
Date: Thu, 24 Nov 2016 00:23:39 +0300	[thread overview]
Message-ID: <87a8cplwkk.fsf@gmail.com> (raw)
In-Reply-To: <jwvmvgq1fps.fsf-monnier+Inbox@gnu.org> (Stefan Monnier's message of "Wed, 23 Nov 2016 08:42:42 -0500")

Stefan Monnier (2016-11-23 08:42 -0500) wrote:

>> Now what I want is just to remove "o" and "u" from
>> 'very-special-mode-map', so that my keys from 'special-mode-map' will
>> take precedence, but I can't do it, as with this:
>
> I see, yes, that makes sense.  I suggest you `M-x report-emacs-bug` and
> ask for this feature.

Thanks, but there are tons of Emacs bugs, and I wouldn't like to bother
you and other contributors with just another feature request.

>> I will get "<key> is undefined", so I have to bind my keys to the same
>> commands in this new map again:
>>
>>   (define-key very-special-mode-map (kbd "o") 'backward-char)
>>   (define-key very-special-mode-map (kbd "u") 'forward-char)
>
> That's the obvious workaround, yes.  It's not that terrible, but I agree
> it's less satisfactory.
>
> Another approach if you want these `o` and `u` bindings to apply in
> every special-mode buffer, is to do
>
>     (defvar my-special-mode-bindings-map
>         (let ((map (make-sparse-keymap)))
>           (define-key map (kbd "o") 'backward-char)
>           (define-key map (kbd "u") 'forward-char)
>           map))
>
>     (define-minor-mode my-special-mode-bindings "Docstring")
>
>     (add-hook 'special-mode-hook #'my-special-mode-bindings)
>
> so you don't have to go through every derivative of special-mode which
> rebinds those keys and unbind them in their map.

Yes, I thought about this variant some time ago, but it doesn't suit my
needs.  In reality I want something more complex than the described
example.  Like, in a couple of modes (derived from special-mode), I want
to use other commands for "o"/"u" keys, so I can bind them as usual.
But if I used a minor mode, its keys would take precedence over the
major modes, so I would have another problem.  Also I rebind many keys
in many minor modes, and these keys would surely conflict with the keys
from my minor modes that I would define as you suggest.

But thanks for your answers!  I really appreciate that you spent your
time on my question.

-- 
Alex



  reply	other threads:[~2016-11-23 21:23 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-21  0:28 unexpected result with keymap inheritance Ernest Adrogué
2016-11-21 14:12 ` Stefan Monnier
2016-11-21 17:12   ` Alex Kost
2016-11-22  2:55     ` Stefan Monnier
2016-11-22 19:07       ` Alex Kost
2016-11-23  1:12         ` Stefan Monnier
2016-11-23  9:51           ` Alex Kost
2016-11-23 13:42             ` Stefan Monnier
2016-11-23 21:23               ` Alex Kost [this message]
2016-11-24  2:20                 ` Stefan Huchler
2016-11-23 10:16           ` Ernest Adrogué
2016-11-23 15:02             ` Stefan Monnier
2016-11-22  0:30   ` Ernest Adrogué
  -- strict thread matches above, loose matches on Subject: below --
2016-11-23  5:43 Edward Flanigan
2016-11-23  9:05 ` Alex Kost
2016-11-23 14:47   ` Stefan Monnier

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=87a8cplwkk.fsf@gmail.com \
    --to=alezost@gmail.com \
    --cc=help-gnu-emacs@gnu.org \
    --cc=monnier@iro.umontreal.ca \
    /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).