Function: web-mode

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

Signature

(web-mode)

Documentation

Major mode for editing web templates.

In addition to any hooks its parent mode web-mode-prog-mode might have run, this mode runs the hook web-mode-hook, as the final or penultimate step during initialization.

C-c C-a b web-mode-attribute-beginning
C-c C-a e web-mode-attribute-end
C-c C-a i web-mode-attribute-insert
C-c C-a k web-mode-attribute-kill
C-c C-a n web-mode-attribute-next
C-c C-a p web-mode-attribute-previous
C-c C-a s web-mode-attribute-select
C-c C-a t web-mode-attribute-transpose
C-c C-b b web-mode-block-beginning
C-c C-b c web-mode-block-close
C-c C-b e web-mode-block-end
C-c C-b k web-mode-block-kill
C-c C-b n web-mode-block-next
C-c C-b p web-mode-block-previous
C-c C-b s web-mode-block-select
C-c C-d a web-mode-dom-apostrophes-replace
C-c C-d d web-mode-dom-errors-show
C-c C-d e web-mode-dom-entities-replace
C-c C-d n web-mode-dom-normalize
C-c C-d q web-mode-dom-quotes-replace
C-c C-d t web-mode-dom-traverse
C-c C-d x web-mode-dom-xpath
C-c C-e + web-mode-element-extract
C-c C-e - web-mode-element-contract
C-c C-e / web-mode-element-close
C-c C-e I web-mode-element-insert-at-point
C-c C-e a web-mode-element-content-select
C-c C-e b web-mode-element-beginning
C-c C-e c web-mode-element-clone
C-c C-e d web-mode-element-child
C-c C-e e web-mode-element-end
C-c C-e f web-mode-element-children-fold-or-unfold
C-c C-e i web-mode-element-insert
C-c C-e k web-mode-element-kill
C-c C-e m web-mode-element-mute-blanks
C-c C-e n web-mode-element-next
C-c C-e p web-mode-element-previous
C-c C-e r web-mode-element-rename
C-c C-e s web-mode-element-select
C-c C-e t web-mode-element-transpose
C-c C-e u web-mode-element-parent
C-c C-e v web-mode-element-vanish
C-c C-e w web-mode-element-wrap
C-c C-f web-mode-fold-or-unfold
C-c C-h web-mode-buffer-fontify
C-c C-j web-mode-jshint
C-c C-l web-mode-file-link
C-c C-n web-mode-navigate
C-c C-r web-mode-reload
C-c C-s web-mode-snippet-insert
C-c C-t a web-mode-tag-attributes-sort
C-c C-t b web-mode-tag-beginning
C-c C-t e web-mode-tag-end
C-c C-t m web-mode-tag-match
C-c C-t n web-mode-tag-next
C-c C-t p web-mode-tag-previous
C-c C-t s web-mode-tag-select
C-c C-w web-mode-whitespaces-show
C-c RET web-mode-mark-and-expand
C-c TAB web-mode-buffer-indent
M-; web-mode-comment-or-uncomment

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
  ) ;eval-and-compile

;;---- MAJOR MODE --------------------------------------------------------------

