all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* how to enable syntax highlighting for some shell script files?
@ 2010-05-09 21:57 xiaweitang
  2010-05-09 22:49 ` Dan Davison
       [not found] ` <mailman.9.1273445410.17813.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 6+ messages in thread
From: xiaweitang @ 2010-05-09 21:57 UTC (permalink / raw)
  To: Help-gnu-emacs


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. 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
-- 
View this message in context: http://old.nabble.com/how-to-enable-syntax-highlighting-for-some-shell-script-files--tp28505457p28505457.html
Sent from the Emacs - Help mailing list archive at Nabble.com.





^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: how to enable syntax highlighting for some shell script files?
  2010-05-09 21:57 how to enable syntax highlighting for some shell script files? xiaweitang
@ 2010-05-09 22:49 ` Dan Davison
  2010-05-09 23:00   ` Yuliang Wang
       [not found]   ` <mailman.10.1273446039.17813.help-gnu-emacs@gnu.org>
       [not found] ` <mailman.9.1273445410.17813.help-gnu-emacs@gnu.org>
  1 sibling, 2 replies; 6+ messages in thread
From: Dan Davison @ 2010-05-09 22:49 UTC (permalink / raw)
  To: xiaweitang; +Cc: Help-gnu-emacs

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




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: how to enable syntax highlighting for some shell script files?
  2010-05-09 22:49 ` Dan Davison
@ 2010-05-09 23:00   ` Yuliang Wang
  2010-05-11 12:37     ` Kevin Rodgers
       [not found]   ` <mailman.10.1273446039.17813.help-gnu-emacs@gnu.org>
  1 sibling, 1 reply; 6+ messages in thread
From: Yuliang Wang @ 2010-05-09 23:00 UTC (permalink / raw)
  To: Dan Davison; +Cc: Help-gnu-emacs

[-- Attachment #1: Type: text/plain, Size: 1972 bytes --]

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

[-- Attachment #2: Type: text/html, Size: 2782 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: how to enable syntax highlighting for some shell script files?
       [not found] ` <mailman.9.1273445410.17813.help-gnu-emacs@gnu.org>
@ 2010-05-10  0:29   ` Tim X
  0 siblings, 0 replies; 6+ messages in thread
From: Tim X @ 2010-05-10  0:29 UTC (permalink / raw)
  To: help-gnu-emacs

Dan Davison <davison@stats.ox.ac.uk> writes:

> 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
>
In addition to what Dan wrote, there is also generic and generic-x
modes. These modes are, as the anme would suggest generic font locking
modes. They will add basic font locking to a number of common
configuration style files.  I have the following in my .emacs file

(require 'generic)
(require 'generic-x)

Tim

-- 
tcross (at) rapttech dot com dot au


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: how to enable syntax highlighting for some shell script files?
       [not found]   ` <mailman.10.1273446039.17813.help-gnu-emacs@gnu.org>
@ 2010-05-10  0:46     ` Pascal J. Bourguignon
  0 siblings, 0 replies; 6+ messages in thread
From: Pascal J. Bourguignon @ 2010-05-10  0:46 UTC (permalink / raw)
  To: help-gnu-emacs

Yuliang Wang <jadelightking@gmail.com> writes:

> 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

A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
----------> http://www.netmeister.org/news/learn2quote.html <-----------
---> http://homepage.ntlworld.com/g.mccaughan/g/remarks/uquote.html <---


And another reason why you should not top-post, is that avoiding it, you
would be more tempted to read the message and therefore get the answer
to your question before you send it.

-- 
__Pascal Bourguignon__


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: how to enable syntax highlighting for some shell script files?
  2010-05-09 23:00   ` Yuliang Wang
@ 2010-05-11 12:37     ` Kevin Rodgers
  0 siblings, 0 replies; 6+ messages in thread
From: Kevin Rodgers @ 2010-05-11 12:37 UTC (permalink / raw)
  To: help-gnu-emacs

Yuliang Wang wrote:
> 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?

Not really, unless each file has the same syntax (see below).

> Vim 
> auto detects .inputrc, but emacs doesn't.   Vim doesn't auto detect 
> .xinitrc, but emacs does.  Funny.

That's just because they have special statements to recognize those file names
in their source code that someone contributed.

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

(add-to-list 'auto-mode-alist '("/\\..*rc\\'" . conf-mode))

-- 
Kevin Rodgers
Denver, Colorado, USA




^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2010-05-11 12:37 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-05-09 21:57 how to enable syntax highlighting for some shell script files? xiaweitang
2010-05-09 22:49 ` Dan Davison
2010-05-09 23:00   ` Yuliang Wang
2010-05-11 12:37     ` Kevin Rodgers
     [not found]   ` <mailman.10.1273446039.17813.help-gnu-emacs@gnu.org>
2010-05-10  0:46     ` Pascal J. Bourguignon
     [not found] ` <mailman.9.1273445410.17813.help-gnu-emacs@gnu.org>
2010-05-10  0:29   ` Tim X

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.