* Can priority of interpreter-mode-alist over auto-mode-alist be changed?
@ 2008-03-27 12:42 skuhagen
2008-03-28 11:13 ` Peter Dyballa
[not found] ` <mailman.9538.1206702847.18990.help-gnu-emacs@gnu.org>
0 siblings, 2 replies; 12+ messages in thread
From: skuhagen @ 2008-03-27 12:42 UTC (permalink / raw)
To: help-gnu-emacs
Hello all
Sorry for posting twice (here and comp.emacs), I wasn't aware of this
group...
I have a very annoying problem with auto-mode. When editing Tcl-
Files,
which often start with
#!/bin/sh
#\
exec tclsh "$0" "$@"
Emacs goes into shell-script-mode instead of Tcl-mode, although the
filename ends with .tcl.
As far as I understand the documentation, the reason is, that
interpreter-mode-alist is searched
for the interpreter given in the first line, and if one is found,
the
mode-setting from the filename
is ignored. I don't want to change interpreter-mode-alist, but I
want
to have the mode by filename
have priority over mode by first line of file. Is this possible?
TIA, regards
Stephan
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Can priority of interpreter-mode-alist over auto-mode-alist be changed?
2008-03-27 12:42 Can priority of interpreter-mode-alist over auto-mode-alist be changed? skuhagen
@ 2008-03-28 11:13 ` Peter Dyballa
[not found] ` <mailman.9538.1206702847.18990.help-gnu-emacs@gnu.org>
1 sibling, 0 replies; 12+ messages in thread
From: Peter Dyballa @ 2008-03-28 11:13 UTC (permalink / raw)
To: skuhagen; +Cc: help-gnu-emacs
Am 27.03.2008 um 13:42 schrieb skuhagen:
> #!/bin/sh
> #\
> exec tclsh "$0" "$@"
Why can't you use
#!/bin/tclsh
directly?
--
Mit friedvollen Grüßen
Pete
Der Langsamste, der sein Ziel nicht aus den Augen verliert, geht noch
immer geschwinder als jener, der ohne Ziel umherirrt.
Gotthold Ephraim Lessing
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Can priority of interpreter-mode-alist over auto-mode-alist be changed?
[not found] ` <mailman.9538.1206702847.18990.help-gnu-emacs@gnu.org>
@ 2008-03-28 15:20 ` Lowell Gilbert
2008-03-28 15:37 ` Will Parsons
2008-03-29 4:51 ` Tim X
1 sibling, 1 reply; 12+ messages in thread
From: Lowell Gilbert @ 2008-03-28 15:20 UTC (permalink / raw)
To: help-gnu-emacs
Peter Dyballa <Peter_Dyballa@Web.DE> writes:
> Am 27.03.2008 um 13:42 schrieb skuhagen:
>> #!/bin/sh
>> #\
>> exec tclsh "$0" "$@"
>
> Why can't you use
>
> #!/bin/tclsh
>
> directly?
In some cases, because the script has to be run on multiple machines
that have different paths to tclsh.
I've used "Local Variables" sections to solve that in the past.
I wouldn't be surprised if there is a better way these days.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Can priority of interpreter-mode-alist over auto-mode-alist be changed?
2008-03-28 15:20 ` Lowell Gilbert
@ 2008-03-28 15:37 ` Will Parsons
2008-03-28 17:03 ` Lennart Borgman (gmail)
` (2 more replies)
0 siblings, 3 replies; 12+ messages in thread
From: Will Parsons @ 2008-03-28 15:37 UTC (permalink / raw)
To: help-gnu-emacs
Lowell Gilbert wrote:
> Peter Dyballa <Peter_Dyballa@Web.DE> writes:
>
>> Am 27.03.2008 um 13:42 schrieb skuhagen:
>>> #!/bin/sh
>>> #\
>>> exec tclsh "$0" "$@"
>>
>> Why can't you use
>>
>> #!/bin/tclsh
>>
>> directly?
>
> In some cases, because the script has to be run on multiple machines
> that have different paths to tclsh.
> I've used "Local Variables" sections to solve that in the past.
> I wouldn't be surprised if there is a better way these days.
This seems to be a regression with Emacs 22. I, too, have tcl scripts
which begin with the common Tcl idiom cited by the OP, and they are
correctly recognized as tcl mode in Emacs 21 but shell mode in Emacs 22.
So, I'd like to join the OP in asking how to get the original behaviour
back?
--
Will
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Can priority of interpreter-mode-alist over auto-mode-alist be changed?
2008-03-28 15:37 ` Will Parsons
@ 2008-03-28 17:03 ` Lennart Borgman (gmail)
2008-03-28 18:24 ` Peter Dyballa
2008-03-28 19:22 ` Lowell Gilbert
2 siblings, 0 replies; 12+ messages in thread
From: Lennart Borgman (gmail) @ 2008-03-28 17:03 UTC (permalink / raw)
To: william.b.parsons; +Cc: help-gnu-emacs
Will Parsons wrote:
> Lowell Gilbert wrote:
>> Peter Dyballa <Peter_Dyballa@Web.DE> writes:
>>
>>> Am 27.03.2008 um 13:42 schrieb skuhagen:
>>>> #!/bin/sh
>>>> #\
>>>> exec tclsh "$0" "$@"
>>> Why can't you use
>>>
>>> #!/bin/tclsh
>>>
>>> directly?
>> In some cases, because the script has to be run on multiple machines
>> that have different paths to tclsh.
>
>> I've used "Local Variables" sections to solve that in the past.
>> I wouldn't be surprised if there is a better way these days.
>
> This seems to be a regression with Emacs 22. I, too, have tcl scripts
> which begin with the common Tcl idiom cited by the OP, and they are
> correctly recognized as tcl mode in Emacs 21 but shell mode in Emacs 22.
>
> So, I'd like to join the OP in asking how to get the original behaviour
> back?
Did you look at the documentation?
(info "(emacs) Choosing Modes")
It this clear? Can you do what you want?
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Can priority of interpreter-mode-alist over auto-mode-alist be changed?
2008-03-28 15:37 ` Will Parsons
2008-03-28 17:03 ` Lennart Borgman (gmail)
@ 2008-03-28 18:24 ` Peter Dyballa
2008-03-28 19:22 ` Lowell Gilbert
2 siblings, 0 replies; 12+ messages in thread
From: Peter Dyballa @ 2008-03-28 18:24 UTC (permalink / raw)
To: william.b.parsons; +Cc: help-gnu-emacs
Am 28.03.2008 um 16:37 schrieb Will Parsons:
> So, I'd like to join the OP in asking how to get the original
> behaviour
> back?
Send a bug report: Help menu -> Send Bug Report...
--
Greetings
Pete
Isn't vi that text editor with two modes... one that beeps and one
that corrupts your file?
– Dan Jacobson, on comp.os.linux.advocacy
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Can priority of interpreter-mode-alist over auto-mode-alist be changed?
2008-03-28 15:37 ` Will Parsons
2008-03-28 17:03 ` Lennart Borgman (gmail)
2008-03-28 18:24 ` Peter Dyballa
@ 2008-03-28 19:22 ` Lowell Gilbert
2008-03-28 21:34 ` Will Parsons
2 siblings, 1 reply; 12+ messages in thread
From: Lowell Gilbert @ 2008-03-28 19:22 UTC (permalink / raw)
To: help-gnu-emacs
Will Parsons <wbp@nodomain.invalid> writes:
> Lowell Gilbert wrote:
>> Peter Dyballa <Peter_Dyballa@Web.DE> writes:
>>
>>> Am 27.03.2008 um 13:42 schrieb skuhagen:
>>>> #!/bin/sh
>>>> #\
>>>> exec tclsh "$0" "$@"
>>>
>>> Why can't you use
>>>
>>> #!/bin/tclsh
>>>
>>> directly?
>>
>> In some cases, because the script has to be run on multiple machines
>> that have different paths to tclsh.
>
>> I've used "Local Variables" sections to solve that in the past.
>> I wouldn't be surprised if there is a better way these days.
>
> This seems to be a regression with Emacs 22. I, too, have tcl scripts
> which begin with the common Tcl idiom cited by the OP, and they are
> correctly recognized as tcl mode in Emacs 21 but shell mode in Emacs 22.
>
> So, I'd like to join the OP in asking how to get the original behaviour
> back?
Three minutes of investigation led me to think that you're looking for
the variable "magic-mode-alist".
I think that what's happening is that your scripts end in ".tcl" and
the way it used to work was that auto-mode-alist used tcl-mode because
of the filename. [If the scripts don't end in .tcl, I don't see how
it ever worked without a hint inside the file.] Now something is
overriding auto-mode-alist, and it might be the "magic" mode-guessing.
There are other possibilities, but the ones I thought to check don't
seem to have changed lately. [e.g., interpeter-mode-alist]
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Can priority of interpreter-mode-alist over auto-mode-alist be changed?
2008-03-28 19:22 ` Lowell Gilbert
@ 2008-03-28 21:34 ` Will Parsons
2008-03-29 15:24 ` Kevin Rodgers
0 siblings, 1 reply; 12+ messages in thread
From: Will Parsons @ 2008-03-28 21:34 UTC (permalink / raw)
To: help-gnu-emacs
Lowell Gilbert wrote:
> Will Parsons <wbp@nodomain.invalid> writes:
>
>> Lowell Gilbert wrote:
>>> Peter Dyballa <Peter_Dyballa@Web.DE> writes:
>>>
>>>> Am 27.03.2008 um 13:42 schrieb skuhagen:
>>>>> #!/bin/sh
>>>>> #\
>>>>> exec tclsh "$0" "$@"
>>>>
>>>> Why can't you use
>>>>
>>>> #!/bin/tclsh
>>>>
>>>> directly?
>>>
>>> In some cases, because the script has to be run on multiple machines
>>> that have different paths to tclsh.
>>
>>> I've used "Local Variables" sections to solve that in the past.
>>> I wouldn't be surprised if there is a better way these days.
>>
>> This seems to be a regression with Emacs 22. I, too, have tcl scripts
>> which begin with the common Tcl idiom cited by the OP, and they are
>> correctly recognized as tcl mode in Emacs 21 but shell mode in Emacs 22.
>>
>> So, I'd like to join the OP in asking how to get the original behaviour
>> back?
>
> Three minutes of investigation led me to think that you're looking for
> the variable "magic-mode-alist".
Perhaps it is, but if so, after reading the description of the variable I
am left with no idea of how to use it to get the desired effect.
> I think that what's happening is that your scripts end in ".tcl" and
> the way it used to work was that auto-mode-alist used tcl-mode because
> of the filename. [If the scripts don't end in .tcl, I don't see how
> it ever worked without a hint inside the file.] Now something is
> overriding auto-mode-alist, and it might be the "magic" mode-guessing.
Quite right. For scripts that don't end in ".tcl", it would unrealistic to
expect that Emacs should know that a file with a "#!/bin/sh" shebang is
really a Tcl script, and in fact I add a second line in this case
containing "#-*-tcl-*" and that forces Tcl mode. (So the question for me,
at least, is not how to force Tcl mode, but how to get the old behaviour
where Tcl mode is automatically recognized when Emacs should be able to do
so.)
> There are other possibilities, but the ones I thought to check don't
> seem to have changed lately. [e.g., interpeter-mode-alist]
If this seems to be a bug, I'll file a bug report, unless someone can say
that this is an intended change and give an easy way of reverting to the
Emacs 21 behaviour.
--
Will
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Can priority of interpreter-mode-alist over auto-mode-alist be changed?
[not found] ` <mailman.9538.1206702847.18990.help-gnu-emacs@gnu.org>
2008-03-28 15:20 ` Lowell Gilbert
@ 2008-03-29 4:51 ` Tim X
2008-03-29 9:48 ` Peter Dyballa
[not found] ` <mailman.9566.1206784114.18990.help-gnu-emacs@gnu.org>
1 sibling, 2 replies; 12+ messages in thread
From: Tim X @ 2008-03-29 4:51 UTC (permalink / raw)
To: help-gnu-emacs
Peter Dyballa <Peter_Dyballa@Web.DE> writes:
> Am 27.03.2008 um 13:42 schrieb skuhagen:
>> #!/bin/sh
>> #\
>> exec tclsh "$0" "$@"
>
> Why can't you use
>
> #!/bin/tclsh
>
The way the OP wants to call the script is how Tcl and other scripting
languages recommend doing it. This avoids having to hard code the tcl
path in the script - for example, if a preferred and newer version of
tcl was in /usr/local/bin, the OPs preferred method would find that over
an older version in /usr/bin/tcl. Essentially, it is a way of avoiding
explicit paths to interpreters in the script, makinig it more portable
and giving greater flexibility.
Tim
--
tcross (at) rapttech dot com dot au
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Can priority of interpreter-mode-alist over auto-mode-alist be changed?
2008-03-29 4:51 ` Tim X
@ 2008-03-29 9:48 ` Peter Dyballa
[not found] ` <mailman.9566.1206784114.18990.help-gnu-emacs@gnu.org>
1 sibling, 0 replies; 12+ messages in thread
From: Peter Dyballa @ 2008-03-29 9:48 UTC (permalink / raw)
To: Tim X; +Cc: help-gnu-emacs
Am 29.03.2008 um 05:51 schrieb Tim X:
> The way the OP wants to call the script is how Tcl and other scripting
> languages recommend doing it. This avoids having to hard code the tcl
> path in the script
This could be achieved the way it's done with Perl scripts
:
eval 'exec perl -w -S $0 ${1+"$@"}'
The first line allows to use
# -*- perl -*-
or
# -*- tcl -*-
to evoke the proper mood in GNU Emacs ...
--
Greetings
Pete
Upgraded, adj.:
Didn't work the first time.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Can priority of interpreter-mode-alist over auto-mode-alist be changed?
[not found] ` <mailman.9566.1206784114.18990.help-gnu-emacs@gnu.org>
@ 2008-03-29 15:03 ` Will Parsons
0 siblings, 0 replies; 12+ messages in thread
From: Will Parsons @ 2008-03-29 15:03 UTC (permalink / raw)
To: help-gnu-emacs
Peter Dyballa wrote:
>
> Am 29.03.2008 um 05:51 schrieb Tim X:
>> The way the OP wants to call the script is how Tcl and other scripting
>> languages recommend doing it. This avoids having to hard code the tcl
>> path in the script
>
> This could be achieved the way it's done with Perl scripts
>
> :
> eval 'exec perl -w -S $0 ${1+"$@"}'
There's no need introduce eval - the lines
#\
exec tclsh "$0" ${1+"$@"}
serve to invoke tclsh.
> The first line allows to use
>
> # -*- perl -*-
>
> or
>
> # -*- tcl -*-
>
> to evoke the proper mood in GNU Emacs ...
Yes, of course - but the fact remains that it shouldn't be necessary to do
this, and in fact it wasn't under Emacs 21.
--
Will
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Can priority of interpreter-mode-alist over auto-mode-alist be changed?
2008-03-28 21:34 ` Will Parsons
@ 2008-03-29 15:24 ` Kevin Rodgers
0 siblings, 0 replies; 12+ messages in thread
From: Kevin Rodgers @ 2008-03-29 15:24 UTC (permalink / raw)
To: help-gnu-emacs
Will Parsons wrote:
> Lowell Gilbert wrote:
>> Will Parsons <wbp@nodomain.invalid> writes:
>>
>>> Lowell Gilbert wrote:
>>>> Peter Dyballa <Peter_Dyballa@Web.DE> writes:
>>>>
>>>>> Am 27.03.2008 um 13:42 schrieb skuhagen:
>>>>>> #!/bin/sh
>>>>>> #\
>>>>>> exec tclsh "$0" "$@"
>>>>> Why can't you use
>>>>>
>>>>> #!/bin/tclsh
>>>>>
>>>>> directly?
>>>> In some cases, because the script has to be run on multiple machines
>>>> that have different paths to tclsh.
>>>> I've used "Local Variables" sections to solve that in the past.
>>>> I wouldn't be surprised if there is a better way these days.
>>> This seems to be a regression with Emacs 22. I, too, have tcl scripts
>>> which begin with the common Tcl idiom cited by the OP, and they are
>>> correctly recognized as tcl mode in Emacs 21 but shell mode in Emacs 22.
>>>
>>> So, I'd like to join the OP in asking how to get the original behaviour
>>> back?
>> Three minutes of investigation led me to think that you're looking for
>> the variable "magic-mode-alist".
>
> Perhaps it is, but if so, after reading the description of the variable I
> am left with no idea of how to use it to get the desired effect.
How about:
(add-to-list 'magic-mode-alist
(cons (regexp-quote "#\\\nexec tclsh \"$0\" \"$@\"")
'tcl-mode))
--
Kevin Rodgers
Denver, Colorado, USA
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2008-03-29 15:24 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-03-27 12:42 Can priority of interpreter-mode-alist over auto-mode-alist be changed? skuhagen
2008-03-28 11:13 ` Peter Dyballa
[not found] ` <mailman.9538.1206702847.18990.help-gnu-emacs@gnu.org>
2008-03-28 15:20 ` Lowell Gilbert
2008-03-28 15:37 ` Will Parsons
2008-03-28 17:03 ` Lennart Borgman (gmail)
2008-03-28 18:24 ` Peter Dyballa
2008-03-28 19:22 ` Lowell Gilbert
2008-03-28 21:34 ` Will Parsons
2008-03-29 15:24 ` Kevin Rodgers
2008-03-29 4:51 ` Tim X
2008-03-29 9:48 ` Peter Dyballa
[not found] ` <mailman.9566.1206784114.18990.help-gnu-emacs@gnu.org>
2008-03-29 15:03 ` Will Parsons
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.