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

safe local variables should be considered safe when autoloaded #1304

Closed sfllaw closed 3 months ago

sfllaw commented 3 months ago

I have an HTML file with the following file local variables:

<!-- Local Variables:
     web-mode-code-indent-offset: 1
     End: -->

If web-mode is already required, visiting this file is just fine. However, if web-mode is autoloaded, then Emacs thinks this setting is unsafe, despite it being marked as :safe.

(defcustom web-mode-code-indent-offset
  :safe #'integerp)

This is because Emacs doesn’t know that the variable is safe until it loads the package. In order to avoid this, we replace the :safe property with an autoload cookie that assigns its safety predicate:

;;;###autoload
(put 'web-mode-code-indent-offset 'safe-local-variable #'integerp)

Fixes fxbois/web-mode#1302.