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

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

Re: sh-mode


From: Michael Slass
Subject: Re: sh-mode
Date: Wed, 06 Nov 2002 15:33:15 GMT
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2

sylvain ferriol <Sylvain.Ferriol@imag.fr> writes:

>hello
>i edit my_file.sh which is a bash file
>and i want to put local variables for emacs in the file
>how can i do that???
>for example
>#!/bin/bash
>#Local Variables:
>#mode: sh-mode
>#End:
>
>but this doesn't work
>
>thanks
>sylvain
>
>
>


If all you want to do is set the mode, you can do that on the *second*
line of the file.  From the "Major Modes" node of the emacs manual:

,----
|    You can specify which major mode should be used for editing a certain
| file by a special sort of text in the first nonblank line of the file.
| The mode name should appear in this line both preceded and followed by
| `-*-'.  Other text may appear on the line as well.  For example,
| 
|      ;-*-Lisp-*-
| 
| tells Emacs to use Lisp mode.  Such an explicit specification overrides
| any defaults based on the file name.  Note how the semicolon is used to
| make Lisp treat this line as a comment.
| 
| <snip>
|
|    When a file's contents begin with `#!', it can serve as an
| executable shell command, which works by running an interpreter named on
| the file's first line.  The rest of the file is used as input to the
| interpreter.
| 
| <snip>
| 
|    When the first line starts with `#!', you cannot (on many systems)
| use the `-*-' feature on the first line, because the system would get
| confused when running the interpreter.  So Emacs looks for `-*-' on the
| second line in such files as well as on the first line.
`----

so:

#!/bin/bash
# -*-sh-*-
...

-- 
Mike Slass


reply via email to

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