Created
November 26, 2012 23:26
-
-
Save syohex/4151333 to your computer and use it in GitHub Desktop.
helm version of 'anything-ghc-browse-document'
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ;; Please see http://d.hatena.ne.jp/kitokitoki/20111217/p1 | |
| (defvar helm-c-source-ghc-mod | |
| '((name . "GHC Browse Documennt") | |
| (init . helm-c-source-ghc-mod) | |
| (candidates-in-buffer) | |
| (candidate-number-limit . 9999) | |
| (action . helm-c-source-ghc-mod-action))) | |
| (defun helm-c-source-ghc-mod () | |
| (with-current-buffer (helm-candidate-buffer 'global) | |
| (unless (call-process-shell-command "ghc-mod list" nil t t) | |
| (error "Failed 'ghc-mod list'")))) | |
| (defun helm-c-source-ghc-mod-action (candidate) | |
| (let ((pkg (ghc-resolve-package-name candidate))) | |
| (if (and pkg candidate) | |
| (ghc-display-document pkg candidate nil) | |
| (error (format "Not found %s(Package %s)" candidate pkg))))) | |
| (defun helm-ghc-browse-document () | |
| (interactive) | |
| (helm :sources '(helm-c-source-ghc-mod) | |
| :buffer (get-buffer-create "*helm-ghc-document*"))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment