annotate .elisp/pycomplete.el @ 195:e1a49db5c6ff

git-next-unmerged-file: also include "both modified" files
author Augie Fackler <durin42@gmail.com>
date Tue, 06 Apr 2010 15:07:46 -0500
parents 014e745b2d04
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
174
014e745b2d04 python-mode: updating to current bzr version
Augie Fackler <durin42@gmail.com>
parents: 19
diff changeset
3 ;; Copyright (C) 2007 Skip Montanaro
014e745b2d04 python-mode: updating to current bzr version
Augie Fackler <durin42@gmail.com>
parents: 19
diff changeset
4
014e745b2d04 python-mode: updating to current bzr version
Augie Fackler <durin42@gmail.com>
parents: 19
diff changeset
5 ;; Author: Skip Montanaro
014e745b2d04 python-mode: updating to current bzr version
Augie Fackler <durin42@gmail.com>
parents: 19
diff changeset
6 ;; Maintainer: skip@pobox.com
014e745b2d04 python-mode: updating to current bzr version
Augie Fackler <durin42@gmail.com>
parents: 19
diff changeset
7 ;; Created: Oct 2004
014e745b2d04 python-mode: updating to current bzr version
Augie Fackler <durin42@gmail.com>
parents: 19
diff changeset
8 ;; Keywords: python pymacs emacs
014e745b2d04 python-mode: updating to current bzr version
Augie Fackler <durin42@gmail.com>
parents: 19
diff changeset
9
014e745b2d04 python-mode: updating to current bzr version
Augie Fackler <durin42@gmail.com>
parents: 19
diff changeset
10 ;; This software is provided as-is, without express or implied warranty.
014e745b2d04 python-mode: updating to current bzr version
Augie Fackler <durin42@gmail.com>
parents: 19
diff changeset
11 ;; Permission to use, copy, modify, distribute or sell this software,
014e745b2d04 python-mode: updating to current bzr version
Augie Fackler <durin42@gmail.com>
parents: 19
diff changeset
12 ;; without fee, for any purpose and by any individual or organization, is
014e745b2d04 python-mode: updating to current bzr version
Augie Fackler <durin42@gmail.com>
parents: 19
diff changeset
13 ;; hereby granted, provided that the above copyright notice and this
014e745b2d04 python-mode: updating to current bzr version
Augie Fackler <durin42@gmail.com>
parents: 19
diff changeset
14 ;; paragraph appear in all copies.
014e745b2d04 python-mode: updating to current bzr version
Augie Fackler <durin42@gmail.com>
parents: 19
diff changeset
15
014e745b2d04 python-mode: updating to current bzr version
Augie Fackler <durin42@gmail.com>
parents: 19
diff changeset
16 ;; Along with pycomplete.py this file allows programmers to complete Python
014e745b2d04 python-mode: updating to current bzr version
Augie Fackler <durin42@gmail.com>
parents: 19
diff changeset
17 ;; symbols within the current buffer. See pycomplete.py for the Python side
014e745b2d04 python-mode: updating to current bzr version
Augie Fackler <durin42@gmail.com>
parents: 19
diff changeset
18 ;; of things and a short description of what to expect.
19
b5d75594b356 Add support for the ipython-mode stuff and remove vestigial pymacs code.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
19
b5d75594b356 Add support for the ipython-mode stuff and remove vestigial pymacs code.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
20 (require 'pymacs)
b5d75594b356 Add support for the ipython-mode stuff and remove vestigial pymacs code.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
21 (require 'python-mode)
b5d75594b356 Add support for the ipython-mode stuff and remove vestigial pymacs code.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
22
b5d75594b356 Add support for the ipython-mode stuff and remove vestigial pymacs code.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
23 (pymacs-load "pycomplete")
b5d75594b356 Add support for the ipython-mode stuff and remove vestigial pymacs code.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
24
b5d75594b356 Add support for the ipython-mode stuff and remove vestigial pymacs code.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
25 (defun py-complete ()
b5d75594b356 Add support for the ipython-mode stuff and remove vestigial pymacs code.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
26 (interactive)
b5d75594b356 Add support for the ipython-mode stuff and remove vestigial pymacs code.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
27 (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
28 (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
29 (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
30
b5d75594b356 Add support for the ipython-mode stuff and remove vestigial pymacs code.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
31 (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
32 (save-excursion
b5d75594b356 Add support for the ipython-mode stuff and remove vestigial pymacs code.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
33 (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
34 (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
35 (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
36 (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
37 (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
38 (setq imports nil)
b5d75594b356 Add support for the ipython-mode stuff and remove vestigial pymacs code.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
39 (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
40 "^\\(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
41 nil t)
b5d75594b356 Add support for the ipython-mode stuff and remove vestigial pymacs code.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
42 (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
43 (list (buffer-substring
b5d75594b356 Add support for the ipython-mode stuff and remove vestigial pymacs code.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
44 (match-beginning 0)
b5d75594b356 Add support for the ipython-mode stuff and remove vestigial pymacs code.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
45 (match-end 0))))))
b5d75594b356 Add support for the ipython-mode stuff and remove vestigial pymacs code.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
46 imports)))
b5d75594b356 Add support for the ipython-mode stuff and remove vestigial pymacs code.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
47
b5d75594b356 Add support for the ipython-mode stuff and remove vestigial pymacs code.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
48 (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
49
b5d75594b356 Add support for the ipython-mode stuff and remove vestigial pymacs code.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
50 (provide 'pycomplete)