From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Henrik Austad Newsgroups: gmane.emacs.help Subject: Re: How to open a file in sh-mode Date: Thu, 14 Aug 2008 12:03:17 +0200 Organization: NTNU, ITK Message-ID: <200808141203.22315.henrikau@stud.ntnu.no> References: <38b2ab8a0808140053g6261aeafmd74692199cea07eb@mail.gmail.com> <200808141016.12117.henrikau@stud.ntnu.no> <38b2ab8a0808140203s53c339f3k70d5887d42a4de2f@mail.gmail.com> Reply-To: henrikau@stud.ntnu.no NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/signed; boundary="nextPart4922127.bYBMT2ABh4"; protocol="application/pgp-signature"; micalg=pgp-sha1 Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1218758356 3365 80.91.229.12 (14 Aug 2008 23:59:16 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 14 Aug 2008 23:59:16 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Aug 15 02:00:09 2008 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1KTmjX-0002rZ-9A for geh-help-gnu-emacs@m.gmane.org; Fri, 15 Aug 2008 01:59:59 +0200 Original-Received: from localhost ([127.0.0.1]:56227 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KTmia-00015Q-Tj for geh-help-gnu-emacs@m.gmane.org; Thu, 14 Aug 2008 19:59:00 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KTZg3-0004CR-7a for help-gnu-emacs@gnu.org; Thu, 14 Aug 2008 06:03:31 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KTZg0-0004Br-Ou for help-gnu-emacs@gnu.org; Thu, 14 Aug 2008 06:03:29 -0400 Original-Received: from [199.232.76.173] (port=46252 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KTZfy-0004Bf-WD for help-gnu-emacs@gnu.org; Thu, 14 Aug 2008 06:03:27 -0400 Original-Received: from mail47.e.nsc.no ([193.213.115.47]:45822) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1KTZfy-0002Gm-9e for help-gnu-emacs@gnu.org; Thu, 14 Aug 2008 06:03:26 -0400 Original-Received: from 062016235195.customer.alfanett.no (062016235195.customer.alfanett.no [62.16.235.195]) by mail47.nsc.no (8.13.8/8.13.5) with ESMTP id m7EA3In4002913; Thu, 14 Aug 2008 12:03:19 +0200 (MEST) User-Agent: KMail/1.9.9 In-Reply-To: <38b2ab8a0808140203s53c339f3k70d5887d42a4de2f@mail.gmail.com> X-detected-kernel: by monty-python.gnu.org: Solaris 10 (beta) X-Mailman-Approved-At: Thu, 14 Aug 2008 19:56:44 -0400 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:56644 Archived-At: --nextPart4922127.bYBMT2ABh4 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline On Thursday 14 August 2008 11:03:07 Francis Moreau wrote: > On Thu, Aug 14, 2008 at 10:16 AM, Henrik Austad =20 wrote: > > On Thursday 14 August 2008 09:53:39 Francis Moreau wrote: > >> Hello, > >> > >> I'm trying to open a file with emacs automatically set on sh-mode. > >> The file name can't be used to guess that emacs should be in sh-mode > >> when opening it. > >> > >> So I tried: > >> > >> $ emacs -f sh-mode foo > >> > >> But that doesn't work. > >> > >> Could anybody give me some advices ? > > > > 1) which version of emacs are you using? > > 2) is it a valid-sh file? i.e. does it start with #!/bin/bash on the > > first line? > > No, it's actually the file created by fc(1) to edit the bash history. > > It uses the FCEDIT env variable to launch the editor it going to use. > > So I'd like to set it to: > > export FCEDIT=3D"emacs -f sh-mode" > > so that fc(1) uses emacs as editor in sh-mode directly. > > Note that the name of the temporary file is *appended* to what you > specified in FCEDIT. so, basically you are looking for a way of putting #!/bin/bash before the=20 output of fc is included? I don't see any obvious ways of doing this, but, you could, if you wanted t= o,=20 use .bash_history (or the appropriate history-file for your shell) and grep= =20 for what you want there? When you set emacs to be the editor, remember that you call emacs with a ne= w=20 file as argument, i.e. if you specify foo as a file, emacs will open *both*= =20 foo and the new file from fc.=20 You could, perhaps, add a hook in .emacs as all files created by fc starts= =20 with [shell]-fc- so basically, I think the question boils down to: """ How do I create a hook in my .emacs so that all files starting with bash-fc= =2D*=20 will load sh-mode? """ =2D-=20 mvh Henrik Austad --nextPart4922127.bYBMT2ABh4 Content-Type: application/pgp-signature; name=signature.asc Content-Description: This is a digitally signed message part. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) iD8DBQBIpALq6k5VT6v45lkRAnqRAKDggCwMlxXg+/XBo6dvhq6vaYo9EwCgzDCQ S6VGY5+4oWp+U5evzuEWif8= =LGze -----END PGP SIGNATURE----- --nextPart4922127.bYBMT2ABh4--