Function: hs-get-near-block

hs-get-near-block is a byte-compiled function defined in hideshow.el.gz.

Signature

(hs-get-near-block &optional INCLUDE-COMMENT)

Documentation

Reposition point to a near block around point.

It search for a valid block before and after point and return t if one is found.

If INCLUDE-COMMENT is non-nil, it also searches for a comment block, returning comment if one is found.

Intended to be used in commands.

Source Code

;; Defined in /usr/src/emacs/lisp/progmodes/hideshow.el.gz
(defun hs-get-near-block (&optional include-comment)
  "Reposition point to a near block around point.
It search for a valid block before and after point and return t if one
is found.

If INCLUDE-COMMENT is non-nil, it also searches for a comment block,
returning `comment' if one is found.

Intended to be used in commands."
  (let ((c-reg (when include-comment (funcall hs-inside-comment-predicate)))
        pos)
    (cond
     ((and c-reg (apply #'hs-hideable-region-p c-reg))
      (goto-char (car c-reg))
      'comment)

     ((and (eq hs-hide-block-behavior 'after-bol)
           (save-excursion
             (forward-line 0)
             (setq pos (hs-get-first-block-on-line))))
      (goto-char pos)
      t)

     ((and (or (funcall hs-looking-at-block-start-predicate)
               (and (forward-line 0)
                    (funcall hs-find-block-beginning-function)))
           (apply #'hs-hideable-region-p (hs-block-positions)))
      t))))