diff options
Diffstat (limited to 'lisp/progmodes/python.el')
| -rw-r--r-- | lisp/progmodes/python.el | 14 |
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 |