Thomas Arildsen
Thomas Arildsen

Reputation: 1290

Can I include lisp code in a text file to be executed when Emacs loads the file?

Is there a way to add lisp code, preferably in a comment, to be executed by Emacs when it loads that file?

Specifically, I want to turn auto-fill mode off for specific LaTeX files. I know something like this can be done with a mode hook, but I don't want to do it for all LaTeX files.

The way AUCTeX for Emacs stores file-specific settings in a comment at the end of edited files leads me to suspect that something like that can be done with a general snippet of lisp, such as (auto-fill-mode 0) in a comment at the start or end of a LaTeX file.

Upvotes: 2

Views: 220

Answers (1)

sabof
sabof

Reputation: 8192

M-x add-file-local-variable RET eval RET (auto-fill-mode -1) RET

This will add a comment at the end of the file, using the appropriate comment syntax. eval can contain any lisp form, but will ask to confirm for some.

Upvotes: 5

Related Questions