cider

A channel dedicated to the Clojure Interactive Development Environment that Rocks (aka CIDER). :cider:
william 2021-03-05T18:00:12.053900Z

I'm debugging an issue with clojure indentation in emacs, and I'd like some pointers to continue the debugging. I found, using edebug, that my error

clojure-indent-function: Wrong type argument: number-or-marker-p, nil
comes from trying to do:
((= pos (1+ method))
where method comes from:
(let ((method (clojure--find-indent-spec))
Now, the question: I enabled edebug also for clojure--find-indent-spec, but the debugger doesn't step in that automatically! Why?

william 2021-03-05T18:41:43.054600Z

I'd like another pair of eyes to see how method can become nil in this code, from clojure-mode:

william 2021-03-05T18:42:38.054900Z

(defun clojure-indent-function (indent-point state)

  ;; Goto to the open-paren.
  (goto-char (elt state 1))
  ;; Maps, sets, vectors and reader conditionals.
  (if (clojure--not-function-form-p)
      (1+ (current-column))
    ;; Function or macro call.
    (forward-char 1)
    (let ((method (clojure--find-indent-spec))
          (last-sexp calculate-lisp-indent-last-sexp)
          (containing-form-column (1- (current-column))))
      (pcase method
        ((or (pred integerp) `(,method))
         (let ((pos -1))
           (condition-case nil
               (while (and (<= (point) indent-point)
                           (not (eobp)))
                 (clojure-forward-logical-sexp 1)
                 (cl-incf pos))
             ;; If indent-point is _after_ the last sexp in the
             ;; current sexp, we detect that by catching the
             ;; `scan-error'. In that case, we should return the
             ;; indentation as if there were an extra sexp at point.
             (scan-error (cl-incf pos)))
           (cond
            ;; The first non-special arg. Rigidly reduce indentation.
            ((= pos (1+ method))
             (+ lisp-body-indent containing-form-column))

william 2021-03-05T18:43:47.056100Z

basically, in the last but one line, I have (= pos (1+ method)) and method is nil there, but it wasn't nil in the let block in which it has been defined, and I'm not sure where else it could have changed!

william 2021-03-05T18:59:44.056900Z

maybe @dpsutton ^?

dpsutton 2021-03-05T19:00:20.057700Z

i don't have time to look at it atm. and these kinds of things just require stepping through. I doubt anyone has context on this low level stuff except at the time they've worked on it. its quite possible you know the most about it at the current time

dpsutton 2021-03-05T19:00:46.058200Z

but if you open an issue on clojure-mode it might get some eyes on it. and be a place for discussion that won't go away when the slack scroll limit is hit

🙌 1
william 2021-03-05T19:02:37.059800Z

thanks, yes, I'll probably do that. I stepped through that, hence my disbelief, since the only place in which it could have changed is:

(pcase method
        ((or (pred integerp) `(,method))
and I don't think that modifies method. Anyway, yes, I'll head for github

william 2021-03-05T19:43:41.060300Z

oh, no, there were known issues https://lists.gnu.org/archive/html/emacs-devel/2021-03/msg00172.html

dpsutton 2021-03-05T19:46:54.060600Z

oof. sucks when its a language control flow issue you end up diagnosing

william 2021-03-05T20:04:31.061200Z

so, there was a PR here https://github.com/clojure-emacs/clojure-mode/pull/585/files following that discussion, but I tried to modify that locally, and the problem persists

william 2021-03-05T20:05:30.062400Z

it doesn't help that I don't understand why pcase (which is pattern matching) should ever overwrite the variable it's matching on. I'm trying to understand the semantics of pcase now that we restricted the problem

william 2021-03-05T20:09:55.063300Z

pinging @manuel since he knows more

william 2021-03-05T20:12:16.064Z

ah, no, my bad, it's not literally the same problem 👼

william 2021-03-05T20:40:48.064200Z

problem solved 🙂