Skip to content

Commit 090d31b

Browse files
Always use safe file local variables for erlang-mode fixer (#4942)
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.
1 parent 067e74f commit 090d31b

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

autoload/ale/fixers/erlang_mode.vim

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,11 @@ let s:variables = {
1717
\}
1818

1919
function! ale#fixers#erlang_mode#Fix(buffer) abort
20-
let emacs_executable =
20+
let l:emacs_executable =
2121
\ ale#Var(a:buffer, 'erlang_erlang_mode_emacs_executable')
2222

2323
let l:exprs = [
24+
\ '(setq enable-local-variables :safe)',
2425
\ s:SetqDefault(a:buffer, s:variables),
2526
\ '(erlang-mode)',
2627
\ '(font-lock-fontify-region (point-min) (point-max))',

test/fixers/test_erlang_mode_fixer_callback.vader

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ Execute(Emacs executable should be configurable):
3333
let b:ale_erlang_erlang_mode_emacs_executable = '/path/to/emacs'
3434
AssertEqual 0, stridx(Fixer('command'), ale#Escape('/path/to/emacs'))
3535

36+
Execute(enable-local-variables should be :safe):
37+
Assert Fixer('command') =~# '\m\<enable-local-variables :safe\>'
38+
3639
Execute(erlang-indent-level should be 4 by default):
3740
Assert Fixer('command') =~# '\m\<erlang-indent-level 4\>'
3841

0 commit comments

Comments
 (0)