GNU bug report logs - #3354
tcl-mode regression in Emacs 22

Previous Next

Package: emacs;

Reported by: Will Parsons <wbparsons <at> cshore.com>

Date: Sat, 23 May 2009 18:25:08 UTC

Severity: normal

Merged with 97

Done: Chong Yidong <cyd <at> stupidchicken.com>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 3354 in the body.
You can then email your comments to 3354 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#3354; Package emacs. (Sat, 23 May 2009 18:25:09 GMT) Full text and rfc822 format available.

Acknowledgement sent to Will Parsons <wbparsons <at> cshore.com>:
New bug report received and forwarded. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. (Sat, 23 May 2009 18:25:09 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> emacsbugs.donarmstrong.com (full text, mbox):

From: Will Parsons <wbparsons <at> cshore.com>
To: bug-gnu-emacs <at> gnu.org
Subject: tcl-mode regression in Emacs 22
Date: Sat, 23 May 2009 13:56:22 -0400 (EDT)
Please write in English if possible, because the Emacs maintainers
usually do not have translators to read other languages for them.

Your bug report will be posted to the bug-gnu-emacs <at> gnu.org mailing list,
and to the gnu.emacs.bug news group.

Please describe exactly what actions triggered the bug
and the precise symptoms of the bug:

(This is a repeat of a bug report sent to gnu.emacs.bugs on 29 Mar 2008.)

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
------

i.e., the shebang overrides the .tcl extension in determining programming
mode.

The original bug report was closed out with the response:

> If the shebang specified /bin/tcl, it would be recognized as a Tcl file.
> In ambiguous situations like this, it's better to use a `-*-' line or
> local variables list (see the node "Choosing Modes" in the Emacs
> manual).

I responded:

  Using a shebang of "#!/bin/tclsh" is not portable, since tclsh may be
  installed elsewhere (typically /usr/local/bin).  The idiom cited in the
  original message is commonly used in Tcl scripts to allow for this.  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.  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.

This has continued to bite me.  Yes, I *know* that I can stick a -*-tcl-*-
string in the file to force recognition as a Tcl file, but if the order of
precedence was changed in going from Emacs 21 to Emacs 22, there should be
a way of getting back the former behaviour.  I tried adding to my .emacs
file the line:

  (add-to-list 'auto-mode-alist '("\\.tcl$" . tcl-mode))

but files ending in ".tcl" but have a shebang of "#!/bin/sh" are still
being treated as shell mode.  I would like to re-open this as being a
genuine bug.

---

In GNU Emacs 22.3.1 (i386-portbld-freebsd7.0, GTK+ Version 2.12.11)
 of 2008-12-06 on nephthys.thalatta.eme
Windowing system distributor `The X.Org Foundation', version 11.0.60900000
configured using `configure  '--with-gtk' '--x-libraries=/usr/local/lib' '--x-includes=/usr/local/include' '--prefix=/usr/local' '--mandir=/usr/local/man' '--infodir=/usr/local/info/' '--build=i386-portbld-freebsd7.0' 'build_alias=i386-portbld-freebsd7.0' 'CC=cc' 'CFLAGS=-O2 -fno-strict-aliasing -pipe''

Important settings:
  value of $LC_ALL: nil
  value of $LC_COLLATE: nil
  value of $LC_CTYPE: nil
  value of $LC_MESSAGES: nil
  value of $LC_MONETARY: nil
  value of $LC_NUMERIC: nil
  value of $LC_TIME: nil
  value of $LANG: nil
  locale-coding-system: nil
  default-enable-multibyte-characters: t

Major mode: Shell-script

Minor modes in effect:
  display-time-mode: t
  delete-selection-mode: t
  recentf-mode: t
  tooltip-mode: t
  tool-bar-mode: t
  mouse-wheel-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  unify-8859-on-encoding-mode: t
  utf-translate-cjk-mode: t
  auto-compression-mode: t
  column-number-mode: t
  line-number-mode: t
  transient-mark-mode: t
  abbrev-mode: t





Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#3354; Package emacs. (Thu, 04 Jun 2009 00:35:04 GMT) Full text and rfc822 format available.

Message #8 received at 3354 <at> emacsbugs.donarmstrong.com (full text, mbox):

From: Glenn Morris <rgm <at> gnu.org>
To: Will Parsons <wbparsons <at> cshore.com>
Cc: 3354 <at> debbugs.gnu.org
Subject: Re: bug#3354: tcl-mode regression in Emacs 22
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.



Forcibly Merged 97 3354. Request was from Glenn Morris <rgm <at> gnu.org> to control <at> emacsbugs.donarmstrong.com. (Thu, 04 Jun 2009 00:35:06 GMT) Full text and rfc822 format available.

Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#3354; Package emacs. (Thu, 04 Jun 2009 01:05:04 GMT) Full text and rfc822 format available.

Message #13 received at 3354 <at> emacsbugs.donarmstrong.com (full text, mbox):

From: Glenn Morris <rgm <at> gnu.org>
To: 3354 <at> debbugs.gnu.org
Cc: Will Parsons <wbparsons <at> cshore.com>
Subject: Re: bug#3354: tcl-mode regression in Emacs 22
Date: Wed, 03 Jun 2009 20:56:26 -0400
Glenn Morris wrote:

> #!/usr/bin/env tclsh
>
> (and give it whatever extension you like.)
>
> But this has problems for argument passing.

Actually, no it doesn't.

http://wiki.tcl.tk/812



Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#3354; Package emacs. (Thu, 04 Jun 2009 02:50:05 GMT) Full text and rfc822 format available.

Acknowledgement sent to Jason Rumney <jasonr <at> f2s.com>:
Extra info received and forwarded to list. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. (Thu, 04 Jun 2009 02:50:05 GMT) Full text and rfc822 format available.

Message #18 received at 3354 <at> emacsbugs.donarmstrong.com (full text, mbox):

From: Jason Rumney <jasonr <at> f2s.com>
To: Glenn Morris <rgm <at> gnu.org>, 3354 <at> debbugs.gnu.org
Cc: Will Parsons <wbparsons <at> cshore.com>
Subject: Re: bug#3354: tcl-mode regression in Emacs 22
Date: Thu, 04 Jun 2009 10:41:15 +0800
Glenn Morris wrote:
> 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.
>   

The examples were given further down in that same thread. The file 
extension .conf is commonly used for configuration files. On Debian at 
least, these files are often shell scripts or XML files rather than 
simple name:value pairs that can be parsed by conf-mode. So the reporter 
wanted shell script detection and XML file detection to take priority 
over auto-mode-alist.




Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#3354; Package emacs. (Thu, 04 Jun 2009 04:10:05 GMT) Full text and rfc822 format available.

Message #21 received at 3354 <at> emacsbugs.donarmstrong.com (full text, mbox):

From: Glenn Morris <rgm <at> gnu.org>
To: Jason Rumney <jasonr <at> f2s.com>
Cc: 3354 <at> debbugs.gnu.org, Will Parsons <wbparsons <at> cshore.com>
Subject: Re: bug#3354: tcl-mode regression in Emacs 22
Date: Thu, 04 Jun 2009 00:04:51 -0400
Jason Rumney wrote:

> The examples were given further down in that same thread. The file 
> extension .conf is commonly used for configuration files. On Debian at 
> least, these files are often shell scripts or XML files rather than 
> simple name:value pairs that can be parsed by conf-mode.

Of the 80+ /etc/*.conf files on my Debian system, none start with a
'#!', so what does this have to do with interpreter-mode-alist needing
to take priority over auto-mode-alist?



Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#3354; Package emacs. (Thu, 04 Jun 2009 05:25:06 GMT) Full text and rfc822 format available.

Acknowledgement sent to Jason Rumney <jasonr <at> f2s.com>:
Extra info received and forwarded to list. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. (Thu, 04 Jun 2009 05:25:06 GMT) Full text and rfc822 format available.

Message #26 received at 3354 <at> emacsbugs.donarmstrong.com (full text, mbox):

From: Jason Rumney <jasonr <at> f2s.com>
To: Glenn Morris <rgm <at> gnu.org>
Cc: 3354 <at> debbugs.gnu.org, Will Parsons <wbparsons <at> cshore.com>
Subject: Re: bug#3354: tcl-mode regression in Emacs 22
Date: Thu, 04 Jun 2009 13:14:54 +0800
Glenn Morris wrote:
> Of the 80+ /etc/*.conf files on my Debian system, none start with a
> '#!', so what does this have to do with interpreter-mode-alist needing
> to take priority over auto-mode-alist?
>   

In Debian testing/unstable, they seem to be going through adding .conf 
to the end of all files in /etc subdirectories that have the behavior of 
loading all files in the directory, presumably to solve the problem of 
backup files being evaluated in those directories.  Quite a few of these 
are shell scripts, but having looked properly now, I can only find one 
out of around 300 .conf files under /etc that starts with #!.





bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> emacsbugs.donarmstrong.com. (Thu, 02 Jul 2009 14:24:19 GMT) Full text and rfc822 format available.

This bug report was last modified 14 years and 310 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.