From debbugs-submit-bounces@debbugs.gnu.org Mon Mar 10 15:48:04 2014 Received: (at submit) by debbugs.gnu.org; 10 Mar 2014 19:48:04 +0000 Received: from localhost ([127.0.0.1]:60588 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WN6BA-0001JH-6W for submit@debbugs.gnu.org; Mon, 10 Mar 2014 15:48:04 -0400 Received: from eggs.gnu.org ([208.118.235.92]:36497) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WN6B7-0001Is-Ip for submit@debbugs.gnu.org; Mon, 10 Mar 2014 15:48:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WN6B1-0006uQ-TS for submit@debbugs.gnu.org; Mon, 10 Mar 2014 15:48:01 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM, T_DKIM_INVALID autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:46995) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WN6B1-0006uL-Qz for submit@debbugs.gnu.org; Mon, 10 Mar 2014 15:47:55 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38166) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WN6Aw-0002Y1-L6 for bug-gnu-emacs@gnu.org; Mon, 10 Mar 2014 15:47:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WN6Ar-0006sr-H0 for bug-gnu-emacs@gnu.org; Mon, 10 Mar 2014 15:47:50 -0400 Received: from mail-we0-x22c.google.com ([2a00:1450:400c:c03::22c]:58427) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WN6Ar-0006si-B4 for bug-gnu-emacs@gnu.org; Mon, 10 Mar 2014 15:47:45 -0400 Received: by mail-we0-f172.google.com with SMTP id t61so9330161wes.17 for ; Mon, 10 Mar 2014 12:47:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:subject:date:message-id:user-agent:mime-version :content-type:content-transfer-encoding; bh=ne3I56CF02LNhZvgWduXg7R5lkjGTbrNKkXApixGIW8=; b=d+GQn8TN+9ranc1DrIhuM1stHPAWGJYQy1UdO4kHgOjey80dkOd7nfl4LgJ4v6J0/i ysQ8ZifFaOQlAKathq2a9sC2WR3+cqRtIfQ16G9asT/+EQdyos5hTMa8Y1oyYbz2okVm n+huN/RTfhSwoYatBS62FfC/6aZZP9+zPFIoArJwtbbB1KPI0eDDx3zIOVEdixy2zFzI SYgyMNHRO+Z10+pto2nCJK3wBeasrQOPS9T5FXvkh2JqvPAPXw9qbHIdVNcXU55qMR0r fqDRwq3hfbtDe++z+i2VcjEsfFo/H0z+XjTLujlzcWk4ku85bE/ABhTAEZYNKFIyMU1Z swUA== X-Received: by 10.194.234.106 with SMTP id ud10mr34000367wjc.0.1394480864057; Mon, 10 Mar 2014 12:47:44 -0700 (PDT) Received: from BELMONTE.yourcompany.com (a81-84-241-129.static.cpe.netcabo.pt. [81.84.241.129]) by mx.google.com with ESMTPSA id dk9sm55123767wjb.4.2014.03.10.12.47.42 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 10 Mar 2014 12:47:43 -0700 (PDT) From: joaotavora@gmail.com (=?iso-8859-1?Q?Jo=E3o_T=E1vora?=) To: bug-gnu-emacs@gnu.org Subject: 24.3.50; electric-pair-delete-adjacent-pairs broken in c-mode, python-mode, maybe-others Date: Mon, 10 Mar 2014 19:47:39 +0000 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (windows-nt) MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -4.0 (----) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -4.0 (----) 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. 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. Thanks, Jo=E3o [1]: http://jblevins.org/git/markdown-mode.git/plain/markdown-mode.el From debbugs-submit-bounces@debbugs.gnu.org Thu Mar 13 18:11:38 2014 Received: (at submit) by debbugs.gnu.org; 13 Mar 2014 22:11:38 +0000 Received: from localhost ([127.0.0.1]:36214 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WODqk-0004mB-4Z for submit@debbugs.gnu.org; Thu, 13 Mar 2014 18:11:38 -0400 Received: from eggs.gnu.org ([208.118.235.92]:37482) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WODqh-0004m2-DJ for submit@debbugs.gnu.org; Thu, 13 Mar 2014 18:11:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WODqa-0003oL-QM for submit@debbugs.gnu.org; Thu, 13 Mar 2014 18:11:35 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50 autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:59149) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WODqa-0003oF-NR for submit@debbugs.gnu.org; Thu, 13 Mar 2014 18:11:28 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39156) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WODqU-0004A0-LE for bug-gnu-emacs@gnu.org; Thu, 13 Mar 2014 18:11:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WODqO-0003mJ-Vd for bug-gnu-emacs@gnu.org; Thu, 13 Mar 2014 18:11:22 -0400 Received: from xvm-90.mit.edu ([18.181.2.90]:58159 helo=mod-relay.xvm.mit.edu) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WODqO-0003mF-Rp for bug-gnu-emacs@gnu.org; Thu, 13 Mar 2014 18:11:16 -0400 Received: by mod-relay.xvm.mit.edu (Postfix) id 72EB31EDF7; Thu, 13 Mar 2014 18:11:15 -0400 (EDT) Delivered-To: gnu-emacs-bug@moderators.isc.org Received: from mail.muc.de (colin.muc.de [193.149.48.1]) by mod-relay.xvm.mit.edu (Postfix) with ESMTP id 13BBD1EDCA for ; Thu, 13 Mar 2014 18:11:14 -0400 (EDT) Received: (qmail 27647 invoked by uid 8); 13 Mar 2014 22:04:33 -0000 To: gnu-emacs-bug@moderators.isc.org Path: not-for-mail From: Alan Mackenzie Newsgroups: gnu.emacs.bug Subject: Re: 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) Organization: muc.de e.V. Lines: 45 Message-ID: References: NNTP-Posting-Host: news.muc.de X-Trace: colin.muc.de 1394748273 27645 193.149.48.2 (13 Mar 2014 22:04:33 GMT) X-Complaints-To: news-admin@muc.de NNTP-Posting-Date: Thu, 13 Mar 2014 22:04:33 +0000 (UTC) User-Agent: tin/2.2.0-20131224 ("Lochindaal") (UNIX) (FreeBSD/8.4-RELEASE (amd64)) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -4.3 (----) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -4.3 (----) Jo?o T?vora 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). From debbugs-submit-bounces@debbugs.gnu.org Sat Apr 05 07:58:45 2014 Received: (at 16981) by debbugs.gnu.org; 5 Apr 2014 11:58:45 +0000 Received: from localhost ([127.0.0.1]:36029 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WWPFE-00074s-Cl for submit@debbugs.gnu.org; Sat, 05 Apr 2014 07:58:45 -0400 Received: from mail-we0-f174.google.com ([74.125.82.174]:35357) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WWPFB-00074i-90 for 16981@debbugs.gnu.org; Sat, 05 Apr 2014 07:58:42 -0400 Received: by mail-we0-f174.google.com with SMTP id t60so4505097wes.5 for <16981@debbugs.gnu.org>; Sat, 05 Apr 2014 04:58:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:in-reply-to:references:user-agent:date :message-id:mime-version:content-type; bh=rgHLfe7GrWFPThBtW/y1Il4CY+uVPWGpTZ0ZE6jMweU=; b=qlGRWyDhk2Uc4sVTmCwpxOLGJxiowfGNbW+eapOmd7vOYXKalfYvZ6nZNlug7YaGQk O2dCSHqYq+6XeS92iHnFQ2L9Bn0oMEtTsA3H1JDFQFinGV2o2Q5TIkxI3fQJMzHAgOdV AXzi6OjGMkxGlL4+1ATLsojSh6mER1IAgr0yWiPKEFZrl0BuMXCpdYz6P46GfTAAmt9O jYQL1o9lCHZ95UsJc4ykHbNVJpU/u1UgP9h/mwJFWc+Iq8o5mUObNElTnuRSZNCWvP8B +uV7VENdm914vnDGbxCpZAX3IeRcB1fh97/GvOU0I2Zhw6WgnBQGVxEfSPJHybIlIkFP TUJA== X-Received: by 10.180.184.167 with SMTP id ev7mr11545608wic.55.1396699120285; Sat, 05 Apr 2014 04:58:40 -0700 (PDT) Received: from kitaj.lan.yourcompany.com (66.207.108.93.rev.vodafone.pt. [93.108.207.66]) by mx.google.com with ESMTPSA id bx16sm6678714wib.13.2014.04.05.04.58.38 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Sat, 05 Apr 2014 04:58:39 -0700 (PDT) From: joaotavora@gmail.com (=?utf-8?B?Sm/Do28gVMOhdm9yYQ==?=) To: Alan Mackenzie Subject: Re: bug#16981: 24.3.50; electric-pair-delete-adjacent-pairs broken in c-mode, python-mode, maybe-others In-Reply-To: (Alan Mackenzie's message of "Thu, 13 Mar 2014 22:04:33 +0000 (UTC)") References: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4.50 (gnu/linux) Date: Sat, 05 Apr 2014 12:58:36 +0100 Message-ID: <87fvlsq977.fsf@kitaj.lan> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 16981 Cc: 16981@debbugs.gnu.org, monnier@iro.umontreal.ca X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.7 (/) Hi Alan, Sorry for the delay, I only check emacs-devel regularly, do cc me next time please if you remember. > 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. Probably has to do with remapping and translation. But if it were the other way around, you'd probably be reporting the bug :-) so it doesn't matter. >> 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. Yes, I think so too. Or both can use a (possibly excessively complicated) system of backspace-related hooks. Advice would probably work too, but do we want that in emacs? Stefan, when you suggested the rebinding originally, was it with any particular concern in mind? Why not this, just the single `delete-backward-char-before-hook'. Seems to work. Maybe also add a "don't use this in programs" to `delete-backward-char'... === modified file 'lisp/elec-pair.el' *** lisp/elec-pair.el 2014-04-04 23:31:02 +0000 --- lisp/elec-pair.el 2014-04-05 11:28:42 +0000 *************** *** 166,176 **** quotes or comments. If lookup fails here, `electric-pair-text-pairs' will be considered.") ! (defun electric-pair-backward-delete-char (n &optional killflag untabify) ! "Delete characters backward, and maybe also two adjacent paired delimiters. ! ! Remaining behavior is given by `backward-delete-char' or, if UNTABIFY is ! non-nil, `backward-delete-char-untabify'." (interactive "*p\nP") (let* ((prev (char-before)) (next (char-after)) --- 166,173 ---- quotes or comments. If lookup fails here, `electric-pair-text-pairs' will be considered.") ! (defun electric-pair-delete-pair-maybe (killflag) ! "Forward-delete pair of soon-to-be-deleted char before point." (interactive "*p\nP") (let* ((prev (char-before)) (next (char-after)) *************** *** 184,200 **** electric-pair-delete-adjacent-pairs) (memq syntax '(?\( ?\" ?\$)) (eq pair next)) ! (delete-char 1 killflag)) ! (if untabify ! (backward-delete-char-untabify n killflag) ! (backward-delete-char n killflag)))) ! ! (defun electric-pair-backward-delete-char-untabify (n &optional killflag) ! "Delete characters backward, and maybe also two adjacent paired delimiters. ! Remaining behavior is given by `backward-delete-char-untabify'." ! (interactive "*p\nP") ! (electric-pair-backward-delete-char n killflag t)) (defun electric-pair-conservative-inhibit (char) (or --- 181,189 ---- electric-pair-delete-adjacent-pairs) (memq syntax '(?\( ?\" ?\$)) (eq pair next)) ! (delete-char 1 killflag)))) ! (add-hook 'delete-backward-char-before-hook 'electric-pair-delete-pair-maybe) (defun electric-pair-conservative-inhibit (char) (or *************** *** 546,562 **** (memq (car (electric-pair-syntax-info last-command-event)) '(?\( ?\) ?\" ?\$)))) - (defvar electric-pair-mode-map - (let ((map (make-sparse-keymap))) - (define-key map [remap backward-delete-char-untabify] - 'electric-pair-backward-delete-char-untabify) - (define-key map [remap backward-delete-char] - 'electric-pair-backward-delete-char) - (define-key map [remap delete-backward-char] - 'electric-pair-backward-delete-char) - map) - "Keymap used by `electric-pair-mode'.") - ;;;###autoload (define-minor-mode electric-pair-mode "Toggle automatic parens pairing (Electric Pair mode). --- 535,540 ---- === modified file 'lisp/simple.el' *** lisp/simple.el 2014-04-02 15:14:50 +0000 --- lisp/simple.el 2014-04-05 11:27:17 +0000 *************** *** 949,954 **** --- 949,959 ---- is undefined. If DELETE is nil, just return the content as a string. If anything else, delete the region and return its content as a string.") + (defvar delete-backward-char-before-hook nil + "Hook run just before `delete-backward-char' actually deletes. + Each function in this list is passed the KILLFLAG arg to + `delete-backward-char' call.") + (defun delete-backward-char (n &optional killflag) "Delete the previous N characters (following if N is negative). If Transient Mark mode is enabled, the mark is active, and N is 1, *************** *** 984,990 **** (save-excursion (insert-char ?\s (- ocol (current-column)) nil)))) ;; Otherwise, do simple deletion. ! (t (delete-char (- n) killflag)))) (defun delete-forward-char (n &optional killflag) "Delete the following N characters (previous if N is negative). --- 989,997 ---- (save-excursion (insert-char ?\s (- ocol (current-column)) nil)))) ;; Otherwise, do simple deletion. ! (t ! (run-hook-with-args 'delete-backward-char-before-hook killflag) ! (delete-char (- n) killflag)))) (defun delete-forward-char (n &optional killflag) "Delete the following N characters (previous if N is negative). From debbugs-submit-bounces@debbugs.gnu.org Sat Apr 05 11:45:16 2014 Received: (at 16981) by debbugs.gnu.org; 5 Apr 2014 15:45:16 +0000 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 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 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 Received: by pastel.home (Postfix, from userid 20848) id 5007F60125; Sat, 5 Apr 2014 11:45:09 -0400 (EDT) From: Stefan Monnier To: joaotavora@gmail.com (=?windows-1252?B?Sm/jbyBU4XZvcmE=?=) Subject: Re: bug#16981: 24.3.50; electric-pair-delete-adjacent-pairs broken in c-mode, python-mode, maybe-others Message-ID: References: <87fvlsq977.fsf@kitaj.lan> Date: Sat, 05 Apr 2014 11:45:09 -0400 In-Reply-To: <87fvlsq977.fsf@kitaj.lan> (=?windows-1252?Q?=22Jo=E3o_T=E1vo?= =?windows-1252?Q?ra=22'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) MIME-Version: 1.0 Content-Type: text/plain 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-Spam-Score: -1.9 (-) X-Debbugs-Envelope-To: 16981 Cc: 16981@debbugs.gnu.org, Alan Mackenzie X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.9 (-) >> 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 From debbugs-submit-bounces@debbugs.gnu.org Sat Apr 05 21:51:14 2014 Received: (at 16981) by debbugs.gnu.org; 6 Apr 2014 01:51:14 +0000 Received: from localhost ([127.0.0.1]:37255 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WWcEs-0007C9-Dd for submit@debbugs.gnu.org; Sat, 05 Apr 2014 21:51:14 -0400 Received: from mail-wi0-f177.google.com ([209.85.212.177]:48231) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WWcEq-0007Bz-7k for 16981@debbugs.gnu.org; Sat, 05 Apr 2014 21:51:12 -0400 Received: by mail-wi0-f177.google.com with SMTP id cc10so3197690wib.10 for <16981@debbugs.gnu.org>; Sat, 05 Apr 2014 18:51:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-type; bh=ggdWwaZw5PGcwllhmveXe05e1958SCSZgiOe7kRq8qk=; b=kYVth+gD2keX6D/RC2/ypkSga/3Fhp7YPrNqQtcJ05ouuZbQFh7/XlYUtaBzq20kyY FhP3zL0W6D4wVDIGC9AORalKuHZKBOkIxmDod71gOFkjlrHJsHnU10aFTxY+8oajWsp3 Dc2ZP/MiRF2kZg4mn+9pxmqFW28m7xhiKvPrP9Hvkas88dRt30hR3nBRs0YvkLDHTByE +lxCykpJR8buGB5/iqXZL+7dNPih6Ly0Juy4dd5qW51ey/NXzd9gUm/uSRILJe7ifiin J0mj13keg49KBwhOTHh6s8SnMzUyv+W73fYg/625xxMF/uRcIjqc77stqnCHGMM2DtFe xhhw== X-Received: by 10.180.78.225 with SMTP id e1mr6944522wix.17.1396749071029; Sat, 05 Apr 2014 18:51:11 -0700 (PDT) Received: from kitaj.lan.yourcompany.com (66.207.108.93.rev.vodafone.pt. [93.108.207.66]) by mx.google.com with ESMTPSA id km2sm19417028wjb.13.2014.04.05.18.51.09 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Sat, 05 Apr 2014 18:51:10 -0700 (PDT) From: joaotavora@gmail.com (=?utf-8?B?Sm/Do28gVMOhdm9yYQ==?=) To: Stefan Monnier Subject: Re: bug#16981: 24.3.50; electric-pair-delete-adjacent-pairs broken in c-mode, python-mode, maybe-others References: <87fvlsq977.fsf@kitaj.lan> Date: Sun, 06 Apr 2014 02:51:07 +0100 In-Reply-To: (Stefan Monnier's message of "Sat, 05 Apr 2014 11:45:09 -0400") Message-ID: <877g738buc.fsf@kitaj.lan> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 16981 Cc: 16981@debbugs.gnu.org, Alan Mackenzie X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.7 (/) Stefan Monnier writes: >>> There's something funny going on here. A minor mode's keymap should >> You're right, but I can't figure out what. > That's because it's how remapping is works: first we lookup the key > So the local-map and global-map's normal bindings take precedence over the > minor-map's remapping. Yeah that's it I remembered that this afternoon. > (define-key electric-pair-mode-map "\177" > `(menu-item "" electric-pair-delete-pair > :filter > electric-pair-delete-adjacent-pairs) > cmd)))))) Aha, the famed :filter trick I had heard about. Looks good enough while we wait for that multiple-commands-per-keybinding refactoring. Not as clean as remapping, but probably good enough, and it's arguable we want this on any other key than backspace. Hmmm now I remember that's it's even harder than defadvice to find the extra code, docstring-wise I mean. How would a hacker discover we're using the filter trick. describe-key doesn't help. . Anyway should I install it? To emacs-24 only? I need a little help VC-wise: - I got two commits that are in trunk, r116926 and r116940, and should be in (cherry-picked to?) emacs-24 - Three different fixes (bugs 16981,17192 and 17183) not yet pushed that I think you want me to only push to emacs-24, since that will be merged back to trunk later. Is this correct? I also don't know much bzr to do this, especially the first item. Is there a wiki as clear as BzrForEmacsDevs on this particular workflow? I just did a "bzr switch emacs-24" from what I believe to be a heavyweight checkout or something. It seems to have worked. From debbugs-submit-bounces@debbugs.gnu.org Sun Apr 06 08:48:27 2014 Received: (at 16981) by debbugs.gnu.org; 6 Apr 2014 12:48:27 +0000 Received: from localhost ([127.0.0.1]:37497 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WWmUs-0004ag-Fd for submit@debbugs.gnu.org; Sun, 06 Apr 2014 08:48:26 -0400 Received: from pruche.dit.umontreal.ca ([132.204.246.22]:52934) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WWmUq-0004aW-BO for 16981@debbugs.gnu.org; Sun, 06 Apr 2014 08:48:24 -0400 Received: from fmsmemgm.homelinux.net (lechon.iro.umontreal.ca [132.204.27.242]) by pruche.dit.umontreal.ca (8.14.1/8.14.1) with ESMTP id s36CmLIb031791; Sun, 6 Apr 2014 08:48:22 -0400 Received: by fmsmemgm.homelinux.net (Postfix, from userid 20848) id 96F2CAE1A3; Sun, 6 Apr 2014 08:48:21 -0400 (EDT) From: Stefan Monnier To: joaotavora@gmail.com (=?windows-1252?B?Sm/jbyBU4XZvcmE=?=) Subject: Re: bug#16981: 24.3.50; electric-pair-delete-adjacent-pairs broken in c-mode, python-mode, maybe-others Message-ID: References: <87fvlsq977.fsf@kitaj.lan> <877g738buc.fsf@kitaj.lan> Date: Sun, 06 Apr 2014 08:48:21 -0400 In-Reply-To: <877g738buc.fsf@kitaj.lan> (=?windows-1252?Q?=22Jo=E3o_T=E1vo?= =?windows-1252?Q?ra=22's?= message of "Sun, 06 Apr 2014 02:51:07 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-NAI-Spam-Flag: NO X-NAI-Spam-Threshold: 5 X-NAI-Spam-Score: 0 X-NAI-Spam-Rules: 1 Rules triggered RV4904=0 X-NAI-Spam-Version: 2.3.0.9378 : core <4904> : inlines <693> : streams <1152966> : uri <1722059> X-Spam-Score: -1.6 (-) X-Debbugs-Envelope-To: 16981 Cc: 16981@debbugs.gnu.org, Alan Mackenzie X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.6 (-) > Hmmm now I remember that's it's even harder than defadvice to find the > extra code, docstring-wise I mean. How would a hacker discover we're > using the filter trick. describe-key doesn't help. . Right. C-h k will give you the binding, but only when electric-pair-delete-pair would be run. To make this trick more widely usable, we'd need to change C-h k so that it shows all "possible bindings". > Anyway should I install it? If that's OK with you, yes. > To emacs-24 only? Yes. > - I got two commits that are in trunk, r116926 and r116940, and should > be in (cherry-picked to?) emacs-24 Just take the corresponding diffs (IIRC you can use "bzr merge -r116925..r116926 .../trunk" for that) and commit them into emacs-24. Bzr doesn't really know about cherry picking, but if you put "backported" into your commit message, our bzrmerge.el script will know that this commit is already in the trunk and will know how to avoid the corresponding conflicts when merging emacs-24 back into trunk. > - Three different fixes (bugs 16981,17192 and 17183) not yet pushed that > I think you want me to only push to emacs-24, since that will be merged > back to trunk later. Right. Stefan From debbugs-submit-bounces@debbugs.gnu.org Sun Apr 06 11:09:08 2014 Received: (at 16981) by debbugs.gnu.org; 6 Apr 2014 15:09:08 +0000 Received: from localhost ([127.0.0.1]:38200 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WWoh1-0000Hu-IT for submit@debbugs.gnu.org; Sun, 06 Apr 2014 11:09:07 -0400 Received: from mail-qc0-f169.google.com ([209.85.216.169]:42151) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WWogy-0000HN-Pw for 16981@debbugs.gnu.org; Sun, 06 Apr 2014 11:09:05 -0400 Received: by mail-qc0-f169.google.com with SMTP id i17so5479413qcy.28 for <16981@debbugs.gnu.org>; Sun, 06 Apr 2014 08:08:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=7kyRWz+Bddv3T1XhdEZX1oPdHIULCA9JDKshJkRiOCg=; b=Vl6eIURG+BwDrv0X60wqT7awXYY69NPs0QQZXUvDiWjlSai68ied8njYVtJ4leyPtb dgG2JQfxZkVLo+D/dycv9QLnMkuATQhEoCZz23ihWjENqQqrJcS1NX2q2mNFpH3sdvNb PsY3vYYZ9iv1wUItEgqTOLQCkdCciGN8Ildfw1P9vIVIz+BU0lXoPtYgHhBruUveQ7YL E+IAmHGipwrM9NxSz4Xijf+vk/zNwCXDZNlzoKTPMUY2eR8bxbMHUHvl6cyorZvmQsGQ 9OB1xzAaIz0wZgW0vGunN18wy732YVEOh9J06reU5gohjJpU1YGVatUDLhGMaOR0ME/f J1/w== X-Received: by 10.224.63.138 with SMTP id b10mr2970646qai.79.1396796939413; Sun, 06 Apr 2014 08:08:59 -0700 (PDT) MIME-Version: 1.0 Received: by 10.229.46.199 with HTTP; Sun, 6 Apr 2014 08:08:39 -0700 (PDT) In-Reply-To: References: <87fvlsq977.fsf@kitaj.lan> <877g738buc.fsf@kitaj.lan> From: =?ISO-8859-1?Q?Jo=E3o_T=E1vora?= Date: Sun, 6 Apr 2014 16:08:39 +0100 Message-ID: Subject: Re: bug#16981: 24.3.50; electric-pair-delete-adjacent-pairs broken in c-mode, python-mode, maybe-others To: Stefan Monnier Content-Type: text/plain; charset=ISO-8859-1 X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 16981 Cc: 16981@debbugs.gnu.org, Alan Mackenzie X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.7 (/) On Sun, Apr 6, 2014 at 1:48 PM, Stefan Monnier wrote: >> Hmmm now I remember that's it's even harder than defadvice to find the >> extra code, docstring-wise I mean. How would a hacker discover we're >> using the filter trick. describe-key doesn't help. . > > Right. C-h k will give you the binding, but only when > electric-pair-delete-pair would be run. To make this trick more widely > usable, we'd need to change C-h k so that it shows all "possible bindings". Yes, I realized that later on. In the meantime, we can use the trick that yasnippet uses (documentation-function if I'm not mistaken) to show what other command electric-pair-delete-pair is shadowing in that situation. >> Anyway should I install it? > If that's OK with you, yes. Yes, I think it's cleaner than all alternatives, unless add-function is the way to go for these situations. > Bzr doesn't really know about cherry picking, but if you put > "backported" into your commit message, our bzrmerge.el script > will know that this commit is already in the trunk and will know how to > avoid the corresponding conflicts when merging emacs-24 back into trunk. Alright, I'll include "backported from trunk, revs x and y". From debbugs-submit-bounces@debbugs.gnu.org Sun Apr 06 20:04:55 2014 Received: (at 16981-done) by debbugs.gnu.org; 7 Apr 2014 00:04:55 +0000 Received: from localhost ([127.0.0.1]:38561 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WWx3W-00025n-Ta for submit@debbugs.gnu.org; Sun, 06 Apr 2014 20:04:55 -0400 Received: from mail-wg0-f43.google.com ([74.125.82.43]:33343) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WWx3T-00025L-8i; Sun, 06 Apr 2014 20:04:52 -0400 Received: by mail-wg0-f43.google.com with SMTP id x13so5992738wgg.2 for ; Sun, 06 Apr 2014 17:04:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-type; bh=Zx2qekBV8sPYx7fM6cK+4QhJ4OingccPvNH4jrM/usQ=; b=pSdJ/vIDGrj6myp99Yc0NPZFdSohgM+oF/hrOfrkDY/r2VyOOjLMU/y9HxntNLpvPx oCxyYUw09+ugwoa9i6cfZYQADW8KmH4EDr9xDocjOn+w/CLacbIkEvGsi/nrO5/Zx4je 1lGMvb7XCfPZ4h3xiilWkKCN463MgGYq8smRtUGjgDO2VnDp6qLnVhl00ZB0Oel+fC01 TcMZxLj2EsuK/QdBnZi+AFhlX9j34z10Oo0oKXt1VZVbfFoL1iFT01Jyk1TEx226KD6u BOFwwF+IHC6kJOHPp89KDIQKdP6l9cJc7OnnnDEM1MKC1zKuYMk0gVduS5t0fPtBpoO1 4pZg== X-Received: by 10.194.201.73 with SMTP id jy9mr38335777wjc.51.1396829087339; Sun, 06 Apr 2014 17:04:47 -0700 (PDT) Received: from kitaj.lan.yourcompany.com (66.207.108.93.rev.vodafone.pt. [93.108.207.66]) by mx.google.com with ESMTPSA id hi1sm23834161wjb.17.2014.04.06.17.04.45 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Sun, 06 Apr 2014 17:04:46 -0700 (PDT) From: joaotavora@gmail.com (=?utf-8?B?Sm/Do28gVMOhdm9yYQ==?=) To: Stefan Monnier Subject: Re: bug#16981: 24.3.50; electric-pair-delete-adjacent-pairs broken in c-mode, python-mode, maybe-others References: <87fvlsq977.fsf@kitaj.lan> <877g738buc.fsf@kitaj.lan> Date: Mon, 07 Apr 2014 01:04:35 +0100 In-Reply-To: (Stefan Monnier's message of "Sun, 06 Apr 2014 08:48:21 -0400") Message-ID: <87zjjyovho.fsf@kitaj.lan> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 16981-done Cc: 16981-done@debbugs.gnu.org, 17192-done@debbugs.gnu.org, 17183-done@debbugs.gnu.org, Alan Mackenzie X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.7 (/) Stefan Monnier writes: > Just take the corresponding diffs (IIRC you can use > "bzr merge -r116925..r116926 .../trunk" for that) and commit them into > emacs-24. > > Bzr doesn't really know about cherry picking, but if you put > "backported" into your commit message, our bzrmerge.el script > will know that this commit is already in the trunk and will know how to > avoid the corresponding conflicts when merging emacs-24 back into trunk. > >> - Three different fixes (bugs 16981,17192 and 17183) not yet pushed that >> I think you want me to only push to emacs-24, since that will be merged >> back to trunk later. > > Right. These three I did successfully, but failed miserably in the backporting. Oh git where art thou... Now I'm downloading a new repo (with sharing properly setup hopefully), since I must have done something that messed up my bzr conf, apparently I shouldn't have moved my repo dir. Should be done tomorrow morning, so I'll backport r116926 and r116940 then. From unknown Wed Jun 18 23:06:00 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Mon, 05 May 2014 11:24:04 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator