|
40 | 40 | nil nil def) |
41 | 41 | ))) |
42 | 42 |
|
| 43 | +(defcustom haskell-hoogle-command |
| 44 | + (if (executable-find "hoogle") "hoogle") |
| 45 | + "Name of the command to use to query Hoogle. |
| 46 | +Can also be a function that returns the command as a string. |
| 47 | +If nil, use the Hoogle web-site." |
| 48 | + :group 'haskell |
| 49 | + :type '(choice (const :tag "Use Web-site" nil) |
| 50 | + string |
| 51 | + function)) |
| 52 | + |
| 53 | +(defcustom haskell-hoogle-url "https://hoogle.haskell.org/?hoogle=%s" |
| 54 | + "Default value for hoogle web site." |
| 55 | + :group 'haskell |
| 56 | + :type '(choice |
| 57 | + (const :tag "haskell-org" "https://hoogle.haskell.org/?hoogle=%s") |
| 58 | + (const :tag "fp-complete" "https://www.stackage.org/lts/hoogle?q=%s") |
| 59 | + string)) |
| 60 | + |
43 | 61 | ;;;###autoload |
44 | 62 | (defun haskell-hoogle (query &optional info) |
45 | 63 | "Do a Hoogle search for QUERY. |
46 | 64 |
|
47 | 65 | If prefix argument INFO is given, then `haskell-hoogle-command' |
48 | 66 | is asked to show extra info for the items matching QUERY.." |
49 | 67 | (interactive (append (hoogle-prompt) current-prefix-arg)) |
50 | | - (let* ((command (concat (executable-find "hoogle") |
| 68 | + (if (null haskell-hoogle-command) |
| 69 | + (browse-url (format haskell-hoogle-url (url-hexify-string query))) |
| 70 | + (let* ((command (concat (if (functionp haskell-hoogle-command) |
| 71 | + (funcall haskell-hoogle-command) |
| 72 | + haskell-hoogle-command) |
51 | 73 | (if info " -i " "") |
52 | 74 | " --color " (shell-quote-argument query))) |
53 | 75 | (output (shell-command-to-string command))) |
54 | 76 | (with-help-window "*hoogle*" |
55 | 77 | (with-current-buffer standard-output |
56 | 78 | (insert output) |
57 | | - (ansi-color-apply-on-region (point-min) (point-max)))))) |
| 79 | + (ansi-color-apply-on-region (point-min) (point-max))))))) |
58 | 80 |
|
59 | 81 | ;;;###autoload |
60 | 82 | (defalias 'hoogle 'haskell-hoogle) |
61 | 83 |
|
62 | | -(defcustom haskell-hoogle-url "https://hoogle.haskell.org/?hoogle=%s" |
63 | | - "Default value for hoogle web site." |
64 | | - :group 'haskell |
65 | | - :type '(choice |
66 | | - (const :tag "haskell-org" "https://hoogle.haskell.org/?hoogle=%s") |
67 | | - (const :tag "fp-complete" "https://www.stackage.org/lts/hoogle?q=%s") |
68 | | - string)) |
69 | | - |
70 | 84 | ;;;###autoload |
71 | 85 | (defun haskell-hoogle-lookup-from-website (query) |
72 | 86 | "Lookup QUERY at `haskell-hoogle-url'." |
|
0 commit comments