Function: hs-hide-block-at-point

hs-hide-block-at-point is a byte-compiled function defined in hideshow.el.gz.

Signature

(hs-hide-block-at-point &optional COMMENT-REG)

Documentation

Hide block if on block beginning.

Optional arg COMMENT-REG is a list of the form (BEGIN END) and specifies the limits of the comment, or nil if the block is not a comment.

If hiding the block is successful, return non-nil. Otherwise, return nil.

Source Code

;; Defined in /usr/src/emacs/lisp/progmodes/hideshow.el.gz
(defun hs-hide-block-at-point (&optional comment-reg)
  "Hide block if on block beginning.
Optional arg COMMENT-REG is a list of the form (BEGIN END) and
specifies the limits of the comment, or nil if the block is not
a comment.

If hiding the block is successful, return non-nil.
Otherwise, return nil."
  (when-let* ((block (or comment-reg (hs-block-positions :a-beg :a-end))))
    (let ((beg (if comment-reg (save-excursion (goto-char (car block)) (pos-eol))
                 (car block)))
          (end (cadr block))
          ov)
      (if (hs-hideable-region-p beg end)
          (progn
            (cond (comment-reg (let (hs-allow-nesting)
                                 (hs-discard-overlays beg end)))
                  ((and hs-allow-nesting (setq ov (hs-overlay-at beg)))
                   (delete-overlay ov))
                  ((not hs-allow-nesting)
                   (hs-discard-overlays beg end)))
            (goto-char end)
            (hs-make-overlay beg end (if comment-reg 'comment 'code)))
        (when comment-reg (goto-char end))
        nil))))