Skip to content

Commit 7ce4944

Browse files
author
galagora
committed
Restore haskell-hoogle-command configurability
1 parent a8d2f1a commit 7ce4944

File tree

1 file changed

+24
-10
lines changed

1 file changed

+24
-10
lines changed

haskell-hoogle.el

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,33 +40,47 @@
4040
nil nil def)
4141
)))
4242

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+
4361
;;;###autoload
4462
(defun haskell-hoogle (query &optional info)
4563
"Do a Hoogle search for QUERY.
4664
4765
If prefix argument INFO is given, then `haskell-hoogle-command'
4866
is asked to show extra info for the items matching QUERY.."
4967
(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)
5173
(if info " -i " "")
5274
" --color " (shell-quote-argument query)))
5375
(output (shell-command-to-string command)))
5476
(with-help-window "*hoogle*"
5577
(with-current-buffer standard-output
5678
(insert output)
57-
(ansi-color-apply-on-region (point-min) (point-max))))))
79+
(ansi-color-apply-on-region (point-min) (point-max)))))))
5880

5981
;;;###autoload
6082
(defalias 'hoogle 'haskell-hoogle)
6183

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-
7084
;;;###autoload
7185
(defun haskell-hoogle-lookup-from-website (query)
7286
"Lookup QUERY at `haskell-hoogle-url'."

0 commit comments

Comments
 (0)