Function: cider-maybe-delete-multiline-comment

cider-maybe-delete-multiline-comment is a byte-compiled function defined in cider-eval.el.

Signature

(cider-maybe-delete-multiline-comment COMMENT-PREFIX CONTINUED-PREFIX COMMENT-POSTFIX)

Documentation

Delete the region after the point in the form of a multiline comment.

The region must begin with COMMENT-PREFIX, followed by multiple lines beginning with CONTINUED-PREFIX at the same indentation, and optionally end with COMMENT-POSTFIX.

Source Code

;; Defined in ~/.emacs.d/elpa/cider-20260822.1520/cider-eval.el
(defun cider-maybe-delete-multiline-comment (comment-prefix continued-prefix comment-postfix)
  "Delete the region after the point in the form of a multiline comment.
The region must begin with COMMENT-PREFIX, followed by multiple lines
beginning with CONTINUED-PREFIX at the same indentation,
and optionally end with COMMENT-POSTFIX."
  (let ((pre-rgx (rx (group-n 1 (* (any " \t"))) ;; may be indented
                     (literal comment-prefix))))
    (when (looking-at pre-rgx)
      (let* ((cont-rgx (rx (literal (match-string 1)) ;; match indentation rigidly
                           (literal continued-prefix)))
             (post-rgx (rx (literal (match-string 1))
                           ;; trim the leading newline, NOTE string-trim messes with match data
                           (literal (if (string-prefix-p "\n" comment-postfix)
                                        (substring comment-postfix 1)
                                      comment-postfix))))
             (start (point))
             (end (save-excursion
                    (goto-char (match-end 0))
                    (if (string-prefix-p ";" comment-prefix)
                        ;; line comment - skip past any similarly indented comments
                        (progn
                          (forward-line 1)
                          (while (and (not (eobp))
                                      (looking-at-p cont-rgx))
                            (forward-line 1)))
                      ;; otherwise it's probably some sort of discarded form like #_
                      (clojure-forward-logical-sexp 1))
                    (if (looking-at post-rgx) ;; skip past postfix
                        (match-end 0)
                      (point)))))
        (delete-region start end)))))