Skip to content

Instantly share code, notes, and snippets.

@syohex
Created November 26, 2012 23:26
Show Gist options
  • Select an option

  • Save syohex/4151333 to your computer and use it in GitHub Desktop.

Select an option

Save syohex/4151333 to your computer and use it in GitHub Desktop.
helm version of 'anything-ghc-browse-document'
;; 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