Function: clojure--search-comment-macro-internal

clojure--search-comment-macro-internal is a byte-compiled function defined in clojure-mode.el.

Signature

(clojure--search-comment-macro-internal LIMIT)

Documentation

Search for a comment forward stopping at LIMIT.

Source Code

;; Defined in ~/.emacs.d/elpa/clojure-mode-20260325.811/clojure-mode.el
(defun clojure--search-comment-macro-internal (limit)
  "Search for a comment forward stopping at LIMIT."
  ;; Iterative search: find the next comment macro (`#_` or `(comment ...)`)
  ;; that isn't inside a string or comment, then extend match-data group 1
  ;; to cover the commented-out sexp(s).
  (let ((result nil))
    (while (and (not result)
                (search-forward-regexp clojure-comment-regexp limit t))
      (let* ((md (match-data))
             (start (match-beginning 1))
             (state (syntax-ppss start)))
        ;; Skip matches inside strings or comments.
        (unless (or (nth 3 state)
                    (nth 4 state))
          (goto-char start)
          ;; For #_#_expr, each #_ discards one sexp, so count them.
          ;; For (comment ...), the regexp matches but has zero #_,
          ;; so max with 1 ensures we skip the comment body.
          (clojure-forward-logical-sexp
           (max (count-matches (rx "#_") (elt md 0) (elt md 1))
                1))
          ;; match-data is a flat list [beg0 end0 beg1 end1 ...],
          ;; so index 3 = end of group 1.  Set it to point (after
          ;; stepping over the commented sexps) so that group 1 spans
          ;; from the macro to the end of the discarded code.
          (setf (elt md 3) (point))
          (set-match-data md)
          (setq result t))))
    result))