emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] emacs-24 r117279: Fix completion retrieval parsing.


From: Fabián Ezequiel Gallina
Subject: [Emacs-diffs] emacs-24 r117279: Fix completion retrieval parsing.
Date: Sat, 21 Jun 2014 14:15:15 +0000
User-agent: Bazaar (2.6b2)

------------------------------------------------------------
revno: 117279
revision-id: address@hidden
parent: address@hidden
fixes bug: http://debbugs.gnu.org/17209
committer: Fabián Ezequiel Gallina <address@hidden>
branch nick: emacs-24
timestamp: Sat 2014-06-21 11:14:54 -0300
message:
  Fix completion retrieval parsing.
  * progmodes/python.el (python-mode):
  (python-util-strip-string): New function.
  (python-shell-completion-get-completions): Use it.
  
  * automated/python-tests.el (python-util-strip-string-1): New test.
modified:
  lisp/ChangeLog                 changelog-20091113204419-o5vbwnq5f7feedwu-1432
  lisp/progmodes/python.el       python.el-20091113204419-o5vbwnq5f7feedwu-3008
  test/ChangeLog                 changelog-20091113204419-o5vbwnq5f7feedwu-8588
  test/automated/python-tests.el 
pythontests.el-20130220195218-kqcioz3fssz9hwe1-1
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2014-06-21 13:41:44 +0000
+++ b/lisp/ChangeLog    2014-06-21 14:14:54 +0000
@@ -1,3 +1,10 @@
+2014-06-21  Fabián Ezequiel Gallina  <address@hidden>
+
+       Fix completion retrieval parsing (bug#17209).
+       * progmodes/python.el (python-mode):
+       (python-util-strip-string): New function.
+       (python-shell-completion-get-completions): Use it.
+
 2014-06-21  Eli Zaretskii  <address@hidden>
 
        * skeleton.el (skeleton-insert): Fix last change.

=== modified file 'lisp/progmodes/python.el'
--- a/lisp/progmodes/python.el  2014-06-21 11:26:43 +0000
+++ b/lisp/progmodes/python.el  2014-06-21 14:14:54 +0000
@@ -2463,8 +2463,10 @@
     (and completion-code
          (> (length input) 0)
          (with-current-buffer (process-buffer process)
-           (let ((completions (python-shell-send-string-no-output
-                               (format completion-code input) process)))
+           (let ((completions
+                  (python-util-strip-string
+                   (python-shell-send-string-no-output
+                    (format completion-code input) process))))
              (and (> (length completions) 2)
                   (split-string completions
                                 "^'\\|^\"\\|;\\|'$\\|\"$" t)))))))
@@ -3644,6 +3646,14 @@
               n (1- n)))
       (reverse acc))))
 
+(defun python-util-strip-string (string)
+  "Strip STRING whitespace and newlines from end and beginning."
+  (replace-regexp-in-string
+   (rx (or (: string-start (* (any whitespace ?\r ?\n)))
+           (: (* (any whitespace ?\r ?\n)) string-end)))
+   ""
+   string))
+
 
 (defun python-electric-pair-string-delimiter ()
   (when (and electric-pair-mode

=== modified file 'test/ChangeLog'
--- a/test/ChangeLog    2014-06-01 10:38:09 +0000
+++ b/test/ChangeLog    2014-06-21 14:14:54 +0000
@@ -1,3 +1,7 @@
+2014-06-21  Fabián Ezequiel Gallina  <address@hidden>
+
+       * automated/python-tests.el (python-util-strip-string-1): New test.
+
 2014-05-08  Glenn Morris  <address@hidden>
 
        * automated/vc-bzr.el (vc-bzr-test-bug9726, vc-bzr-test-bug9781)

=== modified file 'test/automated/python-tests.el'
--- a/test/automated/python-tests.el    2014-04-09 01:50:29 +0000
+++ b/test/automated/python-tests.el    2014-06-21 14:14:54 +0000
@@ -2706,6 +2706,15 @@
         (equal (symbol-value (car ccons)) (cdr ccons)))))
     (kill-buffer buffer)))
 
+(ert-deftest python-util-strip-string-1 ()
+  (should (string= (python-util-strip-string "\t\r\n    str") "str"))
+  (should (string= (python-util-strip-string "str \n\r") "str"))
+  (should (string= (python-util-strip-string "\t\r\n    str \n\r ") "str"))
+  (should
+   (string= (python-util-strip-string "\n str \nin \tg \n\r") "str \nin \tg"))
+  (should (string= (python-util-strip-string "\n \t \n\r ") ""))
+  (should (string= (python-util-strip-string "") "")))
+
 
 ;;; Electricity
 


reply via email to

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