summaryrefslogtreecommitdiff
path: root/lisp/progmodes/python.el
diff options
context:
space:
mode:
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."
(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