[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/haskell-tng-mode 73a60f5 309/385: cache `which hsinspect`
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/haskell-tng-mode 73a60f5 309/385: cache `which hsinspect` per project |
Date: |
Tue, 5 Oct 2021 23:59:54 -0400 (EDT) |
branch: elpa/haskell-tng-mode
commit 73a60f5a1292556f27fb301e0746024426c0b860
Author: Tseen She <ts33n.sh3@gmail.com>
Commit: Tseen She <ts33n.sh3@gmail.com>
cache `which hsinspect` per project
---
haskell-tng-compile.el | 5 +++++
haskell-tng-extra-projectile.el | 5 -----
haskell-tng-extra-stack.el | 1 +
haskell-tng-hsinspect.el | 40 ++++++++++++++++++++--------------------
4 files changed, 26 insertions(+), 25 deletions(-)
diff --git a/haskell-tng-compile.el b/haskell-tng-compile.el
index 0fcd3fd..ee8b21e 100644
--- a/haskell-tng-compile.el
+++ b/haskell-tng-compile.el
@@ -73,6 +73,11 @@
(defvar haskell-tng--compile-dominating-package
(rx (| (: (+ any) ".cabal") "package.yaml")))
+;; Not guaranteed to exist for cabal-install, always fall back to
+;; dominating-package when searching for the dominating project.
+(defvar haskell-tng--compile-dominating-project
+ (rx (| "cabal.project" "cabal.project.local" "cabal.project.freeze")))
+
(defun haskell-tng-compile (&optional edit-command)
"`compile' specialised to Haskell:
diff --git a/haskell-tng-extra-projectile.el b/haskell-tng-extra-projectile.el
index ed6cde9..4fbf108 100644
--- a/haskell-tng-extra-projectile.el
+++ b/haskell-tng-extra-projectile.el
@@ -12,11 +12,6 @@
;; TODO fix the haskell-stack detection to also include cabal
;; TODO populate the projectile compile/run/test commands
-;; ;; Not guaranteed to exist for cabal-install, always fall back to
-;; ;; dominating-package when searching for the dominating project.
-;; (defvar haskell-tng--compile-dominating-project
-;; (rx (| "cabal.project" "cabal.project.local" "cabal.project.freeze")))
-
(make-variable-buffer-local 'projectile-tags-command)
(add-hook
'haskell-tng-mode-hook
diff --git a/haskell-tng-extra-stack.el b/haskell-tng-extra-stack.el
index 810e8b9..ee0ab33 100644
--- a/haskell-tng-extra-stack.el
+++ b/haskell-tng-extra-stack.el
@@ -13,6 +13,7 @@
(require 'haskell-tng-hsinspect)
(setq
+ haskell-tng--compile-dominating-project (rx "stack.yaml")
haskell-tng--hsinspect-which-hsinspect "stack exec --silent which --
hsinspect"
haskell-tng--compile-history '("stack build --fast --no-interleaved-output
--ghc-options=\"-j\" --no-run-tests"
"stack build --fast --no-interleaved-output
--ghc-options=\"-j\""))
diff --git a/haskell-tng-hsinspect.el b/haskell-tng-hsinspect.el
index 4b72c99..5c7eabe 100644
--- a/haskell-tng-hsinspect.el
+++ b/haskell-tng-hsinspect.el
@@ -119,48 +119,48 @@ A prefix argument ensures that caches are flushes."
(defvar-local haskell-tng--hsinspect-imports nil)
(defun haskell-tng--hsinspect-imports (&optional no-work flush-cache)
(haskell-tng--hsinspect-cached
- (lambda () (haskell-tng--hsinspect "imports" buffer-file-name))
+ (lambda () (haskell-tng--hsinspect flush-cache "imports" buffer-file-name))
'haskell-tng--hsinspect-imports
(concat "hsinspect-0.0.7" buffer-file-name "." "imports")
no-work
flush-cache))
-;; TODO use a package specific variable buffer
+;; TODO add a package-wide variable cache
(defun haskell-tng--hsinspect-index (&optional flush-cache)
(when-let (ghcflags-dir
(locate-dominating-file default-directory ".ghc.flags"))
(haskell-tng--hsinspect-cached-disk
- (lambda () (haskell-tng--hsinspect "index"))
+ (lambda () (haskell-tng--hsinspect flush-cache "index"))
(concat "hsinspect-0.0.7" (expand-file-name ghcflags-dir) "index")
nil
flush-cache)))
-;; FIXME use a project-wide cache
-(defvar-local haskell-tng--hsinspect-exe nil)
+;; TODO add a project-wide variable cache
(defvar haskell-tng--hsinspect-which-hsinspect
"cabal exec -v0 which -- hsinspect")
-(defun haskell-tng--hsinspect-exe ()
+(defun haskell-tng--hsinspect-exe (&optional flush-cache)
"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
- ;; TODO don't do this, prefer an error message
- "hsinspect")))))
-
-(defun haskell-tng--hsinspect (&rest params)
+ (when-let (package-dir (or
+ (haskell-tng--util-locate-dominating-file
+ haskell-tng--compile-dominating-project)
+ (haskell-tng--util-locate-dominating-file
+ haskell-tng--compile-dominating-package)))
+ (haskell-tng--hsinspect-cached-disk
+ (lambda () (string-trim (shell-command-to-string
haskell-tng--hsinspect-which-hsinspect)))
+ (concat "which" (expand-file-name package-dir) "hsinspect")
+ nil
+ flush-cache)))
+
+(defun haskell-tng--hsinspect (flush-cache &rest params)
(ignore-errors (kill-buffer "*hsinspect*"))
(when-let ((ghcflags (haskell-tng--hsinspect-ghcflags))
- ;; TODO search for the .cabal file and then delete .ghc.version
support
- (default-directory (locate-dominating-file default-directory
".ghc.version")))
+ (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
- (haskell-tng--hsinspect-exe)
+ (haskell-tng--hsinspect-exe flush-cache)
nil "*hsinspect*" nil
(append params '("--") ghcflags))))
(user-error "`hsinspect' failed. See the *hsinspect* buffer for more
information")
- [nongnu] elpa/haskell-tng-mode 6f2b5ee 266/385: font lock CPP, (continued)
- [nongnu] elpa/haskell-tng-mode 6f2b5ee 266/385: font lock CPP, ELPA Syncer, 2021/10/06
- [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 <=
- [nongnu] elpa/haskell-tng-mode 5707166 365/385: use new ghcflags-provided PATH, ELPA Syncer, 2021/10/06
- [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