Skip to content

Commit 632be9e

Browse files
vemvexpez
authored andcommitted
Add hooks around warming AST cache
Allows to reload code at the right time, avoiding clojure-emacs/refactor-nrepl#134
1 parent 7edb6b3 commit 632be9e

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
## Unreleased
44

55
- [#415](https://github.com/clojure-emacs/clj-refactor.el/issues/415) Support for deps.edn - based projects
6+
- [#408](https://github.com/clojure-emacs/clj-refactor.el/pull/408) New `cljr-before-warming-ast-cache-hook`, `cljr-after-warming-ast-cache-hook` callbacks around AST warming.
67
- [#394](https://github.com/clojure-emacs/clj-refactor.el/issues/394) New config option `cljr-assume-language-context`: by default, when clj-refactor encounters an ambiguous context (clj vs cljs) it creates a popup asking user which context is meant. If this option is changed to "clj" or "cljs", clj-refactor will use that as the assumed context in such ambigous cases.
78
- [#391](https://github.com/clojure-emacs/clj-refactor.el/issues/391) Prevent refactor-nrepl from being injected when starting a REPL outside a project, and add an option `cljr-suppress-outside-project-warning` to suppress the resultant warning.
89

clj-refactor.el

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,16 @@ if it appears to be unused."
276276
(defvar cljr--find-symbol-buffer "*cljr-find-usages*")
277277
(defvar cljr--post-command-messages nil "Message(s) to display after the current command is done.")
278278

279+
(defcustom cljr-before-warming-ast-cache-hook nil
280+
"Runs before each time the AST is loaded."
281+
:group 'cljr
282+
:type 'function)
283+
284+
(defcustom cljr-after-warming-ast-cache-hook nil
285+
"Runs after each time the AST is loaded."
286+
:group 'cljr
287+
:type 'function)
288+
279289
;;; Buffer Local Declarations
280290

281291
;; tracking state of find-symbol buffer
@@ -2670,9 +2680,13 @@ Also adds the alias prefix to all occurrences of public symbols in the namespace
26702680
asts-in-bad-state) "; "))))))
26712681

26722682
(defun cljr--warm-ast-cache ()
2683+
(when cljr-before-warming-ast-cache-hook
2684+
(funcall cljr-before-warming-ast-cache-hook))
26732685
(cljr--call-middleware-async
26742686
(cljr--create-msg "warm-ast-cache")
26752687
(lambda (res)
2688+
(when cljr-after-warming-ast-cache-hook
2689+
(funcall cljr-after-warming-ast-cache-hook res))
26762690
(cljr--maybe-rethrow-error res)
26772691
(cljr--maybe-nses-in-bad-state res)
26782692
(when cljr--debug-mode

0 commit comments

Comments
 (0)