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