1

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?

Yossarian
  • 5,226
  • 1
  • 37
  • 59
  • 1
    [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](http://www.gnu.org/software/emacs/manual/html_node/emacs/Specifying-File-Variables.html#Specifying-File-Variables), so you can add a page break before the real list of local variables – giordano Aug 07 '13 at 09:30
  • @giordano Ah, I didn't grok the bit about page breaks! Using `C-q C-l` to include one worked. Thanks! If you add this as an answer, I'll accept it. – Yossarian Aug 07 '13 at 09:49

2 Answers2

1

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.

giordano
  • 8,087
  • 3
  • 23
  • 48
  • You may want to put the page break into a comment to prevent it from being exported. See [Comment Lines](http://orgmode.org/manual/Comment-lines.html) in the Org manual. –  Aug 07 '13 at 14:10
  • @lunaryorn thanks for your suggestion, but if you don't export the page break you'll run into the same problem also in the exported file, so it might not be a good idea commenting it. – giordano Aug 07 '13 at 14:32
  • On the other hand, some exporters might choke at page breaks. And often you don't want to edit the exported file itself. It's exported, after all :) But of course, it depends on the specific situation. –  Aug 07 '13 at 15:01
0

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.

abo-abo
  • 20,038
  • 3
  • 50
  • 71
  • This doesn't work because emacs parses the local variables list *after* the `-*-` line, so including `-*- mode: org -*-` doesn't work. – Yossarian Aug 07 '13 at 09:47
  • I should also point out that we do also include this as a way of specifying our mode, but the problem is Emacs parsing what is supposed to be literal text. – Yossarian Aug 07 '13 at 09:54