[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/haskell-tng-mode 99a7f10 337/385: cleanup
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/haskell-tng-mode 99a7f10 337/385: cleanup |
Date: |
Wed, 6 Oct 2021 00:00:00 -0400 (EDT) |
branch: elpa/haskell-tng-mode
commit 99a7f100719679780ab520b7fbef95e551cf4046
Author: Tseen She <ts33n.sh3@gmail.com>
Commit: Tseen She <ts33n.sh3@gmail.com>
cleanup
---
haskell-tng-hsinspect.el | 68 +++++++++++++++++++++++-------------------------
1 file changed, 32 insertions(+), 36 deletions(-)
diff --git a/haskell-tng-hsinspect.el b/haskell-tng-hsinspect.el
index 339a124..89fe042 100644
--- a/haskell-tng-hsinspect.el
+++ b/haskell-tng-hsinspect.el
@@ -57,42 +57,38 @@ TODO: support local / git packages by consulting
`plan.json'"
(index (haskell-tng--hsinspect-index alt))
;; TODO imports and index can be calculated in parallel
(sym (haskell-tng--hsinspect-symbol-at-point))
- (found (haskell-tng--hsinspect-qualify imports sym))
- ;; TODO pcase would be better here
- (parts (haskell-tng--string-split-last found "."))
- (name (cdr parts))
- (followed (haskell-tng--hsinspect-follow index nil (car parts)
name))
- (srcid (car followed))
- (module (cdr followed))
- (tarball (haskell-tng--hsinspect-srcid-source srcid))
- (file (concat
- ;; TODO string-replace would be nice...
- (mapconcat 'identity (split-string module (rx ".")) "/" )
- ".hs")))
- (when (not (file-exists-p tarball))
- ;; NOTE we can't do this with stack because it doesn't have the
equivalent
- ;; of the "get" command. Also, it is not clear where stack puts source
- ;; code, so no point looking.
- ;;
- ;; WORKAROUND https://github.com/haskell/cabal/issues/6443
- ;; TODO curl or a built-in emacs downloader, so cabal is not necessary
- (shell-command (format "cabal get %s -d /var/empty &" srcid))
- (error "%s was not found, attempting to download: please try again
later" tarball))
-
- (message "Loading %s from %s" sym tarball)
- (find-file tarball)
- (let ((archive (current-buffer)))
- (goto-char (point-min))
- (re-search-forward (rx-to-string `(: (* any) ,file)))
- (tar-extract)
- (kill-buffer archive)
- (read-only-mode 1)
- (goto-char (point-min))
- ;; TODO re-use the imenu top-level parser, this is a massive hack
- (re-search-forward (rx line-start "import" word-end) nil t)
- (or
- (re-search-forward (rx-to-string `(: (| bol "| " "data " "type " "class
") ,name symbol-end)) nil t)
- (re-search-forward (rx-to-string `(: symbol-start ,name
symbol-end)))))))
+ (found (haskell-tng--hsinspect-qualify imports sym)))
+ (pcase-let* ((`(,imported . ,name) (haskell-tng--string-split-last found
"."))
+ (`(,srcid . ,module) (haskell-tng--hsinspect-follow index nil
imported name))
+ (tarball (haskell-tng--hsinspect-srcid-source srcid))
+ (file (concat
+ ;; TODO string-replace would be nice...
+ (mapconcat 'identity (split-string module (rx "."))
"/" )
+ ".hs")))
+ (when (not (file-exists-p tarball))
+ ;; NOTE we can't do this with stack because it doesn't have the
equivalent
+ ;; of the "get" command. Also, it is not clear where stack puts source
+ ;; code, so no point looking.
+ ;;
+ ;; WORKAROUND https://github.com/haskell/cabal/issues/6443
+ ;; TODO curl or a built-in emacs downloader, so cabal is not necessary
+ (shell-command (format "cabal get %s -d /var/empty &" srcid))
+ (error "%s was not found, attempting to download: please try again
later" tarball))
+
+ (message "Loading %s from %s" sym tarball)
+ (find-file tarball)
+ (let ((archive (current-buffer)))
+ (goto-char (point-min))
+ (re-search-forward (rx-to-string `(: (* any) ,file)))
+ (tar-extract)
+ (kill-buffer archive)
+ (read-only-mode 1)
+ (goto-char (point-min))
+ ;; TODO re-use the imenu top-level parser, this is a massive hack
+ (re-search-forward (rx line-start "import" word-end) nil t)
+ (or
+ (re-search-forward (rx-to-string `(: (| bol "| " "data " "type "
"class ") ,name symbol-end)) nil t)
+ (re-search-forward (rx-to-string `(: symbol-start ,name
symbol-end))))))))
(defun haskell-tng--string-split-last (str sep)
"Return `(front . back)' of a STR split on the last SEP."
- [nongnu] elpa/haskell-tng-mode 3939303 334/385: importing from the hsinspect index will update the buffer cache, (continued)
- [nongnu] elpa/haskell-tng-mode 3939303 334/385: importing from the hsinspect index will update the buffer cache, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 3ea52c1 341/385: special case jumping to inplace packages, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 4217d98 378/385: fixup! third party tools use project specific PATH, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode f7f0e0f 383/385: moar extras, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 2017d07 384/385: widen hsinspect range, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 083e80a 110/385: assert on alternative indentation order, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode ec1ac46 361/385: document a bug, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 4b598b2 377/385: third party tools use project specific PATH, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode aaf7c55 370/385: support for hsinspect-lsp, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode b3e6c9a 113/385: compilation mode regression tests vs haskell-mode, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 99a7f10 337/385: cleanup,
ELPA Syncer <=
- [nongnu] elpa/haskell-tng-mode e6d8761 343/385: local jump-to-definition should error, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode c31afdb 272/385: missing CPP case, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 85c4dd5 233/385: fix bugfix in goto-import, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 5c157fb 255/385: rigid ormolu support, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 64ec84d 260/385: if/then/else indentation, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 1d53572 243/385: bugfixes, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode d1e599a 285/385: switch formatting backend based on project config, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode fd06b8f 264/385: move haskell-tng-newline into the -extra package, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 8ff79e7 247/385: allow parallelism, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 4e2cf00 284/385: simplify the installation of hsinspect, ELPA Syncer, 2021/10/06