+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.
(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)))))))
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))
+
\f
(defun python-electric-pair-string-delimiter ()
(when (and electric-pair-mode
+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)
(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 "") "")))
+
\f
;;; Electricity