From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: joaotavora@gmail.com (=?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?=) Newsgroups: gmane.emacs.bugs Subject: bug#17192: 24.4.50; python-mode's python-electric-pair-string-delimiter inserts an extra quote Date: Sat, 05 Apr 2014 13:22:06 +0100 Message-ID: <87bnwgq841.fsf@kitaj.lan> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1396700616 19936 80.91.229.3 (5 Apr 2014 12:23:36 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 5 Apr 2014 12:23:36 +0000 (UTC) To: 17192@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Apr 05 14:23:27 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 1WWPd6-0001kJ-MI for geb-bug-gnu-emacs@m.gmane.org; Sat, 05 Apr 2014 14:23:24 +0200 Original-Received: from localhost ([::1]:54521 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WWPd6-00043h-6q for geb-bug-gnu-emacs@m.gmane.org; Sat, 05 Apr 2014 08:23:24 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:35422) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WWPcu-00043I-3y for bug-gnu-emacs@gnu.org; Sat, 05 Apr 2014 08:23:21 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WWPcl-0004ec-2z for bug-gnu-emacs@gnu.org; Sat, 05 Apr 2014 08:23:12 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:34888) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WWPck-0004eY-Vu for bug-gnu-emacs@gnu.org; Sat, 05 Apr 2014 08:23:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1WWPck-0007oz-4P for bug-gnu-emacs@gnu.org; Sat, 05 Apr 2014 08:23:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: joaotavora@gmail.com (=?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?=) Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 05 Apr 2014 12:23:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 17192 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.139670056230000 (code B ref -1); Sat, 05 Apr 2014 12:23:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 5 Apr 2014 12:22:42 +0000 Original-Received: from localhost ([127.0.0.1]:36070 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WWPcP-0007nk-NB for submit@debbugs.gnu.org; Sat, 05 Apr 2014 08:22:42 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:33527) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WWPcM-0007nV-Vy for submit@debbugs.gnu.org; Sat, 05 Apr 2014 08:22:39 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WWPcD-0004VJ-Qg for submit@debbugs.gnu.org; Sat, 05 Apr 2014 08:22:38 -0400 Original-Received: from lists.gnu.org ([2001:4830:134:3::11]:37362) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WWPcD-0004VE-NP for submit@debbugs.gnu.org; Sat, 05 Apr 2014 08:22:29 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:35112) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WWPc4-0003dj-H9 for bug-gnu-emacs@gnu.org; Sat, 05 Apr 2014 08:22:29 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WWPbv-0004Bo-AX for bug-gnu-emacs@gnu.org; Sat, 05 Apr 2014 08:22:20 -0400 Original-Received: from mail-wi0-x229.google.com ([2a00:1450:400c:c05::229]:49751) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WWPbu-00049P-VL for bug-gnu-emacs@gnu.org; Sat, 05 Apr 2014 08:22:11 -0400 Original-Received: by mail-wi0-f169.google.com with SMTP id hm4so3922370wib.4 for ; Sat, 05 Apr 2014 05:22:09 -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=jfaFWLO/Pka0xvCrRecyuPDiY8Y+Lvt0Hwklqxm446U=; b=tvIJtmblpLQvZCWaJVNZs4BVsxMqFf9bXbkLEOVH2PqeWJSfoX7Mu5pvGisWRSfHu6 hNaECr92241+rOwun5VL/JPCwxkbAPNuW7dN9yA1hvtSzP7kMvQMloKNyRwgEjFXeyQ7 dgWFxEyWMnbUq1jbbhJ+UJc1vKSpK6UZzMvjjc6v24uSy/KZv37MY9iDDehpswosx72J gWUVlU7pZo1D+Id7O1RA2oMYEruUUc81WdWZHG48PWuIEF2d/AXKubQgCHI2DjXs60Cg 6YO1BV9BG3HQRTnFsa3nDFcpkVu6BVcI6/rmhH9q9oPxzGxHkzJ5kvP5k17rqLEF5tpZ VAiA== X-Received: by 10.194.9.8 with SMTP id v8mr27388451wja.53.1396700529903; Sat, 05 Apr 2014 05:22:09 -0700 (PDT) Original-Received: from kitaj.lan.yourcompany.com (66.207.108.93.rev.vodafone.pt. [93.108.207.66]) by mx.google.com with ESMTPSA id fs4sm10635782wib.11.2014.04.05.05.22.08 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Sat, 05 Apr 2014 05:22:09 -0700 (PDT) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4.50 (gnu/linux) 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-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:87767 Archived-At: Hi maintainers, emacs -Q M-x electric-pair-mode RET M-x python-mode RET M-x erase-buffer RET ! Press double quotes (") twice Buffer contents are 7 double quotes instead of 6, with point correctly at 4. This is fixed by the patch attached. Jo=C3=A3o Using changes with id "2". Message: python-triple-quote-fixes M lisp/ChangeLog M lisp/progmodes/python.el M test/ChangeLog M test/automated/python-tests.el =3D=3D=3D modified file 'lisp/ChangeLog' --- a/lisp/ChangeLog 2014-04-05 11:15:07 +0000 +++ b/lisp/ChangeLog 2014-04-05 12:15:08 +0000 @@ -1,3 +1,8 @@ +2014-04-05 Jo=C3=A3o T=C3=A1vora + + * progmodes/python.el (python-electric-pair-string-delimiter): Fix + triple-quoting electricity. + 2014-04-04 Jo=C3=A3o T=C3=A1vora =20 * elec-pair.el: =3D=3D=3D modified file 'lisp/progmodes/python.el' --- a/lisp/progmodes/python.el 2014-04-05 11:15:07 +0000 +++ b/lisp/progmodes/python.el 2014-04-05 12:15:08 +0000 @@ -3651,8 +3651,9 @@ (let ((count 0)) (while (eq (char-before (- (point) count)) last-command-eve= nt) (cl-incf count)) - (=3D count 3))) - (save-excursion (insert (make-string 3 last-command-event))))) + (=3D count 3)) + (eq (char-after) last-command-event)) + (save-excursion (insert (make-string 2 last-command-event))))) =20 (defvar electric-indent-inhibit) =20 =3D=3D=3D modified file 'test/ChangeLog' --- a/test/ChangeLog 2014-04-05 11:15:07 +0000 +++ b/test/ChangeLog 2014-04-05 12:15:08 +0000 @@ -1,3 +1,8 @@ +2014-04-05 Jo=C3=A3o T=C3=A1vora + + * automated/python-tests.el (python-triple-quote-pairing): New test. + (python-syntax-after-python-backspace): New test. + 2014-04-04 Jo=C3=A3o T=C3=A1vora =20 * automated/electric-tests.el (define-electric-pair-test): Don't =3D=3D=3D modified file 'test/automated/python-tests.el' --- a/test/automated/python-tests.el 2014-04-05 11:15:07 +0000 +++ b/test/automated/python-tests.el 2014-04-05 12:15:08 +0000 @@ -134,6 +134,16 @@ ;;; Font-lock and syntax =20 +(ert-deftest python-syntax-after-python-backspace () + ;; `python-indent-dedent-line-backspace' garbles syntax + :expected-result :failed + (python-tests-with-temp-buffer + "\"\"\"" + (goto-char (point-max)) + (python-indent-dedent-line-backspace 1) + (should (string=3D (buffer-string) "\"\"")) + (should (null (nth 3 (syntax-ppss)))))) + ;;; Indentation =20 @@ -2696,6 +2706,9 @@ (equal (symbol-value (car ccons)) (cdr ccons))))) (kill-buffer buffer))) =20 + +;;; Electricity + (ert-deftest python-util-forward-comment-1 () (python-tests-with-temp-buffer (concat @@ -2708,6 +2721,32 @@ (python-util-forward-comment -1) (should (=3D (point) (point-min))))) =20 +(ert-deftest python-triple-quote-pairing () + (python-tests-with-temp-buffer + "\"\"\n" + (goto-char (1- (point-max))) + (let ((last-command-event ?\")) + (call-interactively 'self-insert-command)) + (should (string=3D (buffer-string) + "\"\"\"\"\"\"\n")) + (should (=3D (point) 4))) + (python-tests-with-temp-buffer + "\n" + (let ((last-command-event ?\")) + (dotimes (i 3) + (call-interactively 'self-insert-command))) + (should (string=3D (buffer-string) + "\"\"\"\"\"\"\n")) + (should (=3D (point) 4))) + (python-tests-with-temp-buffer + "\"\n\"\"\n" + (goto-char (1- (point-max))) + (let ((last-command-event ?\")) + (call-interactively 'self-insert-command)) + (should (=3D (point) (1- (point-max)))) + (should (string=3D (buffer-string) + "\"\n\"\"\"\n")))) + =20 (provide 'python-tests) =20