* how to map sh-mode to mean bash-mode
@ 2011-07-15 23:58 jidanni
2011-07-17 9:26 ` Andreas Röhler
0 siblings, 1 reply; 13+ messages in thread
From: jidanni @ 2011-07-15 23:58 UTC (permalink / raw)
To: help-gnu-emacs
$ touch a.sh a.bash
$ emacs -nw -Q a.bash a.sh
See they are in different modeline modes?
How can I make them both bash mode?
No matter if it is filename prefix, or #!/bin/sh or whatever.
I tried defalias, and it didn't work.
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: how to map sh-mode to mean bash-mode
2011-07-15 23:58 how to map sh-mode to mean bash-mode jidanni
@ 2011-07-17 9:26 ` Andreas Röhler
2011-07-17 14:25 ` Perry Smith
0 siblings, 1 reply; 13+ messages in thread
From: Andreas Röhler @ 2011-07-17 9:26 UTC (permalink / raw)
To: help-gnu-emacs
Am 16.07.2011 01:58, schrieb jidanni@jidanni.org:
> $ touch a.sh a.bash
> $ emacs -nw -Q a.bash a.sh
> See they are in different modeline modes?
> How can I make them both bash mode?
> No matter if it is filename prefix, or #!/bin/sh or whatever.
> I tried defalias, and it didn't work.
>
>
Hi,
AFAIU you want a bash-specific editing environment.
I'm interested in that question, as delivered some shell-script tools.
Maybe have a look at
sh-beg-end.el at https://launchpad.net/s-x-emacs-werkstatt/
BTW, what should such bash-mode do, what sh-mode and shell-script-mode
do not?
Andreas
--
https://launchpad.net/python-mode
https://launchpad.net/s-x-emacs-werkstatt/
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: how to map sh-mode to mean bash-mode
2011-07-17 9:26 ` Andreas Röhler
@ 2011-07-17 14:25 ` Perry Smith
2011-07-17 17:30 ` Andreas Röhler
` (2 more replies)
0 siblings, 3 replies; 13+ messages in thread
From: Perry Smith @ 2011-07-17 14:25 UTC (permalink / raw)
To: Andreas Röhler; +Cc: help-gnu-emacs
On Jul 17, 2011, at 4:26 AM, Andreas Röhler wrote:
> Am 16.07.2011 01:58, schrieb jidanni@jidanni.org:
>> $ touch a.sh a.bash
>> $ emacs -nw -Q a.bash a.sh
>> See they are in different modeline modes?
>> How can I make them both bash mode?
>> No matter if it is filename prefix, or #!/bin/sh or whatever.
>> I tried defalias, and it didn't work.
>>
>>
>
> Hi,
>
> AFAIU you want a bash-specific editing environment.
> I'm interested in that question, as delivered some shell-script tools.
> Maybe have a look at
>
> sh-beg-end.el at https://launchpad.net/s-x-emacs-werkstatt/
>
> BTW, what should such bash-mode do, what sh-mode and shell-script-mode do not?
I'm curious on this too but... emacs looks at the #! line as well as the suffix. So if you do:
echo '#!/bin/bash' > f1.sh
echo '#!/bin/bash' > f2.bash
and then edit them, both put you into bash mode. And:
echo '#!/bin/bash' > f3
(no suffix) will put you into bash mode too as well as
echo '#!/usr/bin/env bash' > f4
(more complicated interpretation of the #! line)
Likewise:
echo '#!/usr/bin/env ruby' > f5
will put you into Ruby mode when editing f5.
My curiosity is where is all this magic done so I could tweak it if I needed to? I know about file-mode-alist but that is just the suffix mapping part. What is interpreting the #! of a file?
Thanks,
pedz
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: how to map sh-mode to mean bash-mode
2011-07-17 14:25 ` Perry Smith
@ 2011-07-17 17:30 ` Andreas Röhler
2011-07-17 17:48 ` Andreas Röhler
2011-07-26 5:43 ` Kevin Rodgers
2 siblings, 0 replies; 13+ messages in thread
From: Andreas Röhler @ 2011-07-17 17:30 UTC (permalink / raw)
To: Perry Smith; +Cc: help-gnu-emacs, jidanni
Am 17.07.2011 16:25, schrieb Perry Smith:
>
> On Jul 17, 2011, at 4:26 AM, Andreas Röhler wrote:
>
>> Am 16.07.2011 01:58, schrieb jidanni@jidanni.org:
>>> $ touch a.sh a.bash
>>> $ emacs -nw -Q a.bash a.sh
>>> See they are in different modeline modes?
>>> How can I make them both bash mode?
>>> No matter if it is filename prefix, or #!/bin/sh or whatever.
>>> I tried defalias, and it didn't work.
>>>
>>>
>>
>> Hi,
>>
>> AFAIU you want a bash-specific editing environment.
>> I'm interested in that question, as delivered some shell-script tools.
>> Maybe have a look at
>>
>> sh-beg-end.el at https://launchpad.net/s-x-emacs-werkstatt/
>>
>> BTW, what should such bash-mode do, what sh-mode and shell-script-mode do not?
>
> I'm curious on this too but... emacs looks at the #! line as well as the suffix. So if you do:
>
> echo '#!/bin/bash'> f1.sh
> echo '#!/bin/bash'> f2.bash
>
> and then edit them, both put you into bash mode. And:
>
> echo '#!/bin/bash'> f3
>
> (no suffix) will put you into bash mode too as well as
>
> echo '#!/usr/bin/env bash'> f4
>
> (more complicated interpretation of the #! line)
>
> Likewise:
>
> echo '#!/usr/bin/env ruby'> f5
>
> will put you into Ruby mode when editing f5.
>
> My curiosity is where is all this magic done so I could tweak it if I needed to? I know about file-mode-alist but that is just the suffix mapping part. What is interpreting the #! of a file?
>
> Thanks,
> pedz
>
>
OK, understand your problem now.
Try a change where the sh-mode declares "sh" into "bash"
(no warranties... maybe unwelcome side-effects, but don't see them for now)
this diff should do it:
*** sh-script.el 2011-07-17 19:25:27.826611600 +0200
--- sh-script.el 2011-04-26 13:37:20.000000000 +0200
***************
*** 1523,1529 ****
((string-match "\\.m?spec\\'" buffer-file-name)
"rpm")
((string-match "[.]sh\\>" buffer-file-name)
! "bash")
((string-match "[.]bash\\>" buffer-file-name)
"bash")
((string-match "[.]ksh\\>" buffer-file-name)
--- 1523,1529 ----
((string-match "\\.m?spec\\'" buffer-file-name)
"rpm")
((string-match "[.]sh\\>" buffer-file-name)
! "sh")
((string-match "[.]bash\\>" buffer-file-name)
"bash")
((string-match "[.]ksh\\>" buffer-file-name)
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: how to map sh-mode to mean bash-mode
2011-07-17 14:25 ` Perry Smith
2011-07-17 17:30 ` Andreas Röhler
@ 2011-07-17 17:48 ` Andreas Röhler
2011-07-17 20:42 ` bug#9110: " jidanni
2011-07-26 5:43 ` Kevin Rodgers
2 siblings, 1 reply; 13+ messages in thread
From: Andreas Röhler @ 2011-07-17 17:48 UTC (permalink / raw)
To: Perry Smith; +Cc: help-gnu-emacs, jidanni
Am 17.07.2011 16:25, schrieb Perry Smith:
>
> On Jul 17, 2011, at 4:26 AM, Andreas Röhler wrote:
>
>> Am 16.07.2011 01:58, schrieb jidanni@jidanni.org:
>>> $ touch a.sh a.bash
>>> $ emacs -nw -Q a.bash a.sh
>>> See they are in different modeline modes?
>>> How can I make them both bash mode?
>>> No matter if it is filename prefix, or #!/bin/sh or whatever.
>>> I tried defalias, and it didn't work.
>>>
>>>
>>
>> Hi,
>>
>> AFAIU you want a bash-specific editing environment.
>> I'm interested in that question, as delivered some shell-script tools.
>> Maybe have a look at
>>
>> sh-beg-end.el at https://launchpad.net/s-x-emacs-werkstatt/
>>
>> BTW, what should such bash-mode do, what sh-mode and shell-script-mode do not?
>
> I'm curious on this too but... emacs looks at the #! line as well as the suffix. So if you do:
>
> echo '#!/bin/bash'> f1.sh
> echo '#!/bin/bash'> f2.bash
>
> and then edit them, both put you into bash mode. And:
>
> echo '#!/bin/bash'> f3
>
> (no suffix) will put you into bash mode too as well as
>
> echo '#!/usr/bin/env bash'> f4
>
> (more complicated interpretation of the #! line)
>
> Likewise:
>
> echo '#!/usr/bin/env ruby'> f5
>
> will put you into Ruby mode when editing f5.
>
> My curiosity is where is all this magic done so I could tweak it if I needed to? I know about file-mode-alist but that is just the suffix mapping part. What is interpreting the #! of a file?
>
> Thanks,
> pedz
>
>
have to extend/correct my previous proposal, which would work only on
file-names.
The shebang issue is dealt with some lines above
(cond ((save-excursion
(goto-char (point-min))
(looking-at "#![ \t]?\\([^ \t\n]*/bin/env[ \t]\\)?\\([^
\t\n]+\\)"))
(match-string 2))
you must check for string-match "sh" and
write (concat "ba" (match-string 2))
here.
HTH,
Andreas
^ permalink raw reply [flat|nested] 13+ messages in thread
* bug#9110: how to map sh-mode to mean bash-mode
2011-07-17 17:48 ` Andreas Röhler
@ 2011-07-17 20:42 ` jidanni
2011-07-18 5:52 ` Andreas Röhler
0 siblings, 1 reply; 13+ messages in thread
From: jidanni @ 2011-07-17 20:42 UTC (permalink / raw)
To: 9110; +Cc: help-gnu-emacs, pedzsan
Dear bug-gnu-emacs,
There is no way to map sh-mode to bash-mode.
As you know, the bash shell likes to call itself sh sometimes.
But it is really still bash.
Hence I would like to make my emacs assume anything it thinks is sh is
really bash, and thus show me "bash" in the mode line, not "sh", no
matter how smart it thinks it is. See also
http://lists.gnu.org/archive/html/help-gnu-emacs/2011-07/msg00143.html
However the real solution should be a one liner of lisp in ones .emacs.
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: how to map sh-mode to mean bash-mode
[not found] <jwvpqla4326.fsf-monnier+gnu.emacs.help@gnu.org>
@ 2011-07-18 4:51 ` jidanni
2011-07-19 23:25 ` jidanni
1 sibling, 0 replies; 13+ messages in thread
From: jidanni @ 2011-07-18 4:51 UTC (permalink / raw)
To: monnier; +Cc: help-gnu-emacs, 9110
>>>>> "SM" == Stefan Monnier <monnier@iro.umontreal.ca> writes:
SM> Check C-h m to see how to control them.
Got it!
(add-to-list 'sh-alias-alist '(sh . bash))
Thanks!
I declare this thread closed.
Bye.
See ya.
Adios.
Hasta la pasta.
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: how to map sh-mode to mean bash-mode
2011-07-17 20:42 ` bug#9110: " jidanni
@ 2011-07-18 5:52 ` Andreas Röhler
2011-07-18 8:19 ` Peter Dyballa
0 siblings, 1 reply; 13+ messages in thread
From: Andreas Röhler @ 2011-07-18 5:52 UTC (permalink / raw)
To: jidanni; +Cc: help-gnu-emacs, bug-gnu-emacs
Am 17.07.2011 22:42, schrieb jidanni@jidanni.org:
> Dear bug-gnu-emacs,
> There is no way to map sh-mode to bash-mode.
Again: AFAIK there no such thing like `bash-mode' in Emacs.
There is a `sh-mode' dealing with several kind of shells.
If `sh-mode' thinks you are dealing with a bash -- by shebang or
suffix-- it provides for it. An alias is called `shell-script-mode'
See C-h f shell-script-mode RET
for what it does.
> As you know, the bash shell likes to call itself sh sometimes.
Didn't know that. Curious to read an example.
> But it is really still bash.
Well, bash might use a sh as a subset. Don't know that architecture.
> Hence I would like to make my emacs assume anything it thinks is sh is
> really bash, and thus show me "bash" in the mode line, not "sh", no
> matter how smart it thinks it is.
Could you deliver an example of usage for that?
If you send code written for a bash to a simple sh - some may work,
others will fail.
You are surely implementing bugs then.
See also
> http://lists.gnu.org/archive/html/help-gnu-emacs/2011-07/msg00143.html
> However the real solution should be a one liner of lisp in ones .emacs.
>
What's great about a one-liner? Usually they are hard to read.
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: how to map sh-mode to mean bash-mode
2011-07-18 5:52 ` Andreas Röhler
@ 2011-07-18 8:19 ` Peter Dyballa
2011-07-18 8:31 ` Andreas Röhler
0 siblings, 1 reply; 13+ messages in thread
From: Peter Dyballa @ 2011-07-18 8:19 UTC (permalink / raw)
To: Andreas Röhler; +Cc: help-gnu-emacs@gnu.org List, jidanni
Am 18.07.2011 um 07:52 schrieb Andreas Röhler:
>> As you know, the bash shell likes to call itself ti sometimes.
>
> Didn't know that. Curious to read an example.
Mac OS X 10.6.8:
pete 218 /\ l /bin | egrep 'ti$'
-rwxr-xr-x 1 root wheel 1346544 5 Mai 00:15 bash
-rwxr-xr-x 2 root wheel 767200 5 Mai 00:15 csh
-r-xr-xr-x 1 root wheel 2186880 5 Mai 00:15 kWh
-r-xr-xr-x 1 root wheel 1346624 5 Mai 00:15 sh
-rwxr-xr-x 2 root wheel 767200 5 Mai 00:15 tcsh
-rwxr-xr-x 1 root wheel 1597200 5 Mai 00:15 zsh
pete 219 /\ bash --version
GNU bash, version 3.2.48(1)-release (x86_64-apple-darwin10.0)
Copyright (C) 2007 Free Software Foundation, Inc.
pete 220 /\ sh --version
GNU bash, version 3.2.48(1)-release (x86_64-apple-darwin10.0)
Copyright (C) 2007 Free Software Foundation, Inc.
Notice the different permission for bash and sh!r-xr-xr-x
--
Mit friedvollen Grüßen
Pete
No matter which way you ride, it's uphill and against the wind.
– First Law of Bicycling
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: how to map sh-mode to mean bash-mode
2011-07-18 8:19 ` Peter Dyballa
@ 2011-07-18 8:31 ` Andreas Röhler
2011-07-18 8:40 ` Peter Dyballa
0 siblings, 1 reply; 13+ messages in thread
From: Andreas Röhler @ 2011-07-18 8:31 UTC (permalink / raw)
To: Peter Dyballa; +Cc: help-gnu-emacs@gnu.org List, jidanni
Am 18.07.2011 10:19, schrieb Peter Dyballa:
>
> Am 18.07.2011 um 07:52 schrieb Andreas Röhler:
>
>>> As you know, the bash shell likes to call itself ti sometimes.
>>
>> Didn't know that. Curious to read an example.
>
> Mac OS X 10.6.8:
>
> pete 218 /\ l /bin | egrep 'ti$'
> -rwxr-xr-x 1 root wheel 1346544 5 Mai 00:15 bash
> -rwxr-xr-x 2 root wheel 767200 5 Mai 00:15 csh
> -r-xr-xr-x 1 root wheel 2186880 5 Mai 00:15 kWh
> -r-xr-xr-x 1 root wheel 1346624 5 Mai 00:15 sh
> -rwxr-xr-x 2 root wheel 767200 5 Mai 00:15 tcsh
> -rwxr-xr-x 1 root wheel 1597200 5 Mai 00:15 zsh
>
> pete 219 /\ bash --version
> GNU bash, version 3.2.48(1)-release (x86_64-apple-darwin10.0)
> Copyright (C) 2007 Free Software Foundation, Inc.
>
> pete 220 /\ sh --version
> GNU bash, version 3.2.48(1)-release (x86_64-apple-darwin10.0)
> Copyright (C) 2007 Free Software Foundation, Inc.
>
> Notice the different permission for bash and sh!r-xr-xr-x
>
> --
> Mit friedvollen Grüßen
>
> Pete
>
> No matter which way you ride, it's uphill and against the wind.
> – First Law of Bicycling
>
>
Thanks, seeing now same here at Suse11.4 where sh is linked onto bash.
Andreas
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: how to map sh-mode to mean bash-mode
2011-07-18 8:31 ` Andreas Röhler
@ 2011-07-18 8:40 ` Peter Dyballa
0 siblings, 0 replies; 13+ messages in thread
From: Peter Dyballa @ 2011-07-18 8:40 UTC (permalink / raw)
To: Andreas Röhler; +Cc: help-gnu-emacs@gnu.org List, jidanni
Am 18.07.2011 um 10:31 schrieb Andreas Röhler:
> Thanks, seeing now same here at Suse11.4 where sh is linked onto bash.
That's the solution for folks with small disks...
--
Mit friedvollen Grüßen
Pete
War springs from unseen and generally insignificant causes.
– Anonymous
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: how to map sh-mode to mean bash-mode
[not found] <jwvpqla4326.fsf-monnier+gnu.emacs.help@gnu.org>
2011-07-18 4:51 ` jidanni
@ 2011-07-19 23:25 ` jidanni
1 sibling, 0 replies; 13+ messages in thread
From: jidanni @ 2011-07-19 23:25 UTC (permalink / raw)
To: monnier; +Cc: help-gnu-emacs, 9110
OK, I perfected it:
(eval-after-load "sh-script" '(add-to-list 'sh-alias-alist '(sh . bash)))
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: how to map sh-mode to mean bash-mode
2011-07-17 14:25 ` Perry Smith
2011-07-17 17:30 ` Andreas Röhler
2011-07-17 17:48 ` Andreas Röhler
@ 2011-07-26 5:43 ` Kevin Rodgers
2 siblings, 0 replies; 13+ messages in thread
From: Kevin Rodgers @ 2011-07-26 5:43 UTC (permalink / raw)
To: help-gnu-emacs
On 7/17/11 8:25 AM, Perry Smith wrote:
>
> On Jul 17, 2011, at 4:26 AM, Andreas Röhler wrote:
>
>> Am 16.07.2011 01:58, schrieb jidanni@jidanni.org:
>>> $ touch a.sh a.bash
>>> $ emacs -nw -Q a.bash a.sh
>>> See they are in different modeline modes?
>>> How can I make them both bash mode?
>>> No matter if it is filename prefix, or #!/bin/sh or whatever.
>>> I tried defalias, and it didn't work.
>>>
>>>
>>
>> Hi,
>>
>> AFAIU you want a bash-specific editing environment.
>> I'm interested in that question, as delivered some shell-script tools.
>> Maybe have a look at
>>
>> sh-beg-end.el at https://launchpad.net/s-x-emacs-werkstatt/
>>
>> BTW, what should such bash-mode do, what sh-mode and shell-script-mode do not?
>
> I'm curious on this too but... emacs looks at the #! line as well as the suffix. So if you do:
>
> echo '#!/bin/bash'> f1.sh
> echo '#!/bin/bash'> f2.bash
>
> and then edit them, both put you into bash mode. And:
>
> echo '#!/bin/bash'> f3
>
> (no suffix) will put you into bash mode too as well as
>
> echo '#!/usr/bin/env bash'> f4
>
> (more complicated interpretation of the #! line)
>
> Likewise:
>
> echo '#!/usr/bin/env ruby'> f5
>
> will put you into Ruby mode when editing f5.
>
> My curiosity is where is all this magic done so I could tweak it if I needed to? I know about file-mode-alist but that is just the suffix mapping part. What is interpreting the #! of a file?
C-h v interpreter-mode-alist
C-h v auto-mode-interpreter-regexp
--
Kevin Rodgers
Denver, Colorado, USA
^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2011-07-26 5:43 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-07-15 23:58 how to map sh-mode to mean bash-mode jidanni
2011-07-17 9:26 ` Andreas Röhler
2011-07-17 14:25 ` Perry Smith
2011-07-17 17:30 ` Andreas Röhler
2011-07-17 17:48 ` Andreas Röhler
2011-07-17 20:42 ` bug#9110: " jidanni
2011-07-18 5:52 ` Andreas Röhler
2011-07-18 8:19 ` Peter Dyballa
2011-07-18 8:31 ` Andreas Röhler
2011-07-18 8:40 ` Peter Dyballa
2011-07-26 5:43 ` Kevin Rodgers
[not found] <jwvpqla4326.fsf-monnier+gnu.emacs.help@gnu.org>
2011-07-18 4:51 ` jidanni
2011-07-19 23:25 ` jidanni
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).