Function: clojure--gather-fn-literal-args

clojure--gather-fn-literal-args is a byte-compiled function defined in clojure-mode.el.

Signature

(clojure--gather-fn-literal-args)

Documentation

Return a cons cell (ARITY . VARARG) ARITY is number of arguments in the function, VARARG is a boolean of whether it takes a variable argument %&.

Source Code

;; Defined in ~/.emacs.d/elpa/clojure-mode-20260325.811/clojure-mode.el
;;; Promoting #() function literals
(defun clojure--gather-fn-literal-args ()
  "Return a cons cell (ARITY . VARARG)
ARITY is number of arguments in the function,
VARARG is a boolean of whether it takes a variable argument %&."
  (save-excursion
    (let ((end (save-excursion (clojure-forward-logical-sexp) (point)))
          (rgx (rx symbol-start "%" (group (?  (or "&" (+ (in "0-9"))))) symbol-end))
          (arity 0)
          (vararg nil))
      (while (re-search-forward rgx end 'noerror)
        (when (not (or (clojure--in-comment-p) (clojure--in-string-p)))
          (let ((s (match-string 1)))
            (if (string= s "&")
                (setq vararg t)
              (setq arity
                    (max arity
                         (if (string= s "") 1
                           (string-to-number s))))))))
      (cons arity vararg))))