Difference between revisions of "Haskell mode for Emacs/Hoogle.el"
DavidHouse (talk | contribs) |
DavidHouse (talk | contribs) |
||
(9 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
+ | '''DEPRECATED''' as of haskell-mode version 2.4. Use the function haskell-hoogle, provided by haskell-mode, instead. |
||
⚫ | |||
⚫ | |||
⚫ | |||
+ | |||
⚫ | |||
+ | You'll need [http://www.haskell.org/haskell-mode/ haskell-mode], at least version 2.2. |
||
+ | |||
+ | <pre-lisp> |
||
+ | ;;; hoogle.el --- functions for looking Haskell symbols up in Hoogle |
||
+ | |||
+ | ;; Copyright (C) 2007 |
||
+ | |||
+ | ;; Author: Andy Hefner <andy.hefner@verizon.net>, <clemens@endorphin.org>, David House <dmhouse@gmail.com> |
||
+ | ;; Maintainer: David House <dmhouse@gmail.com> |
||
+ | ;; Created: 2007 |
||
+ | ;; Version: 0.1 |
||
+ | ;; Keywords: doc, Haskell, Hoogle, search |
||
+ | |||
+ | ;;; Commentary: |
||
+ | |||
⚫ | |||
⚫ | |||
;; modified for Hoogle -- clemens@endorphin.org |
;; modified for Hoogle -- clemens@endorphin.org |
||
− | ;; Improved by David House <dmhouse@gmail.com> - Mar 07 |
+ | ;; Improved by David House <dmhouse@gmail.com> (BSD3 licensed)- Mar 07 |
+ | |||
+ | ;; This file is not part of GNU Emacs |
||
(require 'browse-url) |
(require 'browse-url) |
||
+ | (require 'haskell-mode) |
||
(eval-when-compile (require 'cl)) |
(eval-when-compile (require 'cl)) |
||
Line 13: | Line 33: | ||
(defvar hoogle-local-command "hoogle" |
(defvar hoogle-local-command "hoogle" |
||
"The name of the executable used for Hoogle. If this isn't |
"The name of the executable used for Hoogle. If this isn't |
||
− | found in $PATH (using executable-find), then a web lookup is used.") |
+ | found in $PATH (using `executable-find'), then a web lookup is used.") |
(defvar hoogle-always-use-web nil |
(defvar hoogle-always-use-web nil |
||
"Set to non-nil to always use web lookups.") |
"Set to non-nil to always use web lookups.") |
||
Line 22: | Line 42: | ||
"Lookup the identifier at point in Hoogle. If we can't find an |
"Lookup the identifier at point in Hoogle. If we can't find an |
||
identifier at the point, or with a prefix arg of 1, prompts for a |
identifier at the point, or with a prefix arg of 1, prompts for a |
||
− | name to look up. If we can find a |
+ | name to look up. If we can find a Hoogle in the $PATH (using |
− | executable-find), it will be used, |
+ | `executable-find' on `hoogle-local-command'), it will be used, |
− | is non-nil. For web Hoogling, the |
+ | unless `hoogle-always-use-web' is non-nil. For web Hoogling, the |
− | hoogle-url-base and browse-url is |
+ | name is appended to `hoogle-url-base' and `browse-url' is |
+ | invoked." |
||
(interactive "p") |
(interactive "p") |
||
(let ((symbol-name (haskell-ident-at-point))) |
(let ((symbol-name (haskell-ident-at-point))) |
||
Line 36: | Line 57: | ||
;; If we can find a local Hoogle, and the user hasn't told us to always use |
;; If we can find a local Hoogle, and the user hasn't told us to always use |
||
;; a web Hoogle, use the local Hoogle, otherwise use the web Hoogle. |
;; a web Hoogle, use the local Hoogle, otherwise use the web Hoogle. |
||
− | (if (and ( |
+ | (if (and (not hoogle-always-use-web) |
− | (executable-find |
+ | (fboundp 'executable-find) |
− | ( |
+ | (executable-find hoogle-local-command)) |
(let ((b (get-buffer-create "*Hoogle output*"))) |
(let ((b (get-buffer-create "*Hoogle output*"))) |
||
(shell-command (concat "hoogle " symbol-name) b) |
(shell-command (concat "hoogle " symbol-name) b) |
||
Line 46: | Line 67: | ||
(browse-url (concat hoogle-url-base symbol-name))))) |
(browse-url (concat hoogle-url-base symbol-name))))) |
||
− | (provide 'hoogle) |
+ | (provide 'hoogle) |
+ | ;;; hoogle.el ends here |
||
+ | </pre-lisp> |
Latest revision as of 17:12, 14 December 2007
DEPRECATED as of haskell-mode version 2.4. Use the function haskell-hoogle, provided by haskell-mode, instead.
An Emacs Lisp library to integrate Hoogle with Emacs. The documentation is mostly the docstring of the hoogle-lookup function.
You'll need haskell-mode, at least version 2.2.
<pre-lisp>
- hoogle.el --- functions for looking Haskell symbols up in Hoogle
- Copyright (C) 2007
- Author
- Andy Hefner <andy.hefner@verizon.net>, <clemens@endorphin.org>, David House <dmhouse@gmail.com>
- Maintainer
- David House <dmhouse@gmail.com>
- Created
- 2007
- Version
- 0.1
- Keywords
- doc, Haskell, Hoogle, search
- Commentary
- This code comes from hyperclim.el (public domain) and was originally written by
- Andy Hefner (andy.hefner@verizon.net)
- modified for Hoogle -- clemens@endorphin.org
- Improved by David House <dmhouse@gmail.com> (BSD3 licensed)- Mar 07
- This file is not part of GNU Emacs
(require 'browse-url) (require 'haskell-mode) (eval-when-compile (require 'cl))
(defvar hoogle-url-base "http://haskell.org/hoogle/?q="
"The base for the URL that will be used for web Hoogle lookups.")
(defvar hoogle-local-command "hoogle"
"The name of the executable used for Hoogle. If this isn't
found in $PATH (using `executable-find'), then a web lookup is used.") (defvar hoogle-always-use-web nil
"Set to non-nil to always use web lookups.")
(defvar hoogle-history nil
"The history of what you've Hoogled for.")
(defun hoogle-lookup (p)
"Lookup the identifier at point in Hoogle. If we can't find an
identifier at the point, or with a prefix arg of 1, prompts for a name to look up. If we can find a Hoogle in the $PATH (using `executable-find' on `hoogle-local-command'), it will be used, unless `hoogle-always-use-web' is non-nil. For web Hoogling, the name is appended to `hoogle-url-base' and `browse-url' is invoked."
(interactive "p") (let ((symbol-name (haskell-ident-at-point))) ;; Read a name to lookup from the minibuffer if we couldn't find one in the ;; file. (unless (and (= 1 p) (stringp symbol-name)) (setq symbol-name (read-from-minibuffer "Hoogle lookup name: " "" nil nil 'hoogle-history))) ;; If we can find a local Hoogle, and the user hasn't told us to always use ;; a web Hoogle, use the local Hoogle, otherwise use the web Hoogle. (if (and (not hoogle-always-use-web) (fboundp 'executable-find) (executable-find hoogle-local-command)) (let ((b (get-buffer-create "*Hoogle output*"))) (shell-command (concat "hoogle " symbol-name) b) (with-current-buffer b (toggle-read-only) (set-buffer-modified-p nil))) (browse-url (concat hoogle-url-base symbol-name)))))
(provide 'hoogle)
- hoogle.el ends here
</pre-lisp>