Function: clojure--removal-regions

clojure--removal-regions is a byte-compiled function defined in clojure-mode.el.

Signature

(clojure--removal-regions COLL FORMS)

Documentation

Return the regions to delete to remove FORMS from the collection COLL.

The whitespace between them and the elements left goes too, but the comments and discarded forms among them stay, and the closing bracket never ends up on the line of a comment.

Source Code

;; Defined in ~/.emacs.d/elpa/clojure-mode-20261103.1226/clojure-mode.el
(defun clojure--removal-regions (coll forms)
  "Return the regions to delete to remove FORMS from the collection COLL.
The whitespace between them and the elements left goes too, but the
comments and discarded forms among them stay, and the closing bracket
never ends up on the line of a comment."
  (let (regions run)
    (dolist (child (append (clojure--form-children coll) (list nil)))
      (if (and child (memq child forms))
          (push child run)
        (when run
          (let ((beg (clojure--form-start-with-metadata (car (last run))))
                (end (clojure--form-end (car run))))
            (save-excursion
              (if child
                  (progn (goto-char end)
                         (skip-chars-forward " \t\n,")
                         (push (cons beg (point)) regions))
                (goto-char beg)
                (skip-chars-backward " \t\n,")
                (when (nth 4 (syntax-ppss))
                  (forward-line 1))
                (push (cons (point) end) regions))))
          (setq run nil))))
    regions))