From: Fabián Ezequiel Gallina Date: Thu, 17 May 2012 03:03:36 +0000 (-0300) Subject: Make `python-shell-completion--do-completion-at-point' to return a list for `completi... X-Git-Tag: emacs-24.2.90~1199^2~505 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=0d0e6ccde63ad801353ed289049940a88d626fee;p=emacs.git 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 --- 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: :type 'string :group 'python) -(defvar python-shell-completion-original-window-configuration nil) - (defun python-shell-completion--get-completions (input process completion-code) "Retrieve available completions for INPUT using PROCESS. Argument COMPLETION-CODE is the python code used to get @@ -1722,16 +1720,21 @@ completions on the current context." (defun python-shell-completion--do-completion-at-point (process) "Do completion at point for PROCESS." (with-syntax-table python-dotty-syntax-table - (let* ((line (substring-no-properties - (buffer-substring (point-at-bol) (point)) nil nil)) - (input (substring-no-properties - (or (comint-word (current-word)) "") nil nil)) + (let* ((beg (save-excursion (skip-syntax-backward "w") (point))) + (end (point)) + (line (buffer-substring-no-properties (point-at-bol) end)) + (input (buffer-substring-no-properties beg end)) + ;; Get the last prompt for the inferior process buffer. This is + ;; used for the completion code selection heuristic. (prompt (with-current-buffer (process-buffer process) (buffer-substring-no-properties (overlay-start comint-last-prompt-overlay) (overlay-end comint-last-prompt-overlay)))) (completion-code + ;; Check wether a prompt matches a pdb string, an import statement + ;; or just the standard prompt and use the correct + ;; python-shell-completion-*-code string (cond ((and (> (length python-shell-completion-pdb-string-code) 0) (string-match (concat "^" python-shell-prompt-pdb-regexp) prompt)) @@ -1749,32 +1752,8 @@ completions on the current context." (completions (and completion-code (> (length input) 0) (python-shell-completion--get-completions - line process completion-code))) - (completion (when completions - (try-completion input completions)))) - (cond ((eq completion t) - (if (eq this-command last-command) - (when python-shell-completion-original-window-configuration - (set-window-configuration - python-shell-completion-original-window-configuration))) - (setq python-shell-completion-original-window-configuration nil) - t) - ((null completion) - (message "Can't find completion for \"%s\"" input) - (ding) - nil) - ((not (string= input completion)) - (progn (delete-char (- (length input))) - (insert completion) - t)) - (t - (unless python-shell-completion-original-window-configuration - (setq python-shell-completion-original-window-configuration - (current-window-configuration))) - (with-output-to-temp-buffer "*Python Completions*" - (display-completion-list - (all-completions input completions))) - t))))) + line process completion-code)))) + (list beg end completions)))) (defun python-shell-completion-complete-at-point () "Perform completion at point in inferior Python process."