[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/haskell-tng-mode 5707166 365/385: use new ghcflags-provide
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/haskell-tng-mode 5707166 365/385: use new ghcflags-provided PATH |
Date: |
Wed, 6 Oct 2021 00:00:05 -0400 (EDT) |
branch: elpa/haskell-tng-mode
commit 57071666f725abc4f4fefdbe9a21c4015bb17020
Author: Tseen She <ts33n.sh3@gmail.com>
Commit: Tseen She <ts33n.sh3@gmail.com>
use new ghcflags-provided PATH
---
haskell-tng-hsinspect.el | 49 +++++++++++++++++++++++++++++-------------------
1 file changed, 30 insertions(+), 19 deletions(-)
diff --git a/haskell-tng-hsinspect.el b/haskell-tng-hsinspect.el
index fb4c705..7231c59 100644
--- a/haskell-tng-hsinspect.el
+++ b/haskell-tng-hsinspect.el
@@ -436,6 +436,13 @@ When using hsinspect-0.0.9, also: srcid."
(buffer-substring-no-properties (point-min) (point-max))))
(user-error "Could not find `.ghc.flags': add GhcFlags.Plugin and
compile.")))
+(defun haskell-tng--hsinspect-ghcpath ()
+ "Obtain the ghc PATH for the current buffer. Only supported by
ghcflags-1.0.3+"
+ (when-let (default-directory (locate-dominating-file default-directory
".ghc.path"))
+ (with-temp-buffer
+ (insert-file-contents (expand-file-name ".ghc.path"))
+ (buffer-substring-no-properties (point-min) (point-max)))))
+
(defvar-local haskell-tng--hsinspect-imports nil)
(defun haskell-tng--hsinspect-imports (&optional no-work flush-cache)
(haskell-tng--util-cached
@@ -483,8 +490,6 @@ Does not persist the cache changes to disk."
nil
flush-cache)))
-;; TODO discover the PATH from the build tool and set it when calling hsinspect
-
(defvar haskell-tng--hsinspect-which-hsinspect
"cabal build -v0 :pkg:hsinspect:exe:hsinspect && cabal exec -v0 which --
hsinspect")
(defun haskell-tng--hsinspect-which-hsinspect ()
@@ -512,23 +517,29 @@ This is uncached, prefer `haskell-tng--hsinspect-exe'."
(defun haskell-tng--hsinspect (flush-cache &rest params)
(ignore-errors (kill-buffer "*hsinspect*"))
- (when-let ((ghcflags (haskell-tng--hsinspect-ghcflags))
- (default-directory (haskell-tng--util-locate-dominating-file
- haskell-tng--compile-dominating-package)))
- (if (/= 0
- (let ((process-environment (cons "GHC_ENVIRONMENT=-"
process-environment)))
- (apply
- #'call-process
- (or (haskell-tng--hsinspect-exe flush-cache)
- (user-error "Could not find hsinspect: add to
build-tool-depends"))
- nil "*hsinspect*" nil
- (append params '("--") ghcflags))))
- (user-error "Failed, see *hsinspect* buffer for more information")
- (with-current-buffer "*hsinspect*"
- ;; TODO remove this resilience against stdout / stderr noise
- (goto-char (point-max))
- (backward-sexp)
- (ignore-errors (read (current-buffer)))))))
+ (let ((ghcpath (haskell-tng--hsinspect-ghcpath)))
+ (when-let ((ghcflags (haskell-tng--hsinspect-ghcflags))
+ (default-directory (haskell-tng--util-locate-dominating-file
+ haskell-tng--compile-dominating-package)))
+ (if (/= 0
+ (let ((process-environment (cons "GHC_ENVIRONMENT=-"
process-environment)))
+ ;; override PATH if we know a better one
+ (when ghcpath
+ (setq process-environment
+ (cons (concat "PATH=" ghcpath) process-environment)))
+ (message "DEBUG: %S" process-environment)
+ (apply
+ #'call-process
+ (or (haskell-tng--hsinspect-exe flush-cache)
+ (user-error "Could not find hsinspect: add to
build-tool-depends"))
+ nil "*hsinspect*" nil
+ (append params '("--") ghcflags))))
+ (user-error "Failed, see *hsinspect* buffer for more information")
+ (with-current-buffer "*hsinspect*"
+ ;; TODO remove this resilience against stdout / stderr noise
+ (goto-char (point-max))
+ (backward-sexp)
+ (ignore-errors (read (current-buffer))))))))
(defun haskell-tng-hsinspect (&optional alt)
"Fill the `hsinspect' caches"
- [nongnu] elpa/haskell-tng-mode fdbd0a2 239/385: updates for hsinspect, (continued)
- [nongnu] elpa/haskell-tng-mode fdbd0a2 239/385: updates for hsinspect, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode b2e2c3a 293/385: stop stack from being an asshole, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode ee07f6d 172/385: type indentation tests, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 59354b6 198/385: support hanging type alignment, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode a788ab2 209/385: more efficient layout caching, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode f7e8040 213/385: = ends a type sig, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode fe9d65d 222/385: helper for yatemplates, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode bc93c3d 224/385: very alpha hsinspect support, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 658ddb6 251/385: docs, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 73a60f5 309/385: cache `which hsinspect` per project, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 5707166 365/385: use new ghcflags-provided PATH,
ELPA Syncer <=
- [nongnu] elpa/haskell-tng-mode b1c664b 364/385: allow hsinspect population in the background, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode ce17d96 376/385: new hsinspect release, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode eb6b487 357/385: test fqn-at-point and fix a longstanding bug, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 103e758 325/385: expose some more hsinspect-0.0.8 index info, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 374835c 355/385: a test for interactive commands, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode e3c6dc6 336/385: follow re-exports, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 9904e72 366/385: jump-to-definition works inside the project, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 1c68e79 381/385: requires emacs 27, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 55d8e69 385/385: upgrade hsinspect, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 97e4a66 379/385: bump hsinspect, ELPA Syncer, 2021/10/06