From xemacs-m  Fri Feb 28 15:17:41 1997
Received: from steadfast.teradyne.com (steadfast.teradyne.com [131.101.1.200])
	by xemacs.org (8.8.5/8.8.5) with ESMTP id PAA11253
	for <xemacs-beta@xemacs.org>; Fri, 28 Feb 1997 15:17:40 -0600 (CST)
Received: from engine.ecf.teradyne.com (engine.ecf.teradyne.com [131.101.192.6]) by steadfast.teradyne.com (8.7.1/8.7.1) with ESMTP id QAA08190; Fri, 28 Feb 1997 16:14:13 -0500 (EST)
Received: from midnight.eng.ecf.teradyne.com (midnight.ecf.teradyne.com [131.101.192.49]) by engine.ecf.teradyne.com (8.7.1/8.7.1) with SMTP id WAA26318; Fri, 28 Feb 1997 22:10:19 +0100 (MET)
Received: by midnight.eng.ecf.teradyne.com (SMI-8.6/SMI-SVR4)
	id WAA22982; Fri, 28 Feb 1997 22:10:20 +0100
To: XEmacs Beta Mailing List <xemacs-beta@xemacs.org>,
        Daniel.Pfeiffer@Informatik.START.dbp.de
Subject: sh-script.el's un-smart minor-mode handling
X-Face: 4[iHdXiTu\V3u[~\I)<f9HC);%~nG8`oUqv#uzvs6=\V{AjN6Sn
 c/qi;YLwRmEbt8Y*=j5n(urqY@chPh@J'D"QlqD!C8>*}#kYF[-tYl3VZga/HSOP|K,{L
 Rtu@f0y/=O&Cu}\:~d|P$JON?pn?j,&CnPb1z#/TL9bkAJwyol&a:SvYj-VYbM=Dtxhk9
 =w|R6U3_;SH&B<Mfy6Q%#
Mime-Version: 1.0 (generated by tm-edit 7.105)
Content-Type: multipart/mixed;
 boundary="Multipart_Fri_Feb_28_22:10:18_1997-1"
Content-Transfer-Encoding: 7bit
From: Adrian Aichner <aichner@ecf.teradyne.com>
Date: 28 Feb 1997 22:10:18 +0100
Message-ID: <rxs20a063id.fsf@midnight.ecf.teradyne.com>
Lines: 106
X-Mailer: Gnus v5.4.15/XEmacs 20.1

--Multipart_Fri_Feb_28_22:10:18_1997-1
Content-Type: text/plain; charset=US-ASCII


Hello Daniel, Hello Shell Script Programmers!

I like sh-mode as implemented by sh-script a lot.

The concern I have is its algorithm to select the proper shell syntax.

I had to implement the following work-around to setup the mode
properly for the shell being programmed.

What sh-mode can do (xemacs -q -no-site-file):

1.
For an empty file it asks whether to insert the magic number in
accordance with either: env. var. SHELL or the value of Lisp variable
sh-shell-file.
OK

2.
For a file already containing a proper magic number the shell is not
set since the file is not of size 0. The chosen shell is not shown in
the modeline. It will be wrong for all non-csh scripts when your SHELL
is set to csh.
NOT OK

What my setup does (site-start.el):

The shell setting within sh-mode is governed by auto-mode-alist for
some, and by interpreter-mode-alist for others.
I create little wrapper functions for sh-mode which will set the shell
correctly.

That works fine for me.

My conclusion is that sh-mode doesn't work *quite* right since the
user has to set up these nasty wrapper functions to make sh-mode do
what it should do in the first place.

If you have a better solution, please let me know.

Friendly Regards,

Adrian


--Multipart_Fri_Feb_28_22:10:18_1997-1
Content-Type: text/plain; charset=US-ASCII

(setq auto-mode-alist
      (append '(("\\.C$"  . c++-mode)
                ("\\.cc$" . c++-mode)
                ("\\.hh$" . c++-mode)
                ("\\.t$" . c++-mode)
                ("\\.c$"  . c-mode)
                ("\\.h$"  . c++-mode)
                ("\\.s$" . asm-mode)
                ("\\.n?awk$" . awk-mode)
;;; It's not the extension, it's the magic number that counts!
;;; Ideally they agree.
;;;             ("\\.csh$" . csh-sh-mode)
;;;             ("\\.ksh$" . ksh-sh-mode)
;;;             ("\\.sh$" . sh-sh-mode)
;;; .cshrc, .login and .profile are magic-number-less and have a known
;;; syntax for a given Operating System. 
                ("\\..*\\(cshrc\\|login\\).*" . csh-sh-mode)
                ("\\..*\\(profile\\).*" . sh-sh-mode)
;;;             ...
                )
              auto-mode-alist))
(setq interpreter-mode-alist
      (cons '("^#!.*/csh\\b" . csh-sh-mode) interpreter-mode-alist))
(setq interpreter-mode-alist
      (cons '("^#!.*/ksh\\b" . ksh-sh-mode) interpreter-mode-alist))
(setq interpreter-mode-alist
      (cons '("^#!.*/sh\\b" . sh-sh-mode) interpreter-mode-alist))

--Multipart_Fri_Feb_28_22:10:18_1997-1
Content-Type: text/plain; charset=US-ASCII

(defun csh-sh-mode ()
  (setq sh-mode-hook
            '(lambda ()
               (sh-set-shell "/bin/csh")))
  (sh-mode))
(defun ksh-sh-mode ()
  (setq sh-mode-hook
            '(lambda ()
               (sh-set-shell "/bin/ksh")))
  (sh-mode))
(defun sh-sh-mode ()
  (setq sh-mode-hook
            '(lambda ()
               (sh-set-shell "/bin/sh")))
  (sh-mode))
(autoload 'sh-mode "sh-script" "Major mode for editing shell scripts.")

-- 
  Teradyne GmbH               Adrian Aichner Applications Engineer
  Semiconductor Test Group    Telephone      +49/89/418 61 (0)-208
  Dingolfinger Strasse 2      Fax            +49/89/418 61-217
  D-81673 M"UNCHEN            E-mail         aichner@ecf.teradyne.com

--Multipart_Fri_Feb_28_22:10:18_1997-1--

