From: Stefan Monnier <monnier@IRO.UMontreal.CA>
To: joaotavora@gmail.com (João Távora)
Cc: 16981@debbugs.gnu.org, Alan Mackenzie <acm@muc.de>
Subject: bug#16981: 24.3.50; electric-pair-delete-adjacent-pairs broken in c-mode, python-mode, maybe-others
Date: Sat, 05 Apr 2014 11:45:09 -0400 [thread overview]
Message-ID: <jwvioqnpzdg.fsf-monnier+emacsbugs@gnu.org> (raw)
In-Reply-To: <87fvlsq977.fsf@kitaj.lan> ("João Távora"'s message of "Sat, 05 Apr 2014 12:58:36 +0100")
>> There's something funny going on here. A minor mode's keymap should
>> normally take precedence over the major mode's keymap. (See the page
>> "Searching Keymaps" in the Elisp manual.) So why is electric-pair-mode's
>> keymap being overridden by CC Mode's here?
> You're right, but I can't figure out what.
That's because it's how remapping is works: first we lookup the key
(minor-maps, local-map, global-map), then we lookup the command to see
if it's remapped (minor-maps, local-map, global-map).
So the local-map and global-map's normal bindings take precedence over the
minor-map's remapping.
>>> Perhaps a hook in `backward-delete-char' is in order. Or the other major
>>> modes can find other ways to overload the backspace key.
>> I would say it's legitimate for a major mode to bind the backspace key, but
>> it's more questionable for a minor mode to do the same. Perhaps the minor
>> mode really ought to use defadvice rather than rebinding the key.
How 'bout
(define-key electric-pair-mode-map "\177"
`(menu-item "" electric-pair-delete-pair
:filter
,(lambda (cmd)
(let* ((prev (char-before))
(next (char-after))
(syntax-info (and prev
(electric-pair-syntax-info prev)))
(syntax (car syntax-info))
(pair (cadr syntax-info)))
(and next pair
(memq syntax '(?\( ?\" ?\$))
(eq pair next)
(if (functionp electric-pair-delete-adjacent-pairs)
(funcall electric-pair-delete-adjacent-pairs)
electric-pair-delete-adjacent-pairs)
cmd))))))
-- Stefan
next prev parent reply other threads:[~2014-04-05 15:45 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <mailman.16921.1394480964.10748.bug-gnu-emacs@gnu.org>
2014-03-10 19:47 ` bug#16981: 24.3.50; electric-pair-delete-adjacent-pairs broken in c-mode, python-mode, maybe-others João Távora
2014-03-13 22:04 ` Alan Mackenzie
2014-03-18 1:56 ` bug#16959: " Stefan
2014-03-20 0:33 ` Florian Beck
2014-03-21 21:47 ` Stefan
2014-03-25 17:38 ` Florian Beck
2014-03-26 0:34 ` Stefan Monnier
2014-04-05 11:58 ` João Távora
2014-04-05 15:45 ` Stefan Monnier [this message]
2014-04-06 1:51 ` João Távora
2014-04-06 12:48 ` Stefan Monnier
2014-04-06 15:08 ` João Távora
2014-04-07 0:04 ` João Távora
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=jwvioqnpzdg.fsf-monnier+emacsbugs@gnu.org \
--to=monnier@iro.umontreal.ca \
--cc=16981@debbugs.gnu.org \
--cc=acm@muc.de \
--cc=joaotavora@gmail.com \
/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.