Skip to content

Instantly share code, notes, and snippets.

@yanbe
Created September 25, 2010 23:51
Show Gist options
  • Save yanbe/597430 to your computer and use it in GitHub Desktop.
Save yanbe/597430 to your computer and use it in GitHub Desktop.
Source definition of Auto Complete Mode for Python module contents.
(defun ac-python-candidates ()
(python-find-imports)
(car (read-from-string
(python-send-receive
(format "emacs.complete(%S,%s)"
(python-partial-symbol)
python-imports)))))
(ac-define-source python
'((candidates . ac-python-candidates)
(prefix . (unless
(save-excursion
(re-search-backward "^import"
(save-excursion
(re-search-backward "^")) t))
(let ((symbol (python-partial-symbol)))
(if symbol
(save-excursion
(search-backward symbol))))))
(symbol . "f")))
(add-hook 'python-mode-hook
'(lambda () (add-to-list 'ac-sources 'ac-source-python)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment