add-file-local-variable is an interactive autoloaded Lisp function in `files-x.el'.

(add-file-local-variable VARIABLE VALUE &optional INTERACTIVE)

Add file-local VARIABLE with its VALUE to the Local Variables list.

This command deletes all existing settings of VARIABLE (except `mode'
and `eval') and adds a new file-local VARIABLE with VALUE to the
Local Variables list.

If there is no Local Variables list in the current file buffer
then this function adds the first line containing the string
`Local Variables:' and the last line containing the string `End:'.