aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/progmodes/python.el
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 /lisp/progmodes/python.el
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
Diffstat (limited to 'lisp/progmodes/python.el')
-rw-r--r--lisp/progmodes/python.el14
1 files changed, 12 insertions, 2 deletions
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