Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I wonder if we can set the font in Emacs according to the comments in the file.


-*- fond: "my-font"; -*-

share|improve this question
up vote 1 down vote accepted

For full details, see Specifying File Variables

There are two ways to specify file local variable values: in the first line, or with a local variables list. Here's how to specify them in the first line:

 -*- mode: modename; var: value; ... -*-

Here is an example first line that specifies Lisp mode and sets two variables with numeric values:

 ;; -*- mode: Lisp; fill-column: 75; comment-column: 50; -*-

Instead of using a -*- line, you can define file local variables using a local variables list near the end of the file. The start of the local variables list should be no more than 3000 characters from the end of the file, and must be on the last page if the file is divided into pages.

A local variables list starts with a line containing the string ‘Local Variables:’, and ends with a line containing the string ‘End:’. In between come the variable names and values, one set per line, like this:

 /* Local Variables: */
 /* mode:c           */
 /* comment-column:0 */
 /* End:             */

Note that /* */ is only present to mark these lines as comments to the C source code... Emacs looks only for Local Variables: followed on another line by End:

share|improve this answer

You can use the eval file local variable which can evaluate lisp expressions if you allow it.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.