Function: hypb:count-visible-lines

hypb:count-visible-lines is an autoloaded and byte-compiled function defined in hypb.el.

Signature

(hypb:count-visible-lines START END)

Documentation

Count visible lines between START and END by scanning property boundaries.

count-lines returns 1 rather than 0 when all characters in the region are invisible, hence this function.

Source Code

;; Defined in ~/.emacs.d/elpa/hyperbole-20261030.2317/hypb.el
;;;###autoload
(defun hypb:count-visible-lines (start end)
  "Count visible lines between START and END by scanning property boundaries.
`count-lines' returns 1 rather than 0 when all characters in the region are
invisible, hence this function."
  (save-excursion
    (goto-char start)
    (let ((count 0))
      (while (< (point) end)
        (if (invisible-p (point))
            ;; Fast-forward past the invisible block
            (goto-char (next-single-char-property-change (point) 'invisible nil end))
          ;; Step line by line through visible text
          (let ((line-end (min end (line-end-position))))
            (unless (= (point) line-end)
              (setq count (1+ count)))
            (goto-char (min end (1+ line-end))))))
      count)))