unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Michael Slass <miknrene@drizzle.com>
Subject: Re: sh-mode
Date: Wed, 06 Nov 2002 15:33:15 GMT	[thread overview]
Message-ID: <m3n0omg17e.fsf@localhost.localdomain> (raw)
In-Reply-To: mailman.1036594387.22226.help-gnu-emacs@gnu.org

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	other threads:[~2002-11-06 15:33 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <mailman.1036594387.22226.help-gnu-emacs@gnu.org>
2002-11-06 15:33 ` Michael Slass [this message]
2002-11-06 14:46 sh-mode sylvain ferriol
2002-11-06 15:02 ` sh-mode Alfred M. Szmidt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m3n0omg17e.fsf@localhost.localdomain \
    --to=miknrene@drizzle.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).