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

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

Re: How to put mode Info into comment header of program?


From: Pascal Bourguignon
Subject: Re: How to put mode Info into comment header of program?
Date: Wed, 23 Apr 2008 00:59:33 +0200
User-agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/22.1 (gnu/linux)

Wei <william.wtang@gmail.com> writes:

> Hi,
>
> I am not sure if this is a trivial question. But it definitely seems
> non-trivial to me.
>
> Recently I browse some common lisp code written for Artificial
> Intelligence, which can be found at 
> http://aima.cs.berkeley.edu/lisp/doc/overview.html.
>
> I think the author uses Emacs for his common lisp programming, The
> interesting part is on the top of each of his lisp program, he has a
> line like ";;; -*- Mode: Lisp; Syntax: Common-Lisp; -*- File:
> utilities.lisp". I think this is automatic inserted through some
> mechanism and could be used for other programming language mode also,
> such as cc-mode.
>
> However, I searched over goolge for quite a while and couldn't find
> what kind of setting can enable this.
>
> Can I get any hints from any of you experts?

Have a look at: (info "(emacs)File Variables")

(You can type M-x info RET m emacs RET m File Variables RET or put the
cursor after the (info "(emacs)File Variables") sexp and type C-x
C-e).


Note that there are several "emacsen", and the set of file variables
take into account may vary depending on the emacs used, and the
various modes and libraries loaded.

;;; -*- Mode: Lisp; Syntax: Common-Lisp; -*-

In GNU emacs, there's a single lisp-mode (there's an alias named
common-lisp-mode), and AFAIK, it doesn't vary its behavior on a
'syntax' variable.

In GNU emacs, you'd just write:

;;;; -*- mode:common-lisp -*-

or just:

;;;; -*- mode:lisp -*-


Another file variable that might be useful, in GNU emacs, is coding,
which allows you to explicitely specify the encoding of the file for
emacs:

;;;; -*- mode:lisp;coding:utf-8 -*-

You can actually set any variable you want with file variables, as
long as you have some emacs lisp code that will take it into account
when you edit this file.


This mode  line is not automatically inserted, but you can have it
automatically inserted or updated with a before-save-hook, or with a
skeleton (see the function skeleton-insert, C-h f skeleton-insert RET).


The mode is usually automatically selected depending on the file name
(or path). See the variable auto-mode-alist.  
(Type C-h v auto-mode-alist RET).

So  you don't really need the mode line.  However, it's handy when you
have an occasional file with a different extension. Eg. in some data
file containing lisp sexp, you could put ;; -*- mode:lisp -*- to get
the editing facilities brought with that mode.


-- 
__Pascal Bourguignon__                     http://www.informatimago.com/

PLEASE NOTE: Some quantum physics theories suggest that when the
consumer is not directly observing this product, it may cease to
exist or will exist only in a vague and undetermined state.


reply via email to

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