fxbois / web-mode

web template editing mode for emacs
https://web-mode.org
GNU General Public License v3.0
1.63k stars 262 forks source link

File mode specification error after last update #1243

Closed XO39 closed 2 years ago

XO39 commented 2 years ago

Was working on some angular project when I updated to last version just an hour ago, then when ever I try to open an html file, this annoying error appears:

File mode specification error: (args-out-of-range gray 0 5)
web-mode-fontify-css-rule: Args out of range: "gray", 0, 5

Here is the output of web-mode-debug:

--- WEB-MODE DEBUG BEG ---
versions: emacs(28.1) web-mode("17.2.1")
vars: engine(nil) minor(nil) content-type("") file("*Messages*")
system: window(ns) config("aarch64-apple-darwin21.1.0")
colors: fg(nil) bg(nil) 
minor modes: (buffer-read-only show-paren-mode global-eldoc-mode zoom-mode subword-mode global-subword-mode save-place-mode savehist-mode simple-modeline-mode anzu-mode global-anzu-mode shell-dirtrack-mode default-text-scale-mode smartparens-global-mode too-long-lines-mode yas-minor-mode yas-global-mode company-mode global-company-mode emms-playing-time-mode emms-playing-time-display-mode emms-mode-line-mode global-flycheck-mode treemacs-fringe-indicator-mode treemacs-git-mode treemacs-follow-mode treemacs-filewatch-mode override-global-mode ivy-mode counsel-mode ivy-rich-mode projectile-mode counsel-projectile-mode which-key-mode)
vars:
web-mode-enable-current-column-highlight=nil 
web-mode-enable-current-element-highlight=t 
indent-tabs-mode=nil 
--- WEB-MODE DEBUG END ---

And this is the backtrace log:

