<<< Date Index >>>     <<< Thread Index >>>

Re: set editor, switching from vim to emacs



Hi,

At  3:20 PM PST on November 17 Konstantin Kletschke sent off:
> I am investigating emacs as an replacement vor vim in general. Somehow
> vim goes on my nerves, it is generally excellent software, but
> sometimes I am trying new things out, and emacs _is_ a new thing :)
> 
> I had
> set editor="/usr/bin/vim +':set textwidth=72' +':set wrap' +\`awk
> '/^$/ {print i+2; exit} {i++}' %s\` %s"
> in my muttrc, and I admit, I do not understand the ''` and awk and
> print things. I thought I could replace it with
> set editor = "emacs -nw %s"
> or
> set editor = "emacsclient +%s"
> but I don't get it to jump under the headers to immediately
> start typing message (edit_headers on)...
> 
> So, where is the missing link?

The syntax is (from the info file):

emacsclient {[+LINE[COLUMN]] FILENAME}

where FILENAME is what mutt substitutes %s with.

I'm guessing your number of header lines does not change very much, so you
could approximate what you want with something like

emacs -nw  +8 %s

or be more exact and use (untested, stolen from above)

emacsclient +`awk '/^$/ {print i+2; exit} {i++}' %s` %s

which means

emacsclient +x %s

where x is the result of the command in backquotes.  It counts lines in %s
until it reaches the first blank line (i.e. end of header) and returns the
count + 2.  (skips the attribution, I guess.)  Yes, the exit condition comes
first.  Awk's like that, except when it's not.

> I would appreciate if somebody is there pointing me into right
> direction...

Oh!  Well then you want post mode, which does the above and more for you:

http://astro.utoronto.ca/~reid/mutt/