C-uM-C-d browse hackage.
This commit is contained in:
parent
387bf83f37
commit
4fd1aa963a
@ -11,12 +11,12 @@
|
||||
|
||||
;;; Code:
|
||||
|
||||
(defun ghc-browse-document ()
|
||||
(interactive)
|
||||
(defun ghc-browse-document (&optional haskell-org)
|
||||
(interactive "P")
|
||||
(let* ((mod0 (ghc-extract-module))
|
||||
(mod (ghc-read-module-name mod0))
|
||||
(pkg (ghc-resolve-package-name mod)))
|
||||
(ghc-display-document pkg mod)))
|
||||
(ghc-display-document pkg mod haskell-org)))
|
||||
|
||||
(defun ghc-resolve-package-name (mod)
|
||||
(with-temp-buffer
|
||||
@ -32,11 +32,17 @@
|
||||
(when (looking-at "^haddock-html: \\([^ \n]+\\)$")
|
||||
(match-string-no-properties 1))))
|
||||
|
||||
(defun ghc-display-document (pkg mod)
|
||||
(defvar ghc-doc-local-format "file://%s/%s.html")
|
||||
(defvar ghc-doc-hackage-format
|
||||
"http://hackage.haskell.org/packages/archive/%s/latest/doc/html/%s.html")
|
||||
|
||||
(defun ghc-display-document (pkg mod haskell-org)
|
||||
(when (and pkg mod)
|
||||
(let* ((mod- (ghc-replace-character mod ?. ?-))
|
||||
(path (ghc-resolve-document-path pkg))
|
||||
(url (format "file://%s/%s.html" path mod-)))
|
||||
(url (if haskell-org
|
||||
(format ghc-doc-hackage-format pkg mod-)
|
||||
(format ghc-doc-local-format
|
||||
(ghc-resolve-document-path pkg) mod-))))
|
||||
(browse-url url))))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
@ -50,5 +56,4 @@
|
||||
(make-sparse-keymap)))
|
||||
(define-key ghc-input-map "\t" 'ghc-complete))
|
||||
|
||||
|
||||
(provide 'ghc-doc)
|
@ -10,9 +10,10 @@
|
||||
|
||||
(defun ghc-replace-character (string from to)
|
||||
"Replace characters equal to FROM to TO in STRING."
|
||||
(dotimes (cnt (length string) string)
|
||||
(if (char-equal (aref string cnt) from)
|
||||
(aset string cnt to))))
|
||||
(let ((ret (copy-sequence string)))
|
||||
(dotimes (cnt (length ret) ret)
|
||||
(if (char-equal (aref ret cnt) from)
|
||||
(aset ret cnt to)))))
|
||||
|
||||
(defun ghc-which (cmd)
|
||||
(catch 'loop
|
||||
|
Loading…
Reference in New Issue
Block a user