help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

some emacs commands at end of file


From: Allan Adler
Subject: some emacs commands at end of file
Date: 20 Jan 2007 23:34:30 -0500

In the C source code to a math package called GAP 3, there are some
emacs commands hidden in a comment at the end of the file, something
like this (I copied this by hand):

/***************************************************
*E  Emacs ................... local emacs variables
**
**  Local Variables:
**  mode: outline
**  outline-regexp: "*A\\|*F\\|*V\\|*T\\|*E"
**  fill-column: 73
**  fill-prefix: "**  "
**  eval: (local-set-key "\t" 'c-indent-command')
**  eval: (local-set-key ";" 'electric-c-semi)
**  eval: (local-set-key "{" 'electric-c-brace)
**  eval: (local-set-key "}" 'electric-c-brace)
**  eval: (hide-body)
**  End:
*/

Because of this stuff at the end of the file, if I run emacs and enter
the file, I get prompted with a y or n question that I don't understand.
If I instead type n to the prompt, I just get the file as it is.
If I type y, then all of the lines in the file that begin with *A,*F,*V,
*T or *E are displayed and none of the other lines. This is a display
that looks like just a few lines. If I go to the beginning of those few lines
and execute M-x set-mark and then go to the end and hit C-W to put them
in the yank buffer, and then go to an empty buffer and hit C-y, instead
of just those lines I get the full contents of the file. So this is all
about display, just smoke and mirrors, not the actual content of the file.

I've been trying to make some sense of these commands, since it seems to
be a very useful technique to be able to display just certain particularly
important lines. Here are some questions:
(1) What exactly is it that causes emacs to treat the material in the
    C comments as commands instead of as text?
(2) At what point does it start and at what point does it end?
(3) Why can't I find everything in the comments in the documentation for
    GNU emacs or in the documentation for GNU emacs lisp?

I have a theory about (3), even though I don't know enough to really have
a theory. My theory is that when it says

mode:  outline

it tells emacs to go into something called outline mode. Maybe an outline
is a selection of particular lines, such as I find displayed when I type
y in reply to the prompt. On the other hand, since it is a C file, maybe
the mode that handles C files has some smarts beyond the formatting of C
that makes it respond to some of these commands. For example, I couldn't
find c-indent-mode or electric-c-semi or electric-c-brace in any of the
documentation, so I'm guessing that maybe they are in the .el file that
tells emacs how to handle C files. Using grep, I found a file c-mode.elc
but no file c-mode.el. So, I guess I need to download c-mode.el for
emacs 20.7 from somewhere and try to read it.

Even if that theory is right, I'm not sure what the respective roles are
of outline mode and C mode in this. I noticed something about major and
minor modes in the elisp documentation but haven't made sense of it yet.
-- 
Ignorantly,
Allan Adler <ara@zurich.csail.mit.edu>
* Disclaimer: I am a guest and *not* a member of the MIT CSAIL. My actions and
* comments do not reflect in any way on MIT. Also, I am nowhere near Boston.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]