Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Emacs: Disabling a minor mode from a file header

Though I mostly hate auto-fill-mode, Org Mode makes a good case for using it, so I don't want to disable it for Org Mode by default. However, I do have some Org files where I absolutely do not want it, and am sick of typing M-x auto-etc every time I open them.

I know you can pass variable to Emacs from file headers, and after a bit of searching I came up with this document from which I deduced that I want something like this:

-*- mode: Org; auto-fill-mode 0 -*-

as the first line of my file. But not this exactly, because that gives me an error:

Malformed mode-line: "auto-fill-mode 0"

and auto-fill mode does not start up.

I am sure it is a simple error in syntax, but it would be nice to know the right way to do this.

like image 639
Dmitri Avatar asked Oct 21 '13 17:10

Dmitri


3 Answers

This is what I use:

# -*- mode: Org; eval: (auto-fill-mode 0) -*- #

Note that the # characters are optional, I just prefer them for style reasons.

$ info emacs

48.2.4.1 Specifying File Variables:

Do not use the `mode' keyword for minor modes.  To enable or disable 
a minor mode in a local variables list, use the `eval' keyword with a
Lisp expression that runs the mode command (*note Minor Modes::).`
like image 82
nispio Avatar answered Sep 27 '22 17:09

nispio


As per this part of the doc, append this to the end of your file:

# Local Variables:
# eval: (auto-fill-mode 0)
# End: 
like image 26
abo-abo Avatar answered Sep 27 '22 16:09

abo-abo


You are missing a colon:

-*- mode: Org; auto-fill-mode: 0; -*-
like image 37
sds Avatar answered Sep 27 '22 17:09

sds