diff options
author | Fabián Ezequiel Gallina <fgallina@gnu.org> | 2014-06-21 11:14:54 -0300 |
---|---|---|
committer | Fabián Ezequiel Gallina <fgallina@gnu.org> | 2014-06-21 11:14:54 -0300 |
commit | 656f99beebbe122d84754f4f25c4b1b8c53e8941 (patch) | |
tree | ddf72d5ce2bdbcbc5fe83d0959f4feba08e53ea6 | |
parent | edd112b7f8956e727b21976e9e6a36256d724c24 (diff) | |
download | emacs-656f99beebbe122d84754f4f25c4b1b8c53e8941.tar.gz emacs-656f99beebbe122d84754f4f25c4b1b8c53e8941.tar.bz2 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/ChangeLog | 7 | ||||
-rw-r--r-- | lisp/progmodes/python.el | 14 | ||||
-rw-r--r-- | test/ChangeLog | 4 | ||||
-rw-r--r-- | test/automated/python-tests.el | 9 |
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 @@ +2014-06-21 Fabián Ezequiel Gallina <fgallina@gnu.org> + + 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 <eliz@gnu.org> * 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." (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 @@ returned as is." 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 diff --git a/test/ChangeLog b/test/ChangeLog index 443479b099e..f86084739af 100644 --- a/test/ChangeLog +++ b/test/ChangeLog @@ -1,3 +1,7 @@ +2014-06-21 Fabián Ezequiel Gallina <fgallina@gnu.org> + + * automated/python-tests.el (python-util-strip-string-1): New test. + 2014-05-08 Glenn Morris <rgm@gnu.org> * 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): (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 |