aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lisp/progmodes/python.el54
1 files changed, 23 insertions, 31 deletions
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el
index 1c05048512a..4fe5bd87462 100644
--- a/lisp/progmodes/python.el
+++ b/lisp/progmodes/python.el
@@ -1609,38 +1609,38 @@ else:
1609 (when (> (length completions) 2) 1609 (when (> (length completions) 2)
1610 (split-string completions "^'\\|^\"\\|;\\|'$\\|\"$" t))))) 1610 (split-string completions "^'\\|^\"\\|;\\|'$\\|\"$" t)))))
1611 1611
1612(defun python-shell-completion--get-completion (input completions) 1612(defun python-shell-completion--do-completion-at-point (process)
1613 "Get completion for INPUT using COMPLETIONS." 1613 "Do completion for INPUT using COMPLETIONS."
1614 (let ((completion (when completions 1614 (with-syntax-table python-dotty-syntax-table
1615 (let* ((input (substring-no-properties
1616 (or (comint-word (current-word)) "") nil nil))
1617 (completions (python-shell-completion--get-completions
1618 input process))
1619 (completion (when completions
1615 (try-completion input completions)))) 1620 (try-completion input completions))))
1616 (cond ((eq completion t) 1621 (cond ((eq completion t)
1617 input) 1622 t)
1618 ((null completion) 1623 ((null completion)
1619 (message "Can't find completion for \"%s\"" input) 1624 (message "Can't find completion for \"%s\"" input)
1620 (ding) 1625 (ding)
1621 input) 1626 nil)
1622 ((not (string= input completion)) 1627 ((not (string= input completion))
1623 completion) 1628 (progn (delete-char (- (length input)))
1629 (insert completion)
1630 t))
1624 (t 1631 (t
1625 (message "Making completion list...")
1626 (with-output-to-temp-buffer "*Python Completions*" 1632 (with-output-to-temp-buffer "*Python Completions*"
1627 (display-completion-list 1633 (display-completion-list
1628 (all-completions input completions))) 1634 (all-completions input completions)))
1629 input)))) 1635 t)))))
1630 1636
1631(defun python-shell-completion-complete-at-point () 1637(defun python-shell-completion-complete-at-point ()
1632 "Perform completion at point in inferior Python process." 1638 "Perform completion at point in inferior Python process."
1633 (interactive) 1639 (interactive)
1634 (with-syntax-table python-dotty-syntax-table 1640 (and comint-last-prompt-overlay
1635 (when (and comint-last-prompt-overlay 1641 (> (point-marker) (overlay-end comint-last-prompt-overlay))
1636 (> (point-marker) (overlay-end comint-last-prompt-overlay))) 1642 (python-shell-completion--do-completion-at-point
1637 (let* ((process (get-buffer-process (current-buffer))) 1643 (get-buffer-process (current-buffer)))))
1638 (input (substring-no-properties
1639 (or (comint-word (current-word)) "") nil nil)))
1640 (delete-char (- (length input)))
1641 (insert
1642 (python-shell-completion--get-completion
1643 input (python-shell-completion--get-completions input process)))))))
1644 1644
1645(defun python-shell-completion-complete-or-indent () 1645(defun python-shell-completion-complete-or-indent ()
1646 "Complete or indent depending on the context. 1646 "Complete or indent depending on the context.
@@ -1749,15 +1749,7 @@ inferior python process is updated properly."
1749 (let ((process (python-shell-get-process))) 1749 (let ((process (python-shell-get-process)))
1750 (if (not process) 1750 (if (not process)
1751 (error "Completion needs an inferior Python process running") 1751 (error "Completion needs an inferior Python process running")
1752 (with-syntax-table python-dotty-syntax-table 1752 (python-shell-completion--do-completion-at-point process))))
1753 (let* ((input (substring-no-properties
1754 (or (comint-word (current-word)) "") nil nil))
1755 (completions (python-shell-completion--get-completions
1756 input process)))
1757 (delete-char (- (length input)))
1758 (insert
1759 (python-shell-completion--get-completion
1760 input completions)))))))
1761 1753
1762(add-to-list 'debug-ignored-errors "^Completion needs an inferior Python process running.") 1754(add-to-list 'debug-ignored-errors "^Completion needs an inferior Python process running.")
1763 1755