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

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

Re: how to enable syntax highlighting for some shell script files?


From: Yuliang Wang
Subject: Re: how to enable syntax highlighting for some shell script files?
Date: Sun, 9 May 2010 19:00:32 -0400

Isn't there a way for emacs to automatically detect file types, other than add comment in each file or add items in .emacs one by one?  Vim auto detects .inputrc, but emacs doesn't.   Vim doesn't auto detect .xinitrc, but emacs does.  Funny.

On Sun, May 9, 2010 at 6:49 PM, Dan Davison <davison@stats.ox.ac.uk> wrote:
xiaweitang <jadelightking@gmail.com> writes:

> My emacs does syntax highlighting for C++, latex files, and also .Xdefaults,
> .xinitrc and so on. However, it doesn't do for other files like .inputrc and
> /etc/conf.d/local.start.

Syntax highlighting is determined by what "major mode" emacs chooses
when it visits the file. For shell scripts starting with an interpreter
declaration like #!/bin/bash, emacs knows which major mode to use. For
random configuration files that are in no particular language, you might
want to use conf-mode.

To tell emacs what mode you want it to use for a particular file, you
could do either of the following:

1. Place a special comment in the file telling emacs what major mode to use.
  See the emacs manual:
  http://www.gnu.org/software/emacs/manual/html_node/emacs/Specifying-File-Variables.html#Specifying-File-Variables

  or use info (place cursor after last parenthesis and press C-x C-e):
  (info "Emacs(Specifying File Variables)")

2. Configure the variable auto-mode-alist. For example, you could do this
  (add-to-list 'auto-mode-alist '("\\.inputrc\\'" . conf-mode))

Dan

> My local.start file :
>
> # This is a good place to load any misc programs
> # on startup (use &>/dev/null to hide output)
>
> # disable wlan0 LED blinking
> echo phy0assoc > `find /sys/devices/ -name iwl-phy0::assoc`/trigger
> &>/dev/null
>
> # from http://my.opera.com/xliot/blog/
> if ! test -p /lib/splash/cache/.splash; then
> rm /lib/splash/cache/.splash &>/dev/null
> mkfifo /lib/splash/cache/.splash
> fi



--
Sincerely,
Yuliang Wang

reply via email to

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