[Top][All Lists]

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

bug#16981: 24.3.50; electric-pair-delete-adjacent-pairs broken in c-mode

From: Alan Mackenzie
Subject: bug#16981: 24.3.50; electric-pair-delete-adjacent-pairs broken in c-mode, python-mode, maybe-others
Date: Thu, 13 Mar 2014 22:04:33 +0000 (UTC)
User-agent: tin/2.2.0-20131224 ("Lochindaal") (UNIX) (FreeBSD/8.4-RELEASE (amd64))

Jo?o T?vora <address@hidden> wrote:
> This variable, t by default, acts when `electric-pair-mode' is enabled.

> It doesn't work in c-mode, python-mode and maybe other modes in
> emacs. In also doesn't work in other modes outside of emacs, such as
> markdown-mode.el [1]

> All these modes rebind the backspace key to a command that does some
> mode-specific action, then calls `backward-delete-char-untabify'.

> elec-pair.el does mostly the same through remapping in its
> `electric-pair-mode-map' but this binding is overriden by the
> major-mode's.

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?

> elec-pair.el remaps two other commands similarly. Here's the value of
> electric-pair-mode-map

>    (keymap
>     (remap keymap
>            (delete-backward-char . electric-pair-backward-delete-char)
>            (backward-delete-char . electric-pair-backward-delete-char)
>            (backward-delete-char-untabify
>               . electric-pair-backward-delete-char-untabify)))

> 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.

> Thanks,
> Jo?o

> [1]: http://jblevins.org/git/markdown-mode.git/plain/markdown-mode.el

Alan Mackenzie (Nuremberg, Germany).

reply via email to

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