[Top][All Lists]

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

Setting shell type in sh-mode

From: Glenn Morris
Subject: Setting shell type in sh-mode
Date: Thu, 17 Oct 2002 16:12:14 +0100
User-agent: Gnus, GNU Emacs (

sh-mode has a few different settings that it implements (font-lock
keywords, indentation, etc), according to the type of shell being edited
(bash, csh, etc).

The way it detects which type of shell is in use is to either look for an
interpreter at the start of the script (eg #!/bin/bash), or if that fails,
it falls back on the value of the variable sh-shell-file.

So how can I get my .tcshrc file recognised as a tcsh script?

If I add #!/usr/bin/tcsh to the top, firstly that's changing the file just to
keep Emacs happy; and secondly the file then gets made executable, since I
have executable-make-buffer-file-executable-if-script-p in after-save-hook
(which I rather like).

I can't use 

# -*- sh-shell-file "/usr/bin/tcsh" -*-

since local variables are hacked after the mode setup (including any hook)
has finished, and my default sh-shell-file is "/bin/bash". It seems that
adding after advice to sh-mode suffers from the same problem.

I could use

# -*- eval: (sh-set-shell "tcsh") -*-

but this means I have to set enable-local-eval to t if I'm not to be driven
mad by prompts, and I'd rather not have that setting, as a general rule.

Any ideas gratefully received (no doubt I've missed something obvious!).

reply via email to

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