help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: how to map sh-mode to mean bash-mode


From: Andreas Röhler
Subject: Re: how to map sh-mode to mean bash-mode
Date: Sun, 17 Jul 2011 19:30:18 +0200
User-agent: Mozilla/5.0 (X11; U; Linux i686; de; rv:1.9.2.18) Gecko/20110616 SUSE/3.1.11 Thunderbird/3.1.11

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)







reply via email to

[Prev in Thread] Current Thread [Next in Thread]