2

I'm reading (info "(emacs) 25.9.1 Format of Outlines"):

can explicitly specify a rule for calculating the level of a heading line by setting the variable outline-level. ...... The recommended ways to set this variable are in a major mode command or with a file local variable.

But C-h v outline-level:

This variable may be risky if used as a file-local variable.

Why it may be risky? Isn't it a recommended way to use file-locally?

Drew
  • 75,699
  • 9
  • 109
  • 225
shynur
  • 4,065
  • 1
  • 3
  • 23

1 Answers1

2

Its value is a function:

Its value is ‘outline-level’

Function of no args to compute a header’s nesting level in an outline. It can assume point is at the beginning of a header line and that the match data reflects the ‘outline-regexp’.

The function can do anything it wants, so such settings are inherently unsafe. Of course, if you are setting it to a value that you control, you can verify that the function is benign and mark it as safe. But only you can do that for your setup: there is no way for somebody else to make sure of that.

As the OP points out in a comment below, the variable is always risky, not only when it is specified as a file local variable. And as @Drew points out, the point of the warning when it is specified as a file-local variable is to make sure that the user is alerted to the potential risk. If there were no warning, then the change would go into effect silently.

NickD
  • 27,023
  • 3
  • 23
  • 42
  • If this is the case, then the variable itself is unsafe, not only when it is file local. – shynur Jun 28 '23 at 11:58
  • 2
    Yes, not only when it is file-local. But when it is file-local, if there were no prompting then it would take effect without a user being aware of that. – Drew Jun 28 '23 at 16:15
  • 1
    Please allow me to add Drew's comment to your answer, then I accept it. – shynur Jun 29 '23 at 15:30
  • I edited it a bit. Please check and modify if you disagree. – NickD Jun 29 '23 at 16:21
  • 1
    Ah, I got it. This variable is declaimed as risky so that Emacs will *ask me to confirm* whether to apply it. I didn't know this before. – shynur Jul 11 '23 at 04:32