Function: python-hideshow-find-next-block
python-hideshow-find-next-block is a byte-compiled function defined in
python.el.gz.
Signature
(python-hideshow-find-next-block REGEXP MAXP COMMENTS)
Documentation
Python specific hs-find-next-block function for hs-minor-mode(var)/hs-minor-mode(fun).
Call python-nav-forward-block to find next block and check if
block-start ends within MAXP. If COMMENTS is not nil, comments
are also searched. REGEXP is passed to looking-at to set
match-data.
Source Code
;; Defined in /usr/src/emacs/lisp/progmodes/python.el.gz
(defun python-hideshow-find-next-block (regexp maxp comments)
"Python specific `hs-find-next-block' function for `hs-minor-mode'.
Call `python-nav-forward-block' to find next block and check if
block-start ends within MAXP. If COMMENTS is not nil, comments
are also searched. REGEXP is passed to `looking-at' to set
`match-data'."
(let* ((next-block (save-excursion
(or (and
(python-info-looking-at-beginning-of-block)
(re-search-forward
(python-rx block-start) maxp t))
(and (python-nav-forward-block)
(< (point) maxp)
(re-search-forward
(python-rx block-start) maxp t))
(1+ maxp))))
(next-comment
(or (when comments
(save-excursion
(cl-loop while (re-search-forward "#" maxp t)
if (python-syntax-context 'comment)
return (point))))
(1+ maxp)))
(next-block-or-comment (min next-block next-comment)))
(when (<= next-block-or-comment maxp)
(goto-char next-block-or-comment)
(save-excursion
(beginning-of-line)
(looking-at regexp)))))