From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Glenn Morris Newsgroups: gmane.emacs.help Subject: Setting shell type in sh-mode Date: Thu, 17 Oct 2002 16:12:14 +0100 Organization: None Sender: help-gnu-emacs-admin@gnu.org Message-ID: NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: main.gmane.org 1035012963 28821 80.91.224.249 (19 Oct 2002 07:36:03 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Sat, 19 Oct 2002 07:36:03 +0000 (UTC) Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 182o9P-0007UE-00 for ; Sat, 19 Oct 2002 09:35:59 +0200 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.10) id 182ZiR-0006nH-00; Fri, 18 Oct 2002 12:11:11 -0400 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!newsfeed.gamma.ru!Gamma.RU!peer.news.eu-x.com!server2.netnews.ja.net!pegasus.csx.cam.ac.uk!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 32 Original-NNTP-Posting-Host: xpc21.ast.cam.ac.uk X-Attribution: GM Mail-Copies-To: never Cancel-Lock: sha1:/YApG+7Nc6YyMOU6Vrca+GGR/lw= User-Agent: Gnus, GNU Emacs (www.gnu.org/directory/emacs.html) Original-Xref: shelby.stanford.edu gnu.emacs.help:106149 Original-To: help-gnu-emacs@gnu.org Errors-To: help-gnu-emacs-admin@gnu.org X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.0.11 Precedence: bulk List-Help: List-Post: List-Subscribe: , List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: Xref: main.gmane.org gmane.emacs.help:2740 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:2740 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!).