GNU bug report logs - #17192
24.4.50; python-mode's python-electric-pair-string-delimiter inserts an extra quote

Previous Next

Package: emacs;

Reported by: joaotavora <at> gmail.com (João Távora)

Date: Sat, 5 Apr 2014 12:23:01 UTC

Severity: normal

Found in version 24.4.50

Done: joaotavora <at> gmail.com (João Távora)

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 17192 in the body.
You can then email your comments to 17192 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#17192; Package emacs. (Sat, 05 Apr 2014 12:23:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to joaotavora <at> gmail.com (João Távora):
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Sat, 05 Apr 2014 12:23:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: joaotavora <at> gmail.com (João Távora)
To: bug-gnu-emacs <at> gnu.org
Subject: 24.4.50;
 python-mode's python-electric-pair-string-delimiter inserts an extra
 quote
Date: Sat, 05 Apr 2014 13:22:06 +0100
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ão

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
=== 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ão Távora  <joaotavora <at> gmail.com>
+
+	* progmodes/python.el (python-electric-pair-string-delimiter): Fix
+	triple-quoting electricity.
+
 2014-04-04  João Távora  <joaotavora <at> gmail.com>
 
 	* elec-pair.el:

=== 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-event)
                  (cl-incf count))
-               (= count 3)))
-    (save-excursion (insert (make-string 3 last-command-event)))))
+               (= count 3))
+             (eq (char-after) last-command-event))
+    (save-excursion (insert (make-string 2 last-command-event)))))
 
 (defvar electric-indent-inhibit)
 

=== 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ão Távora  <joaotavora <at> gmail.com>
+
+	* automated/python-tests.el (python-triple-quote-pairing): New test.
+	(python-syntax-after-python-backspace): New test.
+
 2014-04-04  João Távora  <joaotavora <at> gmail.com>
 
 	* automated/electric-tests.el (define-electric-pair-test): Don't

=== 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
 
+(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= (buffer-string) "\"\""))
+    (should (null (nth 3 (syntax-ppss))))))
+
 
 ;;; Indentation
 
@@ -2696,6 +2706,9 @@
         (equal (symbol-value (car ccons)) (cdr ccons)))))
     (kill-buffer buffer)))
 
+
+;;; Electricity
+
 (ert-deftest python-util-forward-comment-1 ()
   (python-tests-with-temp-buffer
    (concat
@@ -2708,6 +2721,32 @@
    (python-util-forward-comment -1)
    (should (= (point) (point-min)))))
 
+(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= (buffer-string)
+                     "\"\"\"\"\"\"\n"))
+    (should (= (point) 4)))
+  (python-tests-with-temp-buffer
+      "\n"
+    (let ((last-command-event ?\"))
+      (dotimes (i 3)
+        (call-interactively 'self-insert-command)))
+    (should (string= (buffer-string)
+                     "\"\"\"\"\"\"\n"))
+    (should (= (point) 4)))
+  (python-tests-with-temp-buffer
+      "\"\n\"\"\n"
+    (goto-char (1- (point-max)))
+    (let ((last-command-event ?\"))
+      (call-interactively 'self-insert-command))
+    (should (= (point) (1- (point-max))))
+    (should (string= (buffer-string)
+                     "\"\n\"\"\"\n"))))
+
 
 (provide 'python-tests)
 





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#17192; Package emacs. (Sat, 05 Apr 2014 15:52:02 GMT) Full text and rfc822 format available.

Message #8 received at 17192 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> IRO.UMontreal.CA>
To: joaotavora <at> gmail.com (João Távora)
Cc: 17192 <at> debbugs.gnu.org
Subject: Re: bug#17192: 24.4.50;
 python-mode's python-electric-pair-string-delimiter inserts an extra
 quote
Date: Sat, 05 Apr 2014 11:50:59 -0400
> This is fixed by the patch attached.

Please install it in emacs-24, thank you,


        Stefan




Reply sent to joaotavora <at> gmail.com (João Távora):
You have taken responsibility. (Mon, 07 Apr 2014 00:05:05 GMT) Full text and rfc822 format available.

Notification sent to joaotavora <at> gmail.com (João Távora):
bug acknowledged by developer. (Mon, 07 Apr 2014 00:05:07 GMT) Full text and rfc822 format available.

Message #13 received at 17192-done <at> debbugs.gnu.org (full text, mbox):

From: joaotavora <at> gmail.com (João Távora)
To: Stefan Monnier <monnier <at> IRO.UMontreal.CA>
Cc: 16981-done <at> debbugs.gnu.org, 17192-done <at> debbugs.gnu.org,
 17183-done <at> debbugs.gnu.org, Alan Mackenzie <acm <at> muc.de>
Subject: Re: bug#16981: 24.3.50;
 electric-pair-delete-adjacent-pairs broken in c-mode,
 python-mode,	maybe-others
Date: Mon, 07 Apr 2014 01:04:35 +0100
Stefan Monnier <monnier <at> IRO.UMontreal.CA> 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.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Mon, 05 May 2014 11:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 10 years and 4 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.