[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/haskell-tng-mode ff76e07 304/385: cache the index command
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/haskell-tng-mode ff76e07 304/385: cache the index command |
Date: |
Tue, 5 Oct 2021 23:59:53 -0400 (EDT) |
branch: elpa/haskell-tng-mode
commit ff76e07f5de6e766b17617e4c86f4bbcca54ed9d
Author: Tseen She <ts33n.sh3@gmail.com>
Commit: Tseen She <ts33n.sh3@gmail.com>
cache the index command
---
haskell-tng-hsinspect.el | 36 +++++++++++++++++++-----------------
1 file changed, 19 insertions(+), 17 deletions(-)
diff --git a/haskell-tng-hsinspect.el b/haskell-tng-hsinspect.el
index fb59fed..a3a46b4 100644
--- a/haskell-tng-hsinspect.el
+++ b/haskell-tng-hsinspect.el
@@ -46,14 +46,14 @@ A prefix argument ensures that caches are flushes."
(message "<not imported>"))))
;;;###autoload
-(defun haskell-tng-import-symbol-at-point ()
+(defun haskell-tng-import-symbol-at-point (&optional alt)
"Import the symbol at point"
- ;; TODO prefix + FQN should mean use unqualified `as' import
- ;; TODO prefix + unqualified should mean to import entire module
+ ;; TODO double prefix + FQN should mean use unqualified `as' import
+ ;; TODO double prefix + unqualified should mean to import entire module
;; TODO shortlist for FQN imports (no need to calc the index)
- (interactive)
+ (interactive "P")
;; TODO update the hsinspect-imports cache
- (when-let* ((index (haskell-tng--hsinspect-index))
+ (when-let* ((index (haskell-tng--hsinspect-index alt))
(sym (haskell-tng--hsinspect-symbol-at-point)))
(message "Seaching for '%s' in %s modules" sym (length index))
(if (string-match (rx bos (group (+ anything)) "." (group (+ (not (any
".")))) eos) sym)
@@ -130,6 +130,19 @@ t means the process failed.")
allow-work
flush-cache))
+(defvar-local haskell-tng--hsinspect-index nil
+ "Cache for the last `index' call for this buffer.
+t means the process failed.")
+(defun haskell-tng--hsinspect-index (flush-cache)
+ (when-let (ghcflags-dir
+ (locate-dominating-file default-directory ".ghc.flags"))
+ (haskell-tng--hsinspect-cached-cmd
+ 'haskell-tng--hsinspect-index
+ (concat (expand-file-name ghcflags-dir) ".index")
+ '("index")
+ t
+ flush-cache)))
+
(defun haskell-tng--hsinspect-cached-cmd (buffer-local-cache
disk-cache
args
@@ -174,18 +187,7 @@ t means the process failed.")
(when (not (eq t (symbol-value buffer-local-cache)))
(symbol-value buffer-local-cache)))
-;; FIXME this can be more efficiently cached alongside the .ghc.flags file,
not per source file
-;; (it's also fast to load so maybe persist it in a cache dir and check
timestamps)
-(defvar-local haskell-tng--hsinspect-index nil)
-(defun haskell-tng--hsinspect-index (&optional lookup-only)
- (if (or lookup-only haskell-tng--hsinspect-index)
- (unless (eq t haskell-tng--hsinspect-index)
- haskell-tng--hsinspect-index)
- (setq haskell-tng--hsinspect-index t) ;; avoid races
- (setq haskell-tng--hsinspect-index
- (haskell-tng--hsinspect "index"))))
-
-;; FIXME cache per project (or package at least)
+;; TODO cache per project (or package at least)
(defvar-local haskell-tng--hsinspect-exe nil)
(defvar haskell-tng--hsinspect-which-hsinspect
"cabal exec -v0 which -- hsinspect")
- [nongnu] elpa/haskell-tng-mode dbbe488 265/385: abbrevs don't fire in comments / strings, (continued)
- [nongnu] elpa/haskell-tng-mode dbbe488 265/385: abbrevs don't fire in comments / strings, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode f56bd2a 256/385: prefer optimised hsinspect builds, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode e84970b 263/385: rename -contrib to -extra, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode af443a1 269/385: fix a name clash in the tests, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode cce466c 271/385: hsinspect now has a compiler plugin, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode d0cd9b9 252/385: documenting an annoying indentation bug, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode afbac7c 300/385: missing import, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 7060573 286/385: moar work to do here, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 89db192 289/385: more thots, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode b46dbd1 305/385: refactoring of the cache for more reuse later, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode ff76e07 304/385: cache the index command,
ELPA Syncer <=
- [nongnu] elpa/haskell-tng-mode 2653ce7 312/385: checks on the hsinspect binary, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode da20f0d 314/385: note about limitations on nixos, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 52d984a 324/385: fix cache typo, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode ae8ebbc 320/385: thots, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode aca98c2 333/385: simplify import-symbol-at-point logic, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 1e3c465 329/385: import types and data constructors, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 3ab7495 342/385: thots, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode ef3cea6 340/385: thots, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode a14a2c2 332/385: allow dir locals for the -as lookups, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 2050c16 323/385: bad parameter order, ELPA Syncer, 2021/10/06