Created
July 17, 2012 01:35
-
-
Save russell/3126357 to your computer and use it in GitHub Desktop.
auto-complete for python-mode using python-shell-completion
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun ac-python-candidates () | |
(let* (py-split-windows-on-execute-p | |
py-switch-buffers-on-execute-p | |
(shell (py-choose-shell)) | |
(proc (or (get-buffer-process shell) | |
(get-buffer-process (py-shell nil nil shell 'noswitch nil))))) | |
(if (processp proc) | |
(with-syntax-table python-dotty-syntax-table | |
(let* ((imports (py-find-imports)) | |
(beg (save-excursion (skip-chars-backward "a-zA-Z0-9_.") (point))) | |
(end (point)) | |
(word (buffer-substring-no-properties beg end)) | |
(code (if imports | |
(concat imports python-shell-module-completion-string-code) | |
python-shell-module-completion-string-code))) | |
(python-shell-completion--get-completions word proc code)))))) | |
(ac-define-source python | |
'((candidates . ac-python-candidates) | |
(symbol . "f") | |
(cache))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment