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

Re: set editor, switching from vim to emacs



On Mon, Nov 17 2003 at 10:46:33PM BRST, Rob Reid <kepler@xxxxxxx> wrote:

> > 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 :)

        At least, it is The Good 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

        Actually, you didn't need the awk to get past the header, you could
have used "...vi ... '+/^$'%s" or something like that.

        Anyway...

> > 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)...

(...)

> emacsclient {[+LINE[COLUMN]] FILENAME}

(...)

> emacs -nw  +8 %s
> 
> or be more exact and use (untested, stolen from above)
> 
> emacsclient +`awk '/^$/ {print i+2; exit} {i++}' %s` %s

        A much cleaner way would be to define (say, in you ~/.emacs ou
~/.xemacs/init.el) a function along the lines of

(defun goto-first-empty-line ()
  "Move cursor to first empty line"
  (interactive)
  (while (progn
           (forward-line 1)
           (not (looking-at "^$")))))

        or, if you want to go *past* the first line,

(defun goto-past-first-empty-line ()
  "Move cursor past the first empty line"
  (interactive)
  (while (progn
           (forward-line 1)
           (not (looking-at "^$"))))
  (next-line 1)) ; <-- change to however many line you want to move forward

        and create a new editing mode, based on the one you'd usually use
(say, text-mode):

(defun my-mutt-mode ()
  "Customized mutt mode"
  (interactive)
  (text-mode)
  (goto-past-first-empty-line))

        And, finally, tell emacs to use this mode to edit mutt files:

(setq auto-mode-alist (cons '("/tmp/mutt*" . my-mutt-mode)
                            auto-mode-alist))

        There. That should do it. It's apparently a lot more work, but it's
much more elegant :)

        Besides, it gives you flexibility to do a lot more than just moving
to the correct line.

        Ah, yes: I haven't tested much of this (I don't edit headers, so I
use "plain" text-mode), be careful and let me know if it works :)

        BTW, in muttrc you put only

set editor="/usr/bin/emacsclient %s"

        And, if you're still taking suggestions, I moved from FSF Emacs to
XEmacs mainly because FSF Emacs + emacsclient makes you move to the original
emacs window to edit the file, then back to mutt to carry on, while XEmacs +
gnuclient edits the file in place (that is, same window as mutt).



                rbp
-- 
 Rodrigo Bernardo Pimentel                         <rbp@xxxxxxxxxxxx>
 http://isnomore.net                          GPG KeyId: <0x0DB14978>

El Hombre de los Moleculos!