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:30:18 +0200 Message-ID: <4E231C2A.5090100@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 1310923948 31413 80.91.229.12 (17 Jul 2011 17:32:28 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sun, 17 Jul 2011 17:32:28 +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:32:23 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 1QiVCZ-0001Gy-EE for geh-help-gnu-emacs@m.gmane.org; Sun, 17 Jul 2011 19:32:23 +0200 Original-Received: from localhost ([::1]:45164 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QiVCY-00071v-6T for geh-help-gnu-emacs@m.gmane.org; Sun, 17 Jul 2011 13:32:22 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]:33072) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QiVAv-00071D-7p for help-gnu-emacs@gnu.org; Sun, 17 Jul 2011 13:30:42 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QiVAt-0001uN-8Y for help-gnu-emacs@gnu.org; Sun, 17 Jul 2011 13:30:40 -0400 Original-Received: from moutng.kundenserver.de ([212.227.126.186]:52980) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QiVAs-0001uA-Lq for help-gnu-emacs@gnu.org; Sun, 17 Jul 2011 13:30:39 -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 0M6c40-1Rez2e2Ce4-00wVfu; Sun, 17 Jul 2011 19:30:36 +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:UNyovRuzJVXRxdQjmiPXgfCsVziYOviaBWoiyA1wUOL T0jpxPVvnpuuNixkSDeRUGx9PvKi+3zrHXhQzUErg1lW+aFkiU 3tjhrW6Nq/hsyYy5cqf5HcWNdnYCRfgKRsAlN9yevhZE/dajlX G44hABnZgE+WuoN1IwDrBbPZ72CEuV+189jMNumxuHgX0F/mm3 zAoAc3EBnL4HxMHIVqDaBBlcWZ/N0MSoiZ6GLyhxVU= X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 212.227.126.186 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:81632 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 > > 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)