From: "Andreas Röhler" <andreas.roehler@easy-emacs.de>
To: Perry Smith <pedzsan@gmail.com>
Cc: help-gnu-emacs@gnu.org, jidanni@jidanni.org
Subject: Re: how to map sh-mode to mean bash-mode
Date: Sun, 17 Jul 2011 19:48:07 +0200 [thread overview]
Message-ID: <4E232057.1040409@easy-emacs.de> (raw)
In-Reply-To: <812736AF-2EAB-4612-8371-70B47FAC1F7B@gmail.com>
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
next prev parent reply other threads:[~2011-07-17 17:48 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
2011-07-17 20:42 ` bug#9110: " jidanni
2011-07-17 23:02 ` Glenn Morris
2011-07-17 23:53 ` bug#9110: closed (Re: bug#9110: how to map sh-mode to mean bash-mode) jidanni
2011-07-18 15:42 ` Stefan Monnier
2011-07-18 4:51 ` bug#9110: how to map sh-mode to mean bash-mode 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-19 23:25 ` bug#9110: " jidanni
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4E232057.1040409@easy-emacs.de \
--to=andreas.roehler@easy-emacs.de \
--cc=help-gnu-emacs@gnu.org \
--cc=jidanni@jidanni.org \
--cc=pedzsan@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.