September 16, 2009

Pylookup

Pylookup is a mode to search python documents especially within emacs.

Usage

M-x pylookup-lookup

Lookup

Lookup

  • M-x pylookup-lookup, (set your local key map)

Ido autocompletion

Autocompletion

Autocompletion

  • Interactive do interface to search keywords
  • C-r, C-s : next/prev match

Search results

Search

Search

  • Results of searching a keyword
  • n/p : next/prev line
  • C-v, M-v : scroll up/down
  • q : quit
  • Space/Enter : lookup document

Read in your browser

Browsing

Browsing

  • You can see the proper python document in your favorite browser, w3m, firefox, ie or whatever.

Install

Checkout

git clone http://github.com/tsgates/pylookup.git  

Edit .emacs

;; add pylookup to your loadpath, ex) "~/.lisp/addons/pylookup"
(setq pylookup-dir "[PATH]")
(add-to-list 'load-path pylookup-dir)
;; load pylookup when compile time
(eval-when-compile (require 'pylookup))

;; set executable file and db file
(setq pylookup-program (concat pylookup-dir "/pylookup.py"))
(setq pylookup-db-file (concat pylookup-dir "/pylookup.db"))

;; to speedup, just load it on demand
(autoload 'pylookup-lookup "pylookup"
  "Lookup SEARCH-TERM in the Python HTML indexes." t)
(autoload 'pylookup-update "pylookup" 
  "Run pylookup-update and create the database at `pylookup-db-file'." t)
  • Change [PATH] variable to proper path where you installed pylookup
  • Add above code in your .emacs

Preferences

Keybinding

(global-set-key "\C-ch" 'pylookup-lookup)

Lookup downloaded documents

  • Update Database (In repository, there is database to lookup online document, but slow to load in a browser)
$ cd ~/.lisp/addons/pylookup  
$ ./pylookup.py -u file:///home/tsgates/.lisp/addons/pylookup/python-2.6.2-docs-html  
$ ./pylookup.py -l test  
COMPARISON_FLAGS (in module doctest) [lib];file:///home/tsgates/.lisp/addons/pylookup...  
  • Move to pylookup directory
  • Execute pylookup.py with your absolute python document path, download from here
  • Test by executing pylookup.py -l test and check pylookup indicating proper path you set

Default browser

(setq browse-url-browser-function 'w3m-browse-url) ;; w3m
(setq browse-url-default-browser "firefox.exe")    ;; firefox in M$ Windows

Numpy Support

self.list_entry = False" in IndexProcessor.__init__
  • A workaround by Takafumi Arakaki

Acknowledgement

  • Martin Blais's haddoc mode: http://furius.ca/haddoc
  • Github: http://github.com/tsgates/pylookup
  • This code is distributed under the GNU GPL v.2.0