From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.bugs 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 Message-ID: References: <87fvlsq977.fsf@kitaj.lan> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1396712788 28803 80.91.229.3 (5 Apr 2014 15:46:28 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 5 Apr 2014 15:46:28 +0000 (UTC) Cc: 16981@debbugs.gnu.org, Alan Mackenzie To: joaotavora@gmail.com (=?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?=) Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Apr 05 17:46:20 2014 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1WWSnU-0005Q0-Ct for geb-bug-gnu-emacs@m.gmane.org; Sat, 05 Apr 2014 17:46:20 +0200 Original-Received: from localhost ([::1]:55045 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WWSnU-0006Sd-3A for geb-bug-gnu-emacs@m.gmane.org; Sat, 05 Apr 2014 11:46:20 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:38247) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WWSnK-0006P6-JG for bug-gnu-emacs@gnu.org; Sat, 05 Apr 2014 11:46:18 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WWSnD-00054L-4A for bug-gnu-emacs@gnu.org; Sat, 05 Apr 2014 11:46:10 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:35782) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WWSnD-00054H-25 for bug-gnu-emacs@gnu.org; Sat, 05 Apr 2014 11:46:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1WWSnC-0006P0-8g for bug-gnu-emacs@gnu.org; Sat, 05 Apr 2014 11:46:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 05 Apr 2014 15:46:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 16981 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 16981-submit@debbugs.gnu.org id=B16981.139671271624540 (code B ref 16981); Sat, 05 Apr 2014 15:46:02 +0000 Original-Received: (at 16981) by debbugs.gnu.org; 5 Apr 2014 15:45:16 +0000 Original-Received: from localhost ([127.0.0.1]:36964 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WWSmR-0006Nj-3y for submit@debbugs.gnu.org; Sat, 05 Apr 2014 11:45:15 -0400 Original-Received: from chene.dit.umontreal.ca ([132.204.246.20]:34957) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WWSmO-0006NY-GX for 16981@debbugs.gnu.org; Sat, 05 Apr 2014 11:45:13 -0400 Original-Received: from pastel.home (lechon.iro.umontreal.ca [132.204.27.242]) by chene.dit.umontreal.ca (8.14.1/8.14.1) with ESMTP id s35Fj9Ll003009; Sat, 5 Apr 2014 11:45:09 -0400 Original-Received: by pastel.home (Postfix, from userid 20848) id 5007F60125; Sat, 5 Apr 2014 11:45:09 -0400 (EDT) In-Reply-To: <87fvlsq977.fsf@kitaj.lan> ("=?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?="'s message of "Sat, 05 Apr 2014 12:58:36 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4.50 (gnu/linux) X-NAI-Spam-Flag: NO X-NAI-Spam-Threshold: 5 X-NAI-Spam-Score: 0 X-NAI-Spam-Rules: 1 Rules triggered RV4903=0 X-NAI-Spam-Version: 2.3.0.9378 : core <4903> : inlines <692> : streams <1152654> : uri <1721262> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:87769 Archived-At: >> 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