mirror of
https://github.com/dense-analysis/ale.git
synced 2025-12-06 12:44:23 +08:00
Always use safe file local variables for erlang-mode fixer (#4942)
Some checks failed
CI / build_image (push) Has been cancelled
CI / test_ale (--linters-only) (push) Has been cancelled
CI / test_ale (--lua-only) (push) Has been cancelled
CI / test_ale (--neovim-07-only) (push) Has been cancelled
CI / test_ale (--neovim-08-only) (push) Has been cancelled
CI / test_ale (--vim-80-only) (push) Has been cancelled
CI / test_ale (--vim-90-only) (push) Has been cancelled
Some checks failed
CI / build_image (push) Has been cancelled
CI / test_ale (--linters-only) (push) Has been cancelled
CI / test_ale (--lua-only) (push) Has been cancelled
CI / test_ale (--neovim-07-only) (push) Has been cancelled
CI / test_ale (--neovim-08-only) (push) Has been cancelled
CI / test_ale (--vim-80-only) (push) Has been cancelled
CI / test_ale (--vim-90-only) (push) Has been cancelled
File local variables in Emacs are used in a way similar to Vim
modelines. For example, at the end of the file you might find something
like the following:
%% Local Variables:
%% erlang-indent-level: 2
%% something-weird: t
%% End:
The `erlang-indent-level' variable in this list instructs the Erlang
mode to use two columns per indentation level. But since the
`something-weird' variable is likely unknown, both may be ignored.
By default, Emacs in batch mode ignores all variable/value pairs if it
encounters at least one that is not known to be safe. Setting
`enable-local-variables' to `:safe' tells Emacs to use only safe values
and ignore the rest.
This commit is contained in:
committed by
GitHub
parent
067e74fee8
commit
090d31b79a
@@ -17,10 +17,11 @@ let s:variables = {
|
||||
\}
|
||||
|
||||
function! ale#fixers#erlang_mode#Fix(buffer) abort
|
||||
let emacs_executable =
|
||||
let l:emacs_executable =
|
||||
\ ale#Var(a:buffer, 'erlang_erlang_mode_emacs_executable')
|
||||
|
||||
let l:exprs = [
|
||||
\ '(setq enable-local-variables :safe)',
|
||||
\ s:SetqDefault(a:buffer, s:variables),
|
||||
\ '(erlang-mode)',
|
||||
\ '(font-lock-fontify-region (point-min) (point-max))',
|
||||
|
||||
@@ -33,6 +33,9 @@ Execute(Emacs executable should be configurable):
|
||||
let b:ale_erlang_erlang_mode_emacs_executable = '/path/to/emacs'
|
||||
AssertEqual 0, stridx(Fixer('command'), ale#Escape('/path/to/emacs'))
|
||||
|
||||
Execute(enable-local-variables should be :safe):
|
||||
Assert Fixer('command') =~# '\m\<enable-local-variables :safe\>'
|
||||
|
||||
Execute(erlang-indent-level should be 4 by default):
|
||||
Assert Fixer('command') =~# '\m\<erlang-indent-level 4\>'
|
||||
|
||||
|
||||
Reference in New Issue
Block a user