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