I too use C-c C-e
a lot, but I also donβt mind if itβs changed
Is Cider supposed to font-lock local bindings any differently? I've noticed it scatters cider-local
text properties everywhere, but doesn't seem to do anything in particular with them.
@qythium See cider--parse-and-apply-locals
I don't think we were ever doing font-locking for those, we were just marking them as locals.
Yeah, I was looking at that section of code and couldn't figure out /what/ it was doing, besides marking them
Hmm, I see it's actually in the mode definition as well:
(setq-local font-lock-fontify-region-function
(cider--wrap-fontify-locals font-lock-fontify-region-function))
for future tooling to take advantage of, perhaps?
Perhaps this was working at some point and we broke it. I don't remember already. I see the code hasn't been touched in 5 years.
I see, thanks - also noticed that the locals it's picking up are almost always wrong and bleeding in from neighboring forms
I was basically trying to hack together an eldoc extension to show something useful in a recur
form by picking up the nearest target's binding names, and saw that the locals code had quite a bit of relevant logic written already.
Ah, looks like it doesn't handle destructured bindings - I'll have to figure that out another time
That does seem a lot nicer and less brittle than the regex / point moving approaches that are currently implemented!
Though I'd be worried about performance, right now I basically have to choose between aggressive-indent-mode
or clojure-indent-use-backtracking
, otherwise editing on my laptop slows to an crawl on large forms... the indentation logic starts taking up 50% of the CPU and triggering GC pauses every few seconds
Hi! π Is there a way I can set some code to run on every buffer eval?
I'd like to re-run spec instrumentation on every file reload
ok, I see there's cider-file-loaded-hook
, I think that's exactly what I need. If anyone knows of some example code that'd be much appreciated
It's as simple as (add-hook 'cider-file-loaded-hook #'cider--test-silently)
.
In your case you'll be triggering some evaluation function of course, there are many of those.
Most likely it was the initial version of something that we didn't finish. Now with parse-clj
it should be easier to do something like what you have in mind. This is one of the dream goal - file-level static analysis that's not depending on running external tools.
this will run on each file loaded. Not sure why you're loading the buffer so much, but i'd probably put a (comment (require 'this-ns :reload))
and inside of that comment form the instrument call as well. I think i remember a patch to add evaluation from a register and that comes to my mind
;; βC-x r s <register-key>β save to register
;; 'C-c C-j x <register-key' to send to repl
(defun cider-insert-register-contents (register)
(interactive (list (register-read-with-preview "From register")))
(let ((form (get-register register)))
;; could put form into a buffer and check if its parens are
;; balanced
(if form
(cider-insert-in-repl form (not cider-invert-insert-eval-p))
(user-error "No saved form in register"))))
(define-key 'cider-insert-commands-map (kbd "x") #'cider-insert-register-contents)
(define-key 'cider-insert-commands-map (kbd "C-x") #'cider-insert-register-contents)
(define-key cider-repl-mode-map (kbd "C-c C-j") 'cider-insert-commands-map)
i'd save the instrument form in a register and then send it to the replthanks @bozhidar , I kina managed to get it working π