aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFabián Ezequiel Gallina2014-06-21 11:14:54 -0300
committerFabián Ezequiel Gallina2014-06-21 11:14:54 -0300
commit656f99beebbe122d84754f4f25c4b1b8c53e8941 (patch)
treeddf72d5ce2bdbcbc5fe83d0959f4feba08e53ea6
parentedd112b7f8956e727b21976e9e6a36256d724c24 (diff)
downloademacs-656f99beebbe122d84754f4f25c4b1b8c53e8941.tar.gz
emacs-656f99beebbe122d84754f4f25c4b1b8c53e8941.zip
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. Fixes: debbugs:17209
-rw-r--r--lisp/ChangeLog7
-rw-r--r--lisp/progmodes/python.el14
-rw-r--r--test/ChangeLog4
-rw-r--r--test/automated/python-tests.el9
4 files changed, 32 insertions, 2 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 46f87253825..9af92aebf3a 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,10 @@
12014-06-21 Fabián Ezequiel Gallina <fgallina@gnu.org>
2
3 Fix completion retrieval parsing (bug#17209).
4 * progmodes/python.el (python-mode):
5 (python-util-strip-string): New function.
6 (python-shell-completion-get-completions): Use it.
7
12014-06-21 Eli Zaretskii <eliz@gnu.org> 82014-06-21 Eli Zaretskii <eliz@gnu.org>
2 9
3 * skeleton.el (skeleton-insert): Fix last change. 10 * skeleton.el (skeleton-insert): Fix last change.
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el
index f127d4b7028..f99a580b376 100644
--- a/lisp/progmodes/python.el
+++ b/lisp/progmodes/python.el
@@ -2463,8 +2463,10 @@ LINE is used to detect the context on how to complete given INPUT."
2463 (and completion-code 2463 (and completion-code
2464 (> (length input) 0) 2464 (> (length input) 0)
2465 (with-current-buffer (process-buffer process) 2465 (with-current-buffer (process-buffer process)
2466 (let ((completions (python-shell-send-string-no-output 2466 (let ((completions
2467 (format completion-code input) process))) 2467 (python-util-strip-string
2468 (python-shell-send-string-no-output
2469 (format completion-code input) process))))
2468 (and (> (length completions) 2) 2470 (and (> (length completions) 2)
2469 (split-string completions 2471 (split-string completions
2470 "^'\\|^\"\\|;\\|'$\\|\"$" t))))))) 2472 "^'\\|^\"\\|;\\|'$\\|\"$" t)))))))
@@ -3644,6 +3646,14 @@ returned as is."
3644 n (1- n))) 3646 n (1- n)))
3645 (reverse acc)))) 3647 (reverse acc))))
3646 3648
3649(defun python-util-strip-string (string)
3650 "Strip STRING whitespace and newlines from end and beginning."
3651 (replace-regexp-in-string
3652 (rx (or (: string-start (* (any whitespace ?\r ?\n)))
3653 (: (* (any whitespace ?\r ?\n)) string-end)))
3654 ""
3655 string))
3656
3647 3657
3648(defun python-electric-pair-string-delimiter () 3658(defun python-electric-pair-string-delimiter ()
3649 (when (and electric-pair-mode 3659 (when (and electric-pair-mode
diff --git a/test/ChangeLog b/test/ChangeLog
index 443479b099e..f86084739af 100644
--- a/test/ChangeLog
+++ b/test/ChangeLog
@@ -1,3 +1,7 @@
12014-06-21 Fabián Ezequiel Gallina <fgallina@gnu.org>
2
3 * automated/python-tests.el (python-util-strip-string-1): New test.
4
12014-05-08 Glenn Morris <rgm@gnu.org> 52014-05-08 Glenn Morris <rgm@gnu.org>
2 6
3 * automated/vc-bzr.el (vc-bzr-test-bug9726, vc-bzr-test-bug9781) 7 * automated/vc-bzr.el (vc-bzr-test-bug9726, vc-bzr-test-bug9781)
diff --git a/test/automated/python-tests.el b/test/automated/python-tests.el
index de963a670bc..f580e946b8f 100644
--- a/test/automated/python-tests.el
+++ b/test/automated/python-tests.el
@@ -2706,6 +2706,15 @@ def foo(a, b, c):
2706 (equal (symbol-value (car ccons)) (cdr ccons))))) 2706 (equal (symbol-value (car ccons)) (cdr ccons)))))
2707 (kill-buffer buffer))) 2707 (kill-buffer buffer)))
2708 2708
2709(ert-deftest python-util-strip-string-1 ()
2710 (should (string= (python-util-strip-string "\t\r\n str") "str"))
2711 (should (string= (python-util-strip-string "str \n\r") "str"))
2712 (should (string= (python-util-strip-string "\t\r\n str \n\r ") "str"))
2713 (should
2714 (string= (python-util-strip-string "\n str \nin \tg \n\r") "str \nin \tg"))
2715 (should (string= (python-util-strip-string "\n \t \n\r ") ""))
2716 (should (string= (python-util-strip-string "") "")))
2717
2709 2718
2710;;; Electricity 2719;;; Electricity
2711 2720