Debugger entered--Lisp error: (args-out-of-range "gray" 0 5)
  web-mode-colorize(889 893)
  web-mode-fontify-css-rule(585 591 592 902)
  web-mode-fontify-css-rules(582 5857)
  web-mode-fontify-part(582 5857)
  web-mode-part-foreach(1 23333 web-mode-fontify-part)
  web-mode-fontify(23333)
  font-lock-fontify-keywords-region(1 23333 nil)
  font-lock-default-fontify-region(1 23333 nil)
  font-lock-fontify-region(1 23333 nil)
  font-lock-default-fontify-buffer()
  font-lock-fontify-buffer()
  font-lock-initial-fontify()
  #f(compiled-function (&optional arg) "Toggle syntax highlighting in this buffer (Font Lock mode).\n\nThis is a minor mode.  If called interactively, toggle the `Font-Lock\nmode' mode.  If the prefix argument is positive, enable the mode, and\nif it is zero or negative, disable the mode.\n\nIf called from Lisp, toggle the mode if ARG is `toggle'.  Enable the\nmode if ARG is nil, omitted, or is a positive number.  Disable the\nmode if ARG is a negative number.\n\nTo check whether the minor mode is enabled in the current buffer,\nevaluate `font-lock-mode'.\n\nThe mode's hook is called both when the mode is enabled and when it is\ndisabled.\n\nWhen Font Lock mode is enabled, text is fontified as you type it:\n\n - Comments are displayed in `font-lock-comment-face';\n - Strings are displayed in `font-lock-string-face';\n - Certain other expressions are displayed in other faces\n   according to the value of the variable `font-lock-keywords'.\n\nTo customize the faces (colors, fonts, etc.) used by Font Lock for\nfontifying different parts of buffer text, use \\[customize-face].\n\nYou can enable Font Lock mode in any major mode automatically by\nturning on in the major mode's hook.  For example, put in your\n~/.emacs:\n\n (add-hook \\='c-mode-hook \\='turn-on-font-lock)\n\nAlternatively, you can use Global Font Lock mode to automagically\nturn on Font Lock mode in buffers whose major mode supports it\nand whose major mode is one of `font-lock-global-modes'.  For\nexample, put in your ~/.emacs:\n\n (global-font-lock-mode t)\n\nWhere major modes support different levels of fontification, you\ncan use the variable `font-lock-maximum-decoration' to specify\nwhich level you generally prefer.  When you turn Font Lock mode\non/off the buffer is fontified/defontified, though fontification\noccurs only if the buffer is less than `font-lock-maximum-size'.\n\nTo add your own highlighting for some major mode, and modify the\nhighlighting selected automatically via the variable\n`font-lock-maximum-decoration', you can use\n`font-lock-add-keywords'.\n\nTo fontify a buffer, without turning on Font Lock mode and\nregardless of buffer size, you can use \\[font-lock-fontify-buffer].\n\nTo fontify a block (the function or paragraph containing point,\nor a number of lines around point), perhaps because modification\non the current line caused syntactic change on other lines, you\ncan use \\[font-lock-fontify-block].\n\nYou can set your own default settings for some mode, by setting a\nbuffer local value for `font-lock-defaults', via its mode hook.\n\nThe above is the default behavior of `font-lock-mode'; you may\nspecify your own function which is called when `font-lock-mode'\nis toggled via `font-lock-function'." (interactive #f(compiled-function () #<bytecode 0xd10296f8319c733>)) #<bytecode -0xb9c7e6a1a1917f6>)(nil)
  ad-Advice-font-lock-mode(#f(compiled-function (&optional arg) "Toggle syntax highlighting in this buffer (Font Lock mode).\n\nThis is a minor mode.  If called interactively, toggle the `Font-Lock\nmode' mode.  If the prefix argument is positive, enable the mode, and\nif it is zero or negative, disable the mode.\n\nIf called from Lisp, toggle the mode if ARG is `toggle'.  Enable the\nmode if ARG is nil, omitted, or is a positive number.  Disable the\nmode if ARG is a negative number.\n\nTo check whether the minor mode is enabled in the current buffer,\nevaluate `font-lock-mode'.\n\nThe mode's hook is called both when the mode is enabled and when it is\ndisabled.\n\nWhen Font Lock mode is enabled, text is fontified as you type it:\n\n - Comments are displayed in `font-lock-comment-face';\n - Strings are displayed in `font-lock-string-face';\n - Certain other expressions are displayed in other faces\n   according to the value of the variable `font-lock-keywords'.\n\nTo customize the faces (colors, fonts, etc.) used by Font Lock for\nfontifying different parts of buffer text, use \\[customize-face].\n\nYou can enable Font Lock mode in any major mode automatically by\nturning on in the major mode's hook.  For example, put in your\n~/.emacs:\n\n (add-hook \\='c-mode-hook \\='turn-on-font-lock)\n\nAlternatively, you can use Global Font Lock mode to automagically\nturn on Font Lock mode in buffers whose major mode supports it\nand whose major mode is one of `font-lock-global-modes'.  For\nexample, put in your ~/.emacs:\n\n (global-font-lock-mode t)\n\nWhere major modes support different levels of fontification, you\ncan use the variable `font-lock-maximum-decoration' to specify\nwhich level you generally prefer.  When you turn Font Lock mode\non/off the buffer is fontified/defontified, though fontification\noccurs only if the buffer is less than `font-lock-maximum-size'.\n\nTo add your own highlighting for some major mode, and modify the\nhighlighting selected automatically via the variable\n`font-lock-maximum-decoration', you can use\n`font-lock-add-keywords'.\n\nTo fontify a buffer, without turning on Font Lock mode and\nregardless of buffer size, you can use \\[font-lock-fontify-buffer].\n\nTo fontify a block (the function or paragraph containing point,\nor a number of lines around point), perhaps because modification\non the current line caused syntactic change on other lines, you\ncan use \\[font-lock-fontify-block].\n\nYou can set your own default settings for some mode, by setting a\nbuffer local value for `font-lock-defaults', via its mode hook.\n\nThe above is the default behavior of `font-lock-mode'; you may\nspecify your own function which is called when `font-lock-mode'\nis toggled via `font-lock-function'." (interactive #f(compiled-function () #<bytecode 0xd10296f8319c733>)) #<bytecode -0xb9c7e6a1a1917f6>))
  apply(ad-Advice-font-lock-mode #f(compiled-function (&optional arg) "Toggle syntax highlighting in this buffer (Font Lock mode).\n\nThis is a minor mode.  If called interactively, toggle the `Font-Lock\nmode' mode.  If the prefix argument is positive, enable the mode, and\nif it is zero or negative, disable the mode.\n\nIf called from Lisp, toggle the mode if ARG is `toggle'.  Enable the\nmode if ARG is nil, omitted, or is a positive number.  Disable the\nmode if ARG is a negative number.\n\nTo check whether the minor mode is enabled in the current buffer,\nevaluate `font-lock-mode'.\n\nThe mode's hook is called both when the mode is enabled and when it is\ndisabled.\n\nWhen Font Lock mode is enabled, text is fontified as you type it:\n\n - Comments are displayed in `font-lock-comment-face';\n - Strings are displayed in `font-lock-string-face';\n - Certain other expressions are displayed in other faces\n   according to the value of the variable `font-lock-keywords'.\n\nTo customize the faces (colors, fonts, etc.) used by Font Lock for\nfontifying different parts of buffer text, use \\[customize-face].\n\nYou can enable Font Lock mode in any major mode automatically by\nturning on in the major mode's hook.  For example, put in your\n~/.emacs:\n\n (add-hook \\='c-mode-hook \\='turn-on-font-lock)\n\nAlternatively, you can use Global Font Lock mode to automagically\nturn on Font Lock mode in buffers whose major mode supports it\nand whose major mode is one of `font-lock-global-modes'.  For\nexample, put in your ~/.emacs:\n\n (global-font-lock-mode t)\n\nWhere major modes support different levels of fontification, you\ncan use the variable `font-lock-maximum-decoration' to specify\nwhich level you generally prefer.  When you turn Font Lock mode\non/off the buffer is fontified/defontified, though fontification\noccurs only if the buffer is less than `font-lock-maximum-size'.\n\nTo add your own highlighting for some major mode, and modify the\nhighlighting selected automatically via the variable\n`font-lock-maximum-decoration', you can use\n`font-lock-add-keywords'.\n\nTo fontify a buffer, without turning on Font Lock mode and\nregardless of buffer size, you can use \\[font-lock-fontify-buffer].\n\nTo fontify a block (the function or paragraph containing point,\nor a number of lines around point), perhaps because modification\non the current line caused syntactic change on other lines, you\ncan use \\[font-lock-fontify-block].\n\nYou can set your own default settings for some mode, by setting a\nbuffer local value for `font-lock-defaults', via its mode hook.\n\nThe above is the default behavior of `font-lock-mode'; you may\nspecify your own function which is called when `font-lock-mode'\nis toggled via `font-lock-function'." (interactive #f(compiled-function () #<bytecode 0xd10296f8319c733>)) #<bytecode -0xb9c7e6a1a1917f6>) nil)
  font-lock-mode()
  turn-on-font-lock()
  turn-on-font-lock-if-desired()
  global-font-lock-mode-enable-in-buffers()
  run-hooks(after-change-major-mode-hook)
bearguns commented 2 years ago

Also seeing this same issue, here's my web-mode-debug:

--- WEB-MODE DEBUG BEG ---
versions: emacs(28.1) web-mode("17.2.1")
vars: engine("vue") minor("vue") content-type("html") file("/Users/smb/code/telegraph-web/src/components/visibility/waybills/WaybillMilestone.vue")
system: window(mac) config("x86_64-apple-darwin20.6.0")
colors: fg(nil) bg(nil) 
minor modes: (mac-mouse-wheel-mode show-paren-mode eldoc-mode global-eldoc-mode override-global-mode electric-pair-mode company-mode global-company-mode ivy-mode ivy-rich-mode counsel-mode emmet-mode lsp-mode flycheck-mode lsp-ui-sideline-mode lsp-ui-doc-mode lsp-ui-mode shell-dirtrack-mode auto-revert-mode magit-auto-revert-mode global-git-commit-mode company-box-mode lsp-modeline-workspace-status-mode)
vars:
web-mode-enable-current-column-highlight=nil 
web-mode-enable-current-element-highlight=nil 
indent-tabs-mode=nil 
--- WEB-MODE DEBUG END ---

It looks like this began after this pull request got merged in? I'm trying to look at web-mode-fontify-css-rule to see where the out of range error could be originating but I haven't dug into web-mode source before.

What's interesting is, I get different errors in different files, and I can't always see what's triggering it. For example, trying to visit or save this file: https://gist.github.com/bearguns/e3b64ea9b9b07c9f204634dbe3e0f949 results in: Args out of range: "tan", 0, 4.

This file: https://gist.github.com/bearguns/138524f8d27cd63448a6badaf4f84f95 results in: Args out of range: "grey", 0, 5

UwUnyaa commented 2 years ago

Interestingly enough, they don't contain references to CSS colors, and the word "tan" is a part of a word, not something that has any chance of getting tokenized as such.

hwboen commented 2 years ago

I have the same problem too

fxbois commented 2 years ago

should be solved with last commit