Fork me on GitHub
#emacs
<
2021-06-30
>
theeternalpulse04:06:54

is there a navigation function like end-of-defun, that works on the ignored expressions (`#_) hidden expressions in cider. I was using end-of-defun` but maybe there's been a change and it doesn't navigate properly to the end of the ignore expression

timvisher18:06:25

Could you be a little more specific about the behavior you're expecting? Like maybe a form

(let [a 1 b 2] |#_(ignored form) (+ a b))
combined with where you expect the cursor to end up post navigation?

theeternalpulse00:07:35

yes, so in my case I am working on a fn that will evaluation n forms from the current cursor, so say I have my cursor

(defn test-fn |[a] ...)

#_[(test-fn 1)
   (test-fn [])]
I want to first go to the end of the current form and evaluate last sexp, end-of-defun moves the cursor in the right place, after the current form, and I can evaluate fine. When I try end-of-defun again, the cursor ends up here:
#_|[(test-fn 1)
   (test-fn [])]
I expected another end-of-defun to go to the end of that sexp after it, but it skips it and goes to the end of whatever form is after that

theeternalpulse00:07:06

I can work with just having it not uncommented, and comment it later since I expect to move it to a test area

theeternalpulse00:07:48

(defun +user/eval-n-defuns (n)
  (interactive "P")
  (save-excursion
    (dotimes (number (or n 2))
      (end-of-defun)
      (+user/run-eval-fun))))
the +user/run-eval-fun just executes which eval to use in which major-mode

timvisher14:07:14

It's slightly above my pay grade to decide whether this is a bug in clojure-mode although I would actually expect it is given that this appears to treat ; comments differently than #_ comments as evidenced here

(defn test-fn <|>[a] (+ a 1))

#_[(thing thing) (thing)]

;;; hello world

(defn test-fn [a] (+ a 1))
end-of-defun
(defn test-fn [a] (+ a 1))

#_<|>[(thing thing) (thing)]

;;; hello world

(defn test-fn [a] (+ a 1))
Positioning me improperly just after the #_ reader macro. end-of-defun
(defn test-fn [a] (+ a 1))

#_[(thing thing) (thing)]

;;; hello world

(defn test-fn [a] (+ a 1))<|>
Properly skipping the textual ;;; comment and placing me at the end of the next form. That may be worth reporting as a bug to clojure-mode. I suspect it has something to do with the #_ not being marked with proper comment text properties but again it's a little above my pay grade. :) If I understand your requirements correctly, a workaround option would be to check for #_ before point as you're executing end-of-defun and, if it's there, run end-of-defun until it's not there. That would skip any number of #_ commented forms.

theeternalpulse14:07:36

Acrually, ideally I want it not to skip, as you can properly cider-eval-last-sexp of an ignored form with cider. The purpose is to have the function you're testing above a commented form of usages of that function for quick feedback when you are developing. Then eventually move those usages to test cases. It's based on a technique I saw a blog about and used ever since. At the time it did work with those ignored forms

timvisher15:07:55

Then test for #_ and run paredit-forword-sexp instead of what I suggested. :)

theeternalpulse17:07:40

The good thing about my way is it displays the result inline, so if I want to set up a quick case I can see the result rather than "test pass" or "test fail". This helps craft output in a quicker way this was the gist I took it from https://gist.github.com/cstby/0cff1f7eb48eb18c6690e6cdb919ca69

theeternalpulse17:07:33

I was also mistaken, before bounds-of-thing-at-point worked

theeternalpulse17:07:08

either way, I think I can figure out something for those

timvisher14:07:14

It's slightly above my pay grade to decide whether this is a bug in clojure-mode although I would actually expect it is given that this appears to treat ; comments differently than #_ comments as evidenced here

(defn test-fn <|>[a] (+ a 1))

#_[(thing thing) (thing)]

;;; hello world

(defn test-fn [a] (+ a 1))
end-of-defun
(defn test-fn [a] (+ a 1))

#_<|>[(thing thing) (thing)]

;;; hello world

(defn test-fn [a] (+ a 1))
Positioning me improperly just after the #_ reader macro. end-of-defun
(defn test-fn [a] (+ a 1))

#_[(thing thing) (thing)]

;;; hello world

(defn test-fn [a] (+ a 1))<|>
Properly skipping the textual ;;; comment and placing me at the end of the next form. That may be worth reporting as a bug to clojure-mode. I suspect it has something to do with the #_ not being marked with proper comment text properties but again it's a little above my pay grade. :) If I understand your requirements correctly, a workaround option would be to check for #_ before point as you're executing end-of-defun and, if it's there, run end-of-defun until it's not there. That would skip any number of #_ commented forms.