Mercurial > dotfiles
comparison .elisp/pycomplete.el @ 19:b5d75594b356
Add support for the ipython-mode stuff and remove vestigial pymacs code.
| author | Augie Fackler <durin42@gmail.com> |
|---|---|
| date | Mon, 08 Dec 2008 10:58:06 -0600 |
| parents | |
| children | 014e745b2d04 |
comparison
equal
deleted
inserted
replaced
| 18:30467b2328cb | 19:b5d75594b356 |
|---|---|
| 1 ;;; Complete symbols at point using Pymacs. | |
| 2 | |
| 3 ;;; See pycomplete.py for the Python side of things and a short description | |
| 4 ;;; of what to expect. | |
| 5 | |
| 6 (require 'pymacs) | |
| 7 (require 'python-mode) | |
| 8 | |
| 9 (pymacs-load "pycomplete") | |
| 10 | |
| 11 (defun py-complete () | |
| 12 (interactive) | |
| 13 (let ((pymacs-forget-mutability t)) | |
| 14 (insert (pycomplete-pycomplete (py-symbol-near-point) | |
| 15 (py-find-global-imports))))) | |
| 16 | |
| 17 (defun py-find-global-imports () | |
| 18 (save-excursion | |
| 19 (let (first-class-or-def imports) | |
| 20 (goto-char (point-min)) | |
| 21 (setq first-class-or-def | |
| 22 (re-search-forward "^ *\\(def\\|class\\) " nil t)) | |
| 23 (goto-char (point-min)) | |
| 24 (setq imports nil) | |
| 25 (while (re-search-forward | |
| 26 "^\\(import \\|from \\([A-Za-z_][A-Za-z_0-9]*\\) import \\).*" | |
| 27 nil t) | |
| 28 (setq imports (append imports | |
| 29 (list (buffer-substring | |
| 30 (match-beginning 0) | |
| 31 (match-end 0)))))) | |
| 32 imports))) | |
| 33 | |
| 34 (define-key py-mode-map "\M-\C-i" 'py-complete) | |
| 35 | |
| 36 (provide 'pycomplete) |
