aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/progmodes/python.el
diff options
context:
space:
mode:
authorFabián Ezequiel Gallina2012-05-17 00:03:36 -0300
committerFabián Ezequiel Gallina2012-05-17 00:03:36 -0300
commit0d0e6ccde63ad801353ed289049940a88d626fee (patch)
treef795faa9bd531e7db51004dc5ed5461a79687a2a /lisp/progmodes/python.el
parent394f09a38f7cdb3138ed3dc778b702ab4ab3a2ba (diff)
downloademacs-0d0e6ccde63ad801353ed289049940a88d626fee.tar.gz
emacs-0d0e6ccde63ad801353ed289049940a88d626fee.zip
Make `python-shell-completion--do-completion-at-point' to return a list for `completion-at-point' do it's job instead of replicating completion logic.
Removed vars: + python-shell-completion-original-window-configuration
Diffstat (limited to 'lisp/progmodes/python.el')
-rw-r--r--lisp/progmodes/python.el43
1 files changed, 11 insertions, 32 deletions
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el
index cfc15c7d040..377ad72756f 100644
--- a/lisp/progmodes/python.el
+++ b/lisp/progmodes/python.el
@@ -1707,8 +1707,6 @@ and use the following as the value of this variable:
1707 :type 'string 1707 :type 'string
1708 :group 'python) 1708 :group 'python)
1709 1709
1710(defvar python-shell-completion-original-window-configuration nil)
1711
1712(defun python-shell-completion--get-completions (input process completion-code) 1710(defun python-shell-completion--get-completions (input process completion-code)
1713 "Retrieve available completions for INPUT using PROCESS. 1711 "Retrieve available completions for INPUT using PROCESS.
1714Argument COMPLETION-CODE is the python code used to get 1712Argument COMPLETION-CODE is the python code used to get
@@ -1722,16 +1720,21 @@ completions on the current context."
1722(defun python-shell-completion--do-completion-at-point (process) 1720(defun python-shell-completion--do-completion-at-point (process)
1723 "Do completion at point for PROCESS." 1721 "Do completion at point for PROCESS."
1724 (with-syntax-table python-dotty-syntax-table 1722 (with-syntax-table python-dotty-syntax-table
1725 (let* ((line (substring-no-properties 1723 (let* ((beg (save-excursion (skip-syntax-backward "w") (point)))
1726 (buffer-substring (point-at-bol) (point)) nil nil)) 1724 (end (point))
1727 (input (substring-no-properties 1725 (line (buffer-substring-no-properties (point-at-bol) end))
1728 (or (comint-word (current-word)) "") nil nil)) 1726 (input (buffer-substring-no-properties beg end))
1727 ;; Get the last prompt for the inferior process buffer. This is
1728 ;; used for the completion code selection heuristic.
1729 (prompt 1729 (prompt
1730 (with-current-buffer (process-buffer process) 1730 (with-current-buffer (process-buffer process)
1731 (buffer-substring-no-properties 1731 (buffer-substring-no-properties
1732 (overlay-start comint-last-prompt-overlay) 1732 (overlay-start comint-last-prompt-overlay)
1733 (overlay-end comint-last-prompt-overlay)))) 1733 (overlay-end comint-last-prompt-overlay))))
1734 (completion-code 1734 (completion-code
1735 ;; Check wether a prompt matches a pdb string, an import statement
1736 ;; or just the standard prompt and use the correct
1737 ;; python-shell-completion-*-code string
1735 (cond ((and (> (length python-shell-completion-pdb-string-code) 0) 1738 (cond ((and (> (length python-shell-completion-pdb-string-code) 0)
1736 (string-match 1739 (string-match
1737 (concat "^" python-shell-prompt-pdb-regexp) prompt)) 1740 (concat "^" python-shell-prompt-pdb-regexp) prompt))
@@ -1749,32 +1752,8 @@ completions on the current context."
1749 (completions 1752 (completions
1750 (and completion-code (> (length input) 0) 1753 (and completion-code (> (length input) 0)
1751 (python-shell-completion--get-completions 1754 (python-shell-completion--get-completions
1752 line process completion-code))) 1755 line process completion-code))))
1753 (completion (when completions 1756 (list beg end completions))))
1754 (try-completion input completions))))
1755 (cond ((eq completion t)
1756 (if (eq this-command last-command)
1757 (when python-shell-completion-original-window-configuration
1758 (set-window-configuration
1759 python-shell-completion-original-window-configuration)))
1760 (setq python-shell-completion-original-window-configuration nil)
1761 t)
1762 ((null completion)
1763 (message "Can't find completion for \"%s\"" input)
1764 (ding)
1765 nil)
1766 ((not (string= input completion))
1767 (progn (delete-char (- (length input)))
1768 (insert completion)
1769 t))
1770 (t
1771 (unless python-shell-completion-original-window-configuration
1772 (setq python-shell-completion-original-window-configuration
1773 (current-window-configuration)))
1774 (with-output-to-temp-buffer "*Python Completions*"
1775 (display-completion-list
1776 (all-completions input completions)))
1777 t)))))
1778 1757
1779(defun python-shell-completion-complete-at-point () 1758(defun python-shell-completion-complete-at-point ()
1780 "Perform completion at point in inferior Python process." 1759 "Perform completion at point in inferior Python process."