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

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

Re: syntax highlighting


From: David Kastrup
Subject: Re: syntax highlighting
Date: 28 Jan 2003 14:07:45 +0100
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3.50

"Paul O'Donnell" <odonnellp@rogers.com> writes:

> I am a little confused about syntax highlighting in emacs. When I open a file
> with *.c or *.html extensions and syntax highlighting is turned on I get the
> appropriate syntax highlighting.
> 
> But what about bash script files? I managed to get the syntax highlighting to
> work when the file extension is *.sh, which is nice, but what if it does not
> have an *.sh extension? Not all scipt files have this extension.
> 
> For example, when I opened the file /home/paul/.bash_profile I got
> syntax highlighting. It does not have an *.sh extension, so how does
> emacs know which syntax highlighting to use?

auto-mode-alist contains
 ("\\.[ck]?sh\\'\\|\\.shar\\'\\|/\\.z?profile\\'" . sh-mode)
 ("\\.bash\\'" . sh-mode)
 ("\\(/\\|\\`\\)\\.\\(bash_profile\\|z?login\\|bash_login\\|z?logout\\)\\'" . 
sh-mode)
 
("\\(/\\|\\`\\)\\.\\(bash_logout\\|shrc\\|[kz]shrc\\|bashrc\\|t?cshrc\\|esrc\\)\\'"
 . sh-mode)
 ("\\(/\\|\\`\\)\\.\\([kz]shenv\\|xinitrc\\|startxrc\\|xsession\\)\\'" . 
sh-mode)
 ("\\.m?spec\\'" . sh-mode)

> When I try to create my own scipts without naming the file *.sh I
> don't get highlighting. How can I get this highlighting for such a
> file?

It should probably be sufficient to start it with
#!/bin/bash

or so and then do revert-buffer or another means to reload the file.

The pattern matched is defined in interpreter-mode-alist.

-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum


reply via email to

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