Function: web-mode-comment-boundaries

web-mode-comment-boundaries is an interactive and natively compiled function defined in web-mode.el.

Signature

(web-mode-comment-boundaries &optional POS)

Key Bindings

This command is not in any keymaps.

Source Code

;; Defined in /nix/store/2qgnz1rp30nzfz6w0apx4kdm14if1bbs-emacs-packages-deps/share/emacs/site-lisp/elpa/web-mode-20260831.219/web-mode.el
(defun web-mode-comment-boundaries (&optional pos)
  (interactive)
  (unless pos (setq pos (point)))
  (let ((beg pos) (end pos) prop)
    (save-excursion
      (goto-char pos)
      (setq prop
            (cond
              ((eq (get-text-property pos 'block-token) 'comment) 'block-token)
              ((eq (get-text-property pos 'tag-type) 'comment) 'tag-type)
              ((eq (get-text-property pos 'part-token) 'comment) 'part-token)
              (t nil)
              ))
      (if (null prop)
          (setq beg nil
                end nil)
          (when (and (not (bobp))
                     (eq (get-text-property pos prop) (get-text-property (1- pos) prop)))
            (setq beg (or (previous-single-property-change pos prop) (point-min))))
          (when (and (not (eobp))
                     (eq (get-text-property pos prop) (get-text-property (1+ pos) prop)))
            (setq end (or (next-single-property-change pos prop) (point-max)))))
      (message "beg(%S) end(%S) point-max(%S)" beg end (point-max))
      (when (and beg (string= (buffer-substring-no-properties beg (+ beg 2)) "//"))
        (goto-char end)
        (while (and (looking-at-p "\n[ ]*//")
                    (not (eobp)))
          (search-forward "//")
          (backward-char 2)
          ;;(message "%S" (point))
          (setq end (next-single-property-change (point) prop))
          (goto-char end)
          ;;(message "%S" (point))
          ) ;while
        ) ;when
      ;;(when end (setq end (1- end))) ;; #1021
      ) ;save-excursion
    ;;(message "beg=%S end=%S" beg end)
    (if (and beg end) (cons beg end) nil)
    ))