Function: hs-get-first-block-on-line

hs-get-first-block-on-line is a byte-compiled function defined in hideshow.el.gz.

Signature

(hs-get-first-block-on-line &optional INCLUDE-COMMENTS)

Documentation

Reposition point to the first valid block found on the current line.

This searches for a valid block from current point to the end of current line and returns the start position of the first block found. Otherwise, if no block is found, it returns nil.

If INCLUDE-COMMENTS is non-nil, also search for a comment block.

Source Code

;; Defined in /usr/src/emacs/lisp/progmodes/hideshow.el.gz
(defun hs-get-first-block-on-line (&optional include-comments)
  "Reposition point to the first valid block found on the current line.
This searches for a valid block from current point to the end of current
line and returns the start position of the first block found.
Otherwise, if no block is found, it returns nil.

If INCLUDE-COMMENTS is non-nil, also search for a comment block."
  (let ((bk-point (point))
        (regexp (if include-comments
                    (concat "\\(" hs-block-start-regexp "\\)"
                            "\\|\\(" hs-c-start-regexp "\\)")
                  hs-block-start-regexp))
        exit)
    (while (and (not exit)
                (funcall hs-find-next-block-function regexp (pos-eol) include-comments)
                (save-excursion
                  (goto-char (match-beginning 0))
                  (pcase-let ((`(,beg ,end)
                               (or (and include-comments
                                        (funcall hs-inside-comment-predicate))
                                   (hs-block-positions))))
                    (if (and beg (hs-hideable-region-p beg end))
                        (setq exit (point))
                      t)))))
    (unless exit (goto-char bk-point))
    exit))