[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: How to open a file in sh-mode
From: |
Henrik Austad |
Subject: |
Re: How to open a file in sh-mode |
Date: |
Thu, 14 Aug 2008 12:03:17 +0200 |
User-agent: |
KMail/1.9.9 |
On Thursday 14 August 2008 11:03:07 Francis Moreau wrote:
> On Thu, Aug 14, 2008 at 10:16 AM, Henrik Austad <henrikau@stud.ntnu.no>
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="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
output of fc is included?
I don't see any obvious ways of doing this, but, you could, if you wanted to,
use .bash_history (or the appropriate history-file for your shell) and grep
for what you want there?
When you set emacs to be the editor, remember that you call emacs with a new
file as argument, i.e. if you specify foo as a file, emacs will open *both*
foo and the new file from fc.
You could, perhaps, add a hook in .emacs as all files created by fc starts
with [shell]-fc-<numbers>
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-*
will load sh-mode?
"""
--
mvh Henrik Austad
signature.asc
Description: This is a digitally signed message part.
- Re: How to open a file in sh-mode, (continued)
- Re: How to open a file in sh-mode, Francis Moreau, 2008/08/14
- Re: How to open a file in sh-mode, Peter Dyballa, 2008/08/14
- Re: How to open a file in sh-mode, Francis Moreau, 2008/08/14
- Re: How to open a file in sh-mode, Lennart Borgman (gmail), 2008/08/14
- Re: How to open a file in sh-mode, Francis Moreau, 2008/08/14
- Re: How to open a file in sh-mode, Lennart Borgman (gmail), 2008/08/14
- Re: How to open a file in sh-mode, Peter Dyballa, 2008/08/14
- Re: How to open a file in sh-mode, Francis Moreau, 2008/08/14
Re: How to open a file in sh-mode, Henrik Austad, 2008/08/14
- Re: How to open a file in sh-mode, Francis Moreau, 2008/08/14
- Re: How to open a file in sh-mode,
Henrik Austad <=
- Re: How to open a file in sh-mode, Francis Moreau, 2008/08/14
- Re: How to open a file in sh-mode, David Hansen, 2008/08/14
- Re: How to open a file in sh-mode, Henrik Austad, 2008/08/14
- Re: How to open a file in sh-mode, Francis Moreau, 2008/08/14
- Re: How to open a file in sh-mode, Lennart Borgman (gmail), 2008/08/14
Message not availableRe: How to open a file in sh-mode, Giorgos Keramidas, 2008/08/14
Re: How to open a file in sh-mode, Francis Moreau, 2008/08/14
Re: How to open a file in sh-mode, Giorgos Keramidas, 2008/08/14
Re: How to open a file in sh-mode, Francis Moreau, 2008/08/14
Re: How to open a file in sh-mode, Giorgos Keramidas, 2008/08/14