;;;###autoload
(define-derived-mode
    web-mode web-mode-prog-mode "Web"
    "Major mode for editing web templates."

    (make-local-variable 'web-mode-attr-indent-offset)
    (make-local-variable 'web-mode-attr-value-indent-offset)
    (make-local-variable 'web-mode-auto-pairs)
    (make-local-variable 'web-mode-block-regexp)
    (make-local-variable 'web-mode-change-beg)
    (make-local-variable 'web-mode-change-end)
    (make-local-variable 'web-mode-code-indent-offset)
    (make-local-variable 'web-mode-column-overlays)
    (make-local-variable 'web-mode-comment-formats)
    (make-local-variable 'web-mode-comment-style)
    (make-local-variable 'web-mode-content-type)
    (make-local-variable 'web-mode-css-indent-offset)
    (make-local-variable 'web-mode-display-table)
    (make-local-variable 'web-mode-django-control-blocks)
    (make-local-variable 'web-mode-django-control-blocks-regexp)
    (make-local-variable 'web-mode-enable-block-face)
    (make-local-variable 'web-mode-enable-inlays)
    (make-local-variable 'web-mode-enable-part-face)
    (make-local-variable 'web-mode-enable-sexp-functions)
    (make-local-variable 'web-mode-engine)
    (make-local-variable 'web-mode-engine-attr-regexp)
    (make-local-variable 'web-mode-engine-file-regexps)
    (make-local-variable 'web-mode-engine-open-delimiter-regexps)
    (make-local-variable 'web-mode-engine-token-regexp)
    (make-local-variable 'web-mode-expand-initial-pos)
    (make-local-variable 'web-mode-expand-initial-scroll)
    (make-local-variable 'web-mode-expand-previous-state)
    (make-local-variable 'web-mode-indent-style)
    (make-local-variable 'web-mode-indentless-attributes)
    (make-local-variable 'web-mode-indentless-elements)
    (make-local-variable 'web-mode-is-scratch)
    (make-local-variable 'web-mode-skip-fontification)
    (make-local-variable 'web-mode-jshint-errors)
    (make-local-variable 'web-mode-last-enabled-feature)
    (make-local-variable 'web-mode-markup-indent-offset)
    (make-local-variable 'web-mode-minor-engine)
    (make-local-variable 'web-mode-overlay-tag-end)
    (make-local-variable 'web-mode-overlay-tag-start)
    (make-local-variable 'web-mode-part-beg)
    (make-local-variable 'web-mode-scan-beg)
    (make-local-variable 'web-mode-scan-end)
    (make-local-variable 'web-mode-sql-indent-offset)
    (make-local-variable 'web-mode-time)
    (make-local-variable 'web-mode-trace)

    (make-local-variable 'font-lock-beg)
    (make-local-variable 'font-lock-end)

    (make-local-variable 'comment-end)
    (make-local-variable 'comment-region-function)
    (make-local-variable 'comment-start)
    (make-local-variable 'fill-paragraph-function)
    (make-local-variable 'font-lock-defaults)
    (make-local-variable 'font-lock-extend-region-functions)
    (make-local-variable 'font-lock-support-mode)
    (make-local-variable 'font-lock-unfontify-region-function)
    (make-local-variable 'imenu-case-fold-search)
    (make-local-variable 'imenu-create-index-function)
    (make-local-variable 'imenu-generic-expression)
    (make-local-variable 'indent-line-function)
    (make-local-variable 'parse-sexp-lookup-properties)
    (make-local-variable 'uncomment-region-function)
    (make-local-variable 'yank-excluded-properties)

    (setq web-mode-time (current-time))

    (setq comment-end "-->"
          comment-region-function 'web-mode-comment-or-uncomment-region
          comment-start "<!--"
          fill-paragraph-function 'web-mode-fill-paragraph
          ;;font-lock-defaults '(web-mode-font-lock-keywords t)
          font-lock-defaults '('(web-mode-fontify) t)
          font-lock-extend-region-functions '(web-mode-extend-region)
          font-lock-support-mode nil
          font-lock-unfontify-region-function 'web-mode-unfontify-region
          imenu-case-fold-search t
          imenu-create-index-function 'web-mode-imenu-index
          indent-line-function 'web-mode-indent-line
          parse-sexp-lookup-properties t
          yank-excluded-properties t
          uncomment-region-function 'web-mode-comment-or-uncomment-region
          prettify-symbols-alist web-mode-prettify-symbols-alist)

    (substitute-key-definition #'indent-new-comment-line
                               #'web-mode-comment-indent-new-line
                               web-mode-map global-map)

    (add-hook 'after-change-functions #'web-mode-on-after-change nil t)
    (add-hook 'after-save-hook        #'web-mode-on-after-save t t)
    (add-hook 'change-major-mode-hook #'web-mode-on-exit nil t)
    (add-hook 'post-command-hook      #'web-mode-on-post-command nil t)
    (add-hook 'hack-local-variables-hook #'web-mode-guess-engine-and-content-type t t)

    (cond
      ((boundp 'yas-after-exit-snippet-hook)
       (add-hook 'yas-after-exit-snippet-hook
                 'web-mode-yasnippet-exit-hook
                 t t))
      ((boundp 'yas/after-exit-snippet-hook)
       (add-hook 'yas/after-exit-snippet-hook
                 'web-mode-yasnippet-exit-hook
                 t t))
      )

    (when web-mode-enable-whitespace-fontification
      (web-mode-whitespaces-on))

    (when web-mode-enable-sexp-functions
      (setq-local forward-sexp-function #'web-mode-forward-sexp))

    (setq web-mode-change-beg (point-min)
          web-mode-change-end (point-max))
    (when (> (point-max) 256000)
      (web-mode-buffer-fontify))

    (when (and (boundp 'hs-special-modes-alist)
               (not (assoc major-mode hs-special-modes-alist)))
      (add-to-list 'hs-special-modes-alist '(web-mode "{" "}" "/[*/]" web-mode-forward-sexp nil))
      ) ;when

    ;; compatibility with emacs < 24
    (if (fboundp 'prog-mode)
        (put 'web-mode 'derived-mode-parent 'prog-mode))

    (cond
      ((not (buffer-file-name))
       )
      ((string-match-p "web-mode-benchmark.html" (buffer-file-name))
       (web-mode-measure "end"))
      ) ;cond

    )