From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: =?ISO-8859-1?Q?Andreas_R=F6hler?= Newsgroups: gmane.emacs.help Subject: Re: how to map sh-mode to mean bash-mode Date: Sun, 17 Jul 2011 19:48:07 +0200 Message-ID: <4E232057.1040409@easy-emacs.de> References: <87mxgfxfim.fsf@jidanni.org> <4E22AADE.1090701@easy-emacs.de> <812736AF-2EAB-4612-8371-70B47FAC1F7B@gmail.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit X-Trace: dough.gmane.org 1310924979 4632 80.91.229.12 (17 Jul 2011 17:49:39 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sun, 17 Jul 2011 17:49:39 +0000 (UTC) Cc: help-gnu-emacs@gnu.org, jidanni@jidanni.org To: Perry Smith Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sun Jul 17 19:49:33 2011 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1QiVTA-0006L1-6d for geh-help-gnu-emacs@m.gmane.org; Sun, 17 Jul 2011 19:49:32 +0200 Original-Received: from localhost ([::1]:34568 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QiVT9-0001U0-9r for geh-help-gnu-emacs@m.gmane.org; Sun, 17 Jul 2011 13:49:31 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]:49379) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QiVRv-0001Tq-0D for help-gnu-emacs@gnu.org; Sun, 17 Jul 2011 13:48:16 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QiVRt-00047q-GI for help-gnu-emacs@gnu.org; Sun, 17 Jul 2011 13:48:14 -0400 Original-Received: from moutng.kundenserver.de ([212.227.17.8]:61591) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QiVRs-00047j-Vn for help-gnu-emacs@gnu.org; Sun, 17 Jul 2011 13:48:13 -0400 Original-Received: from [192.168.178.27] (brln-4dbc6ccd.pool.mediaWays.net [77.188.108.205]) by mrelayeu.kundenserver.de (node=mreu3) with ESMTP (Nemesis) id 0MWcMY-1QxPwA2PD0-00Xf88; Sun, 17 Jul 2011 19:48:08 +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 In-Reply-To: <812736AF-2EAB-4612-8371-70B47FAC1F7B@gmail.com> X-Provags-ID: V02:K0:MC2ybbSKrG6no7p+4fexv9Ro097xYMyB+bDhjXPlOJP /muYcOrGQ7tD3w9GE4tr3wYK0hFGqD/2K7VCTNBglQku60LYK7 4bql4XcPQGVms0mpLEeALmkWAOAkalypimCre2yq8IonGORQo5 6EZx7zD3JDN9OSycX5PAxdQfKI4AjCXvfBAgndWzv3yIfk71zf G6wY6puoIzfmPHuNVxgw4vYvEY1d8U83ktQ92Olz4g= X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 212.227.17.8 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:81634 Archived-At: 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