From bee19e1610913d73209e244278128f6d22a277aa Mon Sep 17 00:00:00 2001 From: debbie <148627186+webdevred@users.noreply.github.com> Date: Sun, 19 Oct 2025 22:40:29 +0200 Subject: [PATCH] Added a defcustom which enables users to view hoogle results in eww --- haskell-hoogle.el | 46 ++++++++++++++++++++++++++-------------------- 1 file changed, 26 insertions(+), 20 deletions(-) diff --git a/haskell-hoogle.el b/haskell-hoogle.el index 857af921..40a19073 100644 --- a/haskell-hoogle.el +++ b/haskell-hoogle.el @@ -59,6 +59,11 @@ If nil, use the Hoogle web-site." (const :tag "fp-complete" "https://www.stackage.org/lts/hoogle?q=%s") string)) +(defcustom haskell-hoogle-use-eww nil + "Whether to use Eww for viewing hoogle results." + :group 'haskell + :type 'hooolean) + ;;;###autoload (defun haskell-hoogle (query &optional info) "Do a Hoogle search for QUERY. @@ -66,26 +71,27 @@ If nil, use the Hoogle web-site." If prefix argument INFO is given, then `haskell-hoogle-command' is asked to show extra info for the items matching QUERY.." (interactive (append (hoogle-prompt) current-prefix-arg)) - (if (null haskell-hoogle-command) - (browse-url (format haskell-hoogle-url (url-hexify-string query))) - (let* ((command (concat (if (functionp haskell-hoogle-command) - (funcall haskell-hoogle-command) - haskell-hoogle-command) - (if info " -i " "") - " --color " (shell-quote-argument query))) - (output (shell-command-to-string command))) - (with-help-window "*hoogle*" - (with-current-buffer standard-output - (let ((outs (ansi-color-filter-apply output))) - (delay-mode-hooks (haskell-mode)) - (if info - (let ((lns (split-string output "\n" t " "))) - (insert (car lns) "\n\n") - (dolist (ln (cdr lns)) (insert "-- " ln "\n"))) - (insert outs) - (forward-line -1) - (when (looking-at-p "^plus more results") (insert "\n-- "))) - (view-mode))))))) + (cond + (haskell-hoogle-use-eww (eww (format haskell-hoogle-url (url-hexify-string query)))) + ((null haskell-hoogle-command) (browse-url (format haskell-hoogle-url (url-hexify-string query)))) + (t (let* ((command (concat (if (functionp haskell-hoogle-command) + (funcall haskell-hoogle-command) + haskell-hoogle-command) + (if info " -i " "") + " --color " (shell-quote-argument query))) + (output (shell-command-to-string command))) + (with-help-window "*hoogle*" + (with-current-buffer standard-output + (let ((outs (ansi-color-filter-apply output))) + (delay-mode-hooks (haskell-mode)) + (if info + (let ((lns (split-string output "\n" t " "))) + (insert (car lns) "\n\n") + (dolist (ln (cdr lns)) (insert "-- " ln "\n"))) + (insert outs) + (forward-line -1) + (when (looking-at-p "^plus more results") (insert "\n-- "))) + (view-mode)))))))) ;;;###autoload (defalias 'hoogle 'haskell-hoogle)