Skip to content

Instantly share code, notes, and snippets.

@yanbe
Created July 1, 2009 09:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yanbe/138704 to your computer and use it in GitHub Desktop.
Save yanbe/138704 to your computer and use it in GitHub Desktop.
CHM file support for python-mode on Emacs
;; CHM file support for Python help
;; Prerequisites: hhh.exe http://saitou155.catfood.jp/hhh.htm
;; TODO: support Mac and Linux
(require 'python-mode)
(defcustom py-chmhelp-path "/Python26/Doc/python262.chm"
"path for Python CHM help file"
:type 'string
:group 'python)
(defun py-chmhelp-dotexpr-begin nil
(interactive)
(re-search-backward "[^a-zA-Z_0-9\\.]")
(forward-char))
(defun py-chmhelp-dotexpr-end nil
(interactive)
(re-search-forward "[a-zA-Z_0-9\\.]*"))
(put 'python-dotexpr 'beginning-op 'py-chmhelp-dotexpr-begin)
(put 'python-dotexpr 'end-op 'py-chmhelp-dotexpr-end)
(defun py-chmhelp-thing-at-point nil
(interactive)
(require 'thingatpt)
(let ((sym (thing-at-point 'python-dotexpr)))
(if sym
(let* ((module (substring sym 0 (string-match "\\." sym)))
(func (substring sym (length module) nil)))
(start-process "CHM help" nil "hhh"
(concat
py-chmhelp-path "::/library/"
module ".html#"
(if (string-equal func "")
(concat "module-" module)
(concat module func))))))))
(define-key py-mode-map "\C-cj" 'py-chmhelp-thing-at-point)
(provide 'python-chmhelp)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment