Subject: Re: bug#3354: tcl-mode regression in Emacs 22

From: Glenn Morris <[email-masked]>
Date: Wed, 03 Jun 2009 20:28:39 -0400

unarchive 97
forcemerge 97 3354
stop

Will Parsons wrote:

> The following valid Tcl script is recognized automatically as Tcl mode
> under Emacs 21 but as shell mode under Emacs 22:
>
> ------
> isis% cat test.tcl
> #!/bin/sh
> #\
> exec tclsh "$0" ${1+"$@"}
> puts test
[...]
>   Using a shebang of "#!/bin/tclsh" is not portable, since tclsh may be
>   installed elsewhere (typically /usr/local/bin).

#!/usr/bin/env tclsh

(and give it whatever extension you like.)

But this has problems for argument passing.

> I am aware that "-*-" can be used to force recognition of Tcl mode,
> but this should not be necessary if the script has a ".tcl"
> extension, and in fact it is not necessary in versions of Emacs
> prior to version 22, so the current behaviour is a regression.

It's a change.

> If for some reason a decision was made to have the shebang override
> the extension to determine the mode, then there should be an easy
> way of getting back the previous behaviour, *without* having to add
> instructions to Emacs to the script files themselves.

(setq interpreter-mode-alist
      (delete (assoc "sh" interpreter-mode-alist)
            interpreter-mode-alist))

(but #!/bin/sh scripts without filename extensions, which are
numerous, will no longer be opened in sh-mode).

I don't know what the reason is for giving interpreter-mode-alist the
highest priority (above magic-mode-alist as well). The only reference
I can find is:

http://lists.gnu.org/archive/html/emacs-pretest-bug/2004-10/msg00215.html

which just says "I feel this [the old behaviour] to be wrong", with no
examples.