Question

I'm writing the readme (in org-mode) for a new emacs mode, and in the installation instructions we have how to enable the mode on a per-file basis:

or at the end of your file:

#+BEGIN_SRC emacs-lisp
  ! Local Variables:
  ! mode: f90-namelist
  ! End:
#+END_SRC

The problem is that this puts the README.org file into our new f90-namelist-mode and not org-mode. Putting another local variables list at the end of the file with # mode: org doesn't work, although putting

# -*- enable-local-variables: query -*-

lets me accept or reject all of the local variables, and emacs then determines the major mode from the .org file extension. This then precludes having any other local variables I might like to include.

Is there a more elegant way to include a literal local variables list in the text?

Was it helpful?

Solution

Quoting from the Emacs manual:

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.

So to make sure your in text local variables will be ignored, add a page break (C-q C-l) before the real list of local variables or at the end of the file if you don't have local variables:

or at the end of your file:

#+BEGIN_SRC emacs-lisp
  ! Local Variables:
  ! mode: f90-namelist
  ! End:
#+END_SRC
^L

This will work for all local variables, not only the major mode.

If you don't want to export the page break, just comment it, as suggested by @lunaryorn.

OTHER TIPS

Here's how iostream header looks like:

// Standard iostream objects -*- C++ -*-
...

This is the standard way to specify the mode not only in Emacs, but on the whole of Linux, for all editors, which choose to parse it. I recommend you to go this way.

Also, enabling local variables is a faux pas from my viewpoint, as it can lead to a mess that Microsoft Word had with VBA: viruses everywhere. Source code or documents should not execute themselves.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top