Actually it must be named: "Make `apply-on-rectangle' able to skip lines".
Reattaching the patch as .txt
--- rect.el 2023-01-30 14:18:22.542176710 +0300
+++ rect-patched.el 2023-01-30 15:44:14.953579566 +0300
@@ -143,12 +143,16 @@
(rectangle--reset-point-crutches))
;;; Rectangle operations.
+(defvar *rectangle-skip-lines* nil
+ "If `t' -- skip empty lines, if `function' -- skip line if it returns `nil'.
+The function gets all arguments of `apply-to-rectangle' as input.")
(defun apply-on-rectangle (function start end &rest args)
"Call FUNCTION for each line of rectangle with corners at START, END.
FUNCTION is called with two arguments: the start and end columns of the
rectangle, plus ARGS extra arguments. Point is at the beginning of line when
the function is called.
+Application of the FUNCTION is affected by the `*rectangle-skip-lines*'.
The final point after the last operation will be returned."
(save-excursion
(let* ((cols (rectangle--pos-cols start end))
@@ -166,7 +170,14 @@
(goto-char startpt)
(while
(progn
- (apply function startcol endcol args)
+ (when (cond
+ ((null *rectangle-skip-lines*)
+ t)
+ ((functionp *rectangle-skip-lines*)
+ (apply *rectangle-skip-lines* function start end args))
+ (t
+ (/= (line-beginning-position) (line-end-position))))
+ (apply function startcol endcol args))
(setq final-point (point))
(and (zerop (forward-line 1)) (bolp)
(<= (point) endpt))))