Merge branch 'master' of git://github.com/dschoepe/ghc-mod into dschoepe-master
This commit is contained in:
commit
04c44083b5
@ -22,8 +22,9 @@
|
|||||||
(with-temp-buffer
|
(with-temp-buffer
|
||||||
(call-process "ghc-pkg" nil t nil "find-module" "--simple-output" mod)
|
(call-process "ghc-pkg" nil t nil "find-module" "--simple-output" mod)
|
||||||
(goto-char (point-min))
|
(goto-char (point-min))
|
||||||
(when (looking-at "^\\([^ ]+\\)-[0-9]")
|
(when (re-search-forward "\\([^ ]+\\)-\\([0-9]*\\(\\.[0-9]+\\)*\\)$")
|
||||||
(match-string-no-properties 1))))
|
(cons (match-string-no-properties 1)
|
||||||
|
(match-string-no-properties 2)))))
|
||||||
|
|
||||||
(defun ghc-resolve-document-path (pkg)
|
(defun ghc-resolve-document-path (pkg)
|
||||||
(with-temp-buffer
|
(with-temp-buffer
|
||||||
@ -36,17 +37,23 @@
|
|||||||
|
|
||||||
(defconst ghc-doc-local-format "file://%s/%s.html")
|
(defconst ghc-doc-local-format "file://%s/%s.html")
|
||||||
(defconst ghc-doc-hackage-format
|
(defconst ghc-doc-hackage-format
|
||||||
"http://hackage.haskell.org/packages/archive/%s/latest/doc/html/%s.html")
|
"http://hackage.haskell.org/packages/archive/%s/%s/doc/html/%s.html")
|
||||||
|
|
||||||
(defun ghc-display-document (pkg mod haskell-org)
|
(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 ?. ?-))
|
||||||
(url (if haskell-org
|
(url (if haskell-org
|
||||||
(format ghc-doc-hackage-format pkg mod-)
|
(format ghc-doc-hackage-format (car pkg) (cdr pkg) mod-)
|
||||||
(format ghc-doc-local-format
|
(let* ((pkg-with-ver (format "%s-%s" (car pkg) (cdr pkg)))
|
||||||
(ghc-resolve-document-path pkg) mod-))))
|
(path (ghc-resolve-document-path pkg-with-ver)))
|
||||||
|
(if (file-exists-p (format "%s/%s.html" path mod-))
|
||||||
|
(format ghc-doc-local-format path mod-)
|
||||||
|
;; fall back to online version if local file
|
||||||
|
;; doesn't exist:
|
||||||
|
(format ghc-doc-hackage-format (car pkg) (cdr pkg) mod-))))))
|
||||||
(browse-url url))))
|
(browse-url url))))
|
||||||
|
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
|
||||||
(defvar ghc-input-map nil)
|
(defvar ghc-input-map nil)
|
||||||
@ -70,4 +77,4 @@
|
|||||||
(if (looking-at "^\\(import\\|module\\) +\\(qualified +\\)?\\([^ (\n]+\\)")
|
(if (looking-at "^\\(import\\|module\\) +\\(qualified +\\)?\\([^ (\n]+\\)")
|
||||||
(match-string-no-properties 3))))
|
(match-string-no-properties 3))))
|
||||||
|
|
||||||
(provide 'ghc-doc)
|
(provide 'ghc-doc)
|
||||||
|
Loading…
Reference in New Issue
Block a user