This commit is contained in:
Daniel Gröber 2015-08-18 03:50:40 +02:00
commit 58ae1271a3
2 changed files with 25 additions and 4 deletions

View File

@ -10,6 +10,17 @@
(require 'ghc-comp)
(require 'ghc-info)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; Customize Variables
;;;
(defcustom ghc-doc-browser-function #'browse-url
"Function used to browse documentation."
:type '(radio (function-item browse-url)
(function-item ghc-browse-url-safari))
:group 'ghc-mod)
;;; Code:
(defun ghc-browse-document (&optional haskell-org)
@ -43,9 +54,18 @@
(defconst ghc-doc-hackage-format
"http://hackage.haskell.org/packages/archive/%s/%s/doc/html/%s.html")
(defun ghc-browse-url-safari (uri &rest args)
"Open a URI in Safari using AppleScript. This preserves anchors."
(let ((script (format "
tell application \"Safari\"
open location \"%s\"
activate
end tell" uri)))
(do-applescript script)))
(defun ghc-display-document (pkg-ver-path mod haskell-org &optional symbol)
(let* ((mod- (ghc-replace-character mod ?. ?-))
(pkg (ghc-pkg-ver-path-get-pkg pkg-ver-path))
(let* ((pkg (ghc-pkg-ver-path-get-pkg pkg-ver-path))
(mod- (ghc-replace-character mod ?. ?-))
(ver (ghc-pkg-ver-path-get-ver pkg-ver-path))
(path (ghc-pkg-ver-path-get-path pkg-ver-path))
(pkg-with-ver (format "%s-%s" pkg ver))
@ -54,8 +74,7 @@
(file (format "%s/%s.html" path mod-))
(url0 (if (or haskell-org (not (file-exists-p file))) remote local))
(url (if symbol (ghc-add-anchor url0 symbol) url0)))
;; Mac's "open" removes the anchor from "file://", sigh.
(browse-url url)))
(funcall ghc-doc-browser-function url)))
(defun ghc-add-anchor (url symbol)
(let ((case-fold-search nil))

View File

@ -30,6 +30,8 @@
(defconst ghc-version "5.3.0.0")
(defgroup ghc-mod '() "ghc-mod customization")
;; (eval-when-compile
;; (require 'haskell-mode))