Skip to content

Instantly share code, notes, and snippets.

@kiwanami
Forked from myuhe/init.el
Created September 29, 2010 14:22
Show Gist options
  • Save kiwanami/602825 to your computer and use it in GitHub Desktop.
Save kiwanami/602825 to your computer and use it in GitHub Desktop.
(defun py-doc-exec ()
(interactive)
(save-current-buffer
(let ((symbol
(with-syntax-table python-dotty-syntax-table (current-word)))
(tmpbuf (get-buffer-create "*py-doc-popup*"))
(enable-recursive-minibuffers t))
(if (equal symbol "") (error "No symbol"))
(set-buffer "*py-doc-popup*")
(comint-redirect-send-command-to-process
(format "emacs.ehelp(%S, %s)"
symbol python-imports) "*py-doc-popup*" (python-proc) nil t))))
(require 'deferred)
(defun py-doc-popup ()
"Get help() for object at point, and display it in a popup."
;; Note that we do this in the inferior process, not a separate one, to
;; ensure the environment is appropriate.
(interactive)
(py-doc-exec)
(deferred:$
(deferred:wait 100)
(deferred:nextc it
(lambda (x)
(let ((curbuf (current-buffer)))
(set-buffer "*py-doc-popup*")
(let ((bs (buffer-string)))
(set-buffer curbuf)
(popup-tip bs))
(kill-buffer "*py-doc-popup*"))))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment