[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/haskell-tng-mode 388df13 282/385: refactor calls to hsinsp
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/haskell-tng-mode 388df13 282/385: refactor calls to hsinspect to allow for more callers |
Date: |
Tue, 5 Oct 2021 23:59:47 -0400 (EDT) |
branch: elpa/haskell-tng-mode
commit 388df1371ed92d7c34afb17153594cf955c6d593
Author: Tseen She <ts33n.sh3@gmail.com>
Commit: Tseen She <ts33n.sh3@gmail.com>
refactor calls to hsinspect to allow for more callers
---
haskell-tng-hsinspect.el | 46 +++++++++++++++++++++++-----------------------
1 file changed, 23 insertions(+), 23 deletions(-)
diff --git a/haskell-tng-hsinspect.el b/haskell-tng-hsinspect.el
index 2a0d146..202fd95 100644
--- a/haskell-tng-hsinspect.el
+++ b/haskell-tng-hsinspect.el
@@ -63,9 +63,8 @@ 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 maybe we should just rely on the build tool being able to launch the
-;; correct version of hsinspect, then we can drop the need for .ghc.version
-;; files.
+;; 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"))
@@ -77,8 +76,6 @@ name of the symbol at point in the minibuffer."
(user-error "could not find `.ghc.version'.")))
;; TODO invalidate cache when imports section has changed
-;; TODO is there a way to tell Emacs not to render this in `C-h v'?
-;; (suggestion is to advise around describe-key)
(defvar-local haskell-tng--hsinspect-imports nil
"Cache for the last `imports' call for this buffer.
t means the process failed.")
@@ -87,24 +84,27 @@ t means the process failed.")
(unless (eq t haskell-tng--hsinspect-imports)
haskell-tng--hsinspect-imports)
(setq haskell-tng--hsinspect-imports t) ;; avoid races
- (ignore-errors (kill-buffer "*hsinspect*"))
- (when-let ((ghcflags (haskell-tng--hsinspect-ghcflags))
- (default-directory (locate-dominating-file default-directory
".ghc.version")))
- (if (/= 0
- (let ((process-environment (cons "GHC_ENVIRONMENT=-"
process-environment)))
- (apply
- #'call-process
- ;; TODO async
- (haskell-tng--hsinspect-ghc)
- nil "*hsinspect*" nil
- ;; need to disable all warnings
- (append `("imports" ,buffer-file-name "--") ghcflags))))
- (user-error "`hsinspect' failed. See the *hsinspect* buffer for more
information")
- (setq haskell-tng--hsinspect-imports
- (with-current-buffer "*hsinspect*"
- (goto-char (point-max))
- (backward-sexp)
- (or (ignore-errors (read (current-buffer))) t)))))))
+ (setq haskell-tng--hsinspect-imports
+ (haskell-tng--hsinspect "imports" buffer-file-name))))
+
+(defun haskell-tng--hsinspect (&rest params)
+ (ignore-errors (kill-buffer "*hsinspect*"))
+ (when-let ((ghcflags (haskell-tng--hsinspect-ghcflags))
+ (default-directory (locate-dominating-file default-directory
".ghc.version")))
+ (if (/= 0
+ (let ((process-environment (cons "GHC_ENVIRONMENT=-"
process-environment)))
+ (apply
+ #'call-process
+ ;; TODO async
+ (haskell-tng--hsinspect-ghc)
+ nil "*hsinspect*" nil
+ (append params '("--") ghcflags))))
+ (user-error "`hsinspect' failed. See the *hsinspect* buffer for more
information")
+ (with-current-buffer "*hsinspect*"
+ ;; TODO remove this resilience against stdout / stderr noise when
debugging hsinspect
+ (goto-char (point-max))
+ (backward-sexp)
+ (or (ignore-errors (read (current-buffer))) t)))))
(provide 'haskell-tng-hsinspect)
;;; haskell-tng-hsinspect.el ends here
- [nongnu] elpa/haskell-tng-mode e0fd8f4 303/385: abstract the hsinspect caching logic, (continued)
- [nongnu] elpa/haskell-tng-mode e0fd8f4 303/385: abstract the hsinspect caching logic, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 4dc6f76 313/385: fix hsinspect discoverability, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode eb4591f 287/385: document popup dependency, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 48729c8 308/385: more cache cleanups, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 6299e6d 317/385: amazeballs idea, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode aa9cdbb 226/385: hacky file-specific language extensions, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode a4f06f5 237/385: an idea, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 0113f37 273/385: hsinspect should work on symbols with FQNs, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 06e4e76 245/385: support running scripts on nix, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 3179294 267/385: rename ormolu command, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 388df13 282/385: refactor calls to hsinspect to allow for more callers,
ELPA Syncer <=
- [nongnu] elpa/haskell-tng-mode 067e8a7 280/385: bugfix fontification of erroneous matches inside strings, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 224e955 307/385: add screencasts to the README, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode b59ce04 356/385: improve testing, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode ee1fb28 345/385: small cleanup, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 1310276 346/385: planning, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 09018bc 352/385: support hsinspect beta releases, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode e73bc19 335/385: jump-to-definition, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 2f2c500 354/385: defining a test spec, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 232baf8 362/385: less import suggestions, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode ab53433 375/385: reprioritise, ELPA Syncer, 2021/10/06