Function: web-mode-comment-or-uncomment

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

Signature

(web-mode-comment-or-uncomment)

Documentation

Comment or uncomment line(s), block or region at POS.

Key Bindings

web-mode-map M-;

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-or-uncomment ()
  "Comment or uncomment line(s), block or region at POS."
  (interactive)
  ;; TODO : if mark is at eol, mark--
  (if (and (not mark-active) (looking-at-p "[[:space:]]*$"))
      (web-mode-comment-insert)
      (when (and (use-region-p) (eq (point) (region-end)))
        (if (bolp) (backward-char))
        (exchange-point-and-mark))
      (if (eq (get-text-property (point) 'block-token) 'delimiter-beg)
          (web-mode-block-skip-blank-forward (point) '(delimiter-beg))
          (skip-chars-forward "[:space:]" (line-end-position)))
      (cond
        ;; #1147
        ((and (get-text-property (point) 'jsx-beg)
              (eq (get-text-property (1+ (point)) 'part-token) 'comment))
         (web-mode-uncomment (1+ (point))))
        ((or (eq (get-text-property (point) 'tag-type) 'comment)
             (eq (get-text-property (point) 'block-token) 'comment)
             (eq (get-text-property (point) 'part-token) 'comment))
         (web-mode-uncomment (point)))
        (t
         (web-mode-comment (point)))
        )
      ) ;if
  )