namespace caching breaks updating namespace name #480
Comments
This also affects |
This also affects CIDER as well. (defun cider-eval-ns-form ()
"Evaluate the current buffer's namespace form."
(interactive)
(when (clojure-find-ns)
(save-excursion
(goto-char (match-beginning 0))
(cider-eval-defun-at-point))))
(defun cider-ns-form ()
"Retrieve the ns form."
(when (clojure-find-ns)
(save-excursion
(goto-char (match-beginning 0))
(cider-defun-at-point)))) The caching breaks the contract of side-effecting the match data unfortunately. |
Extracting the search logic into |
Yeah, probably we need two functions indeed - one that finds the form and another that simply returns the current namespace. Right now things are way too convoluted. |
@dpsutton Interested in tackling this? I was thinking of adding a
I'd really love for us to get rid of relying on the implementation details and the regexp matching, that's for sure. Won't have time for this for a while, but as it's not complex and you're pretty familiar with the matter I hope you'd "volunteer" to improve this. |
This is the helpful function to update the namespace and reset the cache for namespaces. Unfortunately it relies on the replace match generated in
clojure-find-ns
. The problem is that this match does not happen if namespace caching is enbled.Note the top level bails if the cache is already set and therefore does not call
(match-string-no-properties 4)
yielding an error.This leaves an unfortunate catch-22: if you use the cache, you need to update it with update-ns. If you update the ns with the cache on, it doesn't create the match to update the cache.
The text was updated successfully, but these errors were encountered: