Skip to content

Instantly share code, notes, and snippets.

@epost
Last active August 29, 2015 14:16
Show Gist options
  • Save epost/6db5fac97956d0050137 to your computer and use it in GitHub Desktop.
Save epost/6db5fac97956d0050137 to your computer and use it in GitHub Desktop.
purescript support tidbits for emacs
(defun purescript-pursuit-search (query-str)
"Search Pursuit for given search string"
(browse-url (concat "http://pursuit.purescript.org/?q=" query-str))
)
;; TODO
;; - use symbol at point as default query?
;; - simply called 'hoogle' and 'hayoo' in haskell-mode
;; - browse *inside* emacs?
;; - case sensitivity?
(defun purescript-pursuit-search-interactive (query-str-as-export-param)
"Search Pursuit for given search string"
(interactive "sSearch Pursuit for: ")
(purescript-pursuit-search query-str-as-export-param)
)
(require 'thingatpt)
; TODO 'word may not be the desired type, see http://emacswiki.org/emacs/ThingAtPoint and http://ergoemacs.org/emacs/elisp_idioms.html
(defun purescript-pursuit-search-symbol-at-point ()
"Search Pursuit for the symbol at the cursor location"
(interactive)
(purescript-pursuit-search (thing-at-point 'word))
)
;; (thing-at-point 'word) is quite a poor surrogate for purescript-ident-at-point
defun purescript-pursuit-search-with-default (query-str-as-export-param &optional info)
"Search Pursuit for given search string, or use word under cursor if no search string given."
(interactive
(let ((default-query (thing-at-point 'word)))
(list
(read-string (format "Query Pursuit (default %s): " default-query)
nil nil default-query)
current-prefix-arg)
))
(message query-str-as-export-param)
(purescript-pursuit-search query-str-as-export-param)
)
(defun purescript-hook-erik ()
(define-key purescript-mode-map [(control c)(control p)] 'purescript-pursuit-search-with-default)
(define-key purescript-mode-map [(control c)(control s)] 'purescript-pursuit-search-interactive)
(define-key purescript-mode-map [(control c)(control .)] 'purescript-pursuit-search-symbol-at-point)
(add-to-list 'compilation-error-regexp-alist
'("\\(Error\\|Warnin\\g\\) at \\([^ \n]+\\) line \\([0-9]+\\), column \\([0-9]+\\) - line \\([0-9]+\\), column \\([0-9]+\\):"
2 (3 . 5) (4 . 6) nil
))
)
(add-hook 'purescript-mode-hook 'purescript-hook-erik)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment