emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/haskell-tng-mode 4e2cf00 284/385: simplify the installatio


From: ELPA Syncer
Subject: [nongnu] elpa/haskell-tng-mode 4e2cf00 284/385: simplify the installation of hsinspect
Date: Tue, 5 Oct 2021 23:59:49 -0400 (EDT)

branch: elpa/haskell-tng-mode
commit 4e2cf006eb8c544ace8aafd2e8375dcb31dd8c8e
Author: Tseen She <ts33n.sh3@gmail.com>
Commit: Tseen She <ts33n.sh3@gmail.com>

    simplify the installation of hsinspect
---
 README.md                | 19 ++++++-------------
 haskell-tng-hsinspect.el | 29 ++++++++++++++++-------------
 2 files changed, 22 insertions(+), 26 deletions(-)

diff --git a/README.md b/README.md
index 6435488..b355e60 100644
--- a/README.md
+++ b/README.md
@@ -63,25 +63,18 @@ A full installation may look like the following
 
 The optional command line tool 
[`hsinspect`](https://gitlab.com/tseenshe/hsinspect) provides semantic 
information by using the `ghc` api.
 
-You must install `hsinspect` for every version of `ghc` that you plan to use, 
e.g.
+To use this feature you must install `hsinspect` command line tool and the 
`ghcflags` plugin to every `.cabal` file:
 
-```
-rm -f ~/.cabal/bin/hsinspect
-for V in 8.4.4 8.6.5 ; do
-  cabal v2-install hsinspect-0.0.7 -w ghc-$V -O2 &&
-  mv -f ~/.cabal/bin/hsinspect ~/.cabal/bin/hsinspect-ghc-$V
-done
-```
-
-And add the `ghcflags` compiler plugin to every project you plan to inspect:
-
-1. add a `build-depends` on `ghcflags`
-2. add `-fplugin GhcFlags.Plugin` to `ghc-options`
+1. `build-tool-depends: hsinspect-0.0.7` (or make `hsinspect` available 
globally, self-managing `ghc` versions)
+2. `build-depends: ghcflags-1.0.1`
+3. add `ghc-options: -fplugin GhcFlags.Plugin`
 
 The `haskell-tng-extra-company` package will automatically complete symbols 
that are in scope.
 
 To find out which module a symbol belongs to, use `M-x 
haskell-tng-fqn-at-point`.
 
+To automatically import a symbol at point, use `M-x 
haskell-tng-import-symbol-at-point`.
+
 ## Contrib
 
 Integrations are provided for common libraries and external applications.
diff --git a/haskell-tng-hsinspect.el b/haskell-tng-hsinspect.el
index 45332a2..f9085a7 100644
--- a/haskell-tng-hsinspect.el
+++ b/haskell-tng-hsinspect.el
@@ -104,18 +104,6 @@ name of the symbol at point in the minibuffer."
          (buffer-substring-no-properties (point-min) (point-max))))
     (user-error "could not find `.ghc.flags'.")))
 
-;; TODO rely on the build tool launching hsinspect, then drop .ghc.version
-;; (need a way to ensure we launch from the correct PWD)
-(defun haskell-tng--hsinspect-ghc ()
-  "Obtain the version of hsinspect that matches the project's compiler."
-  (if-let (default-directory (locate-dominating-file default-directory 
".ghc.version"))
-      (with-temp-buffer
-        (insert-file-contents (expand-file-name ".ghc.version"))
-        (concat
-         "hsinspect-ghc-"
-         (string-trim (buffer-substring-no-properties (point-min) 
(point-max)))))
-    (user-error "could not find `.ghc.version'.")))
-
 ;; TODO invalidate cache when imports section has changed
 (defvar-local haskell-tng--hsinspect-imports nil
   "Cache for the last `imports' call for this buffer.
@@ -139,6 +127,21 @@ t means the process failed.")
     (setq haskell-tng--hsinspect-index
           (haskell-tng--hsinspect "index"))))
 
+(defvar-local haskell-tng--hsinspect-exe nil)
+(defvar haskell-tng--hsinspect-which-hsinspect
+  "cabal exec -v0 which -- hsinspect")
+(defun haskell-tng--hsinspect-exe ()
+  "The binary to use for `hsinspect'"
+  (or
+   haskell-tng--hsinspect-exe
+   (setq
+    haskell-tng--hsinspect-exe
+    (let ((which (string-trim (shell-command-to-string 
haskell-tng--hsinspect-which-hsinspect))))
+      (if (file-exists-p which)
+          which
+        ;; fall back to system installed binary
+        "hsinspect")))))
+
 (defun haskell-tng--hsinspect (&rest params)
   (ignore-errors (kill-buffer "*hsinspect*"))
   (when-let ((ghcflags (haskell-tng--hsinspect-ghcflags))
@@ -148,7 +151,7 @@ t means the process failed.")
               (apply
                #'call-process
                ;; TODO async
-               (haskell-tng--hsinspect-ghc)
+               (haskell-tng--hsinspect-exe)
                nil "*hsinspect*" nil
                (append params '("--") ghcflags))))
         (user-error "`hsinspect' failed. See the *hsinspect* buffer for more 
information")



reply via email to

[Prev in Thread] Current Thread [Next in Thread]