Message mode for both mu and mutt

163 views
Skip to first unread message

Thomas Kahle

unread,
Nov 4, 2012, 12:36:40 PM11/4/12
to mu-di...@googlegroups.com
Hi,

I'm trying a soft migration from mutt to mu4e and for some time I'd like
to use both. Here's a problem: I use message mode for writing emails
from mutt and for that I put the variable 'mail-header-separator' to an
empty string. For sending from within emacs I need an actual separator
there. It seems that mutt and emacs sending require mutually exclusive
configuration? Has anybody solved this?

Thanks,
Thomas

--
Thomas Kahle
http://dev.gentoo.org/~tomka/
signature.asc

Mandar Mitra

unread,
Nov 5, 2012, 9:38:57 AM11/5/12
to mu-di...@googlegroups.com
Thomas Kahle wrote (Sun, Nov 04, 2012 at 09:36:40AM -0800):

> I'm trying a soft migration from mutt to mu4e and for some time I'd like
> to use both.

That's exactly what I'm trying to do. Will you write / blog about this,
please?


> Here's a problem: I use message mode for writing emails
> from mutt and for that I put the variable 'mail-header-separator' to an
> empty string. For sending from within emacs I need an actual separator
> there. It seems that mutt and emacs sending require mutually exclusive
> configuration? Has anybody solved this?

What exactly do you mean by "sending from within emacs"?

I used to use post mode, but have recently switched to message mode
because of tab completion of addresses, and the ability to attach files
while writing the message using C-c C-a. When I do this, I use C-c C-c
to send, and the message goes out fine[*]. Maybe I've misunderstood your
question?

[*] I haven't yet figured out how to automatically tell mutt to forget
about the message buffer if I've bypassed mutt while sending.

mandar.

Thomas Kahle

unread,
Nov 5, 2012, 12:38:40 PM11/5/12
to mu-di...@googlegroups.com
On 20:08 Mon 05 Nov 2012, Mandar Mitra wrote:
> Thomas Kahle wrote (Sun, Nov 04, 2012 at 09:36:40AM -0800):
>
> > I'm trying a soft migration from mutt to mu4e and for some time I'd like
> > to use both.
>
> That's exactly what I'm trying to do. Will you write / blog about this,
> please?

Maybe, let's see. Currently I'm trying to figure out how to link mu to
org-mode in a smoother way than this (which is what I do now):
http://upsilon.cc/~zack/blog/posts/2010/02/integrating_Mutt_with_Org-mode/

... and also how to have several identities.

> > Here's a problem: I use message mode for writing emails
> > from mutt and for that I put the variable 'mail-header-separator' to an
> > empty string. For sending from within emacs I need an actual separator
> > there. It seems that mutt and emacs sending require mutually exclusive
> > configuration? Has anybody solved this?
>
> What exactly do you mean by "sending from within emacs"?

I use 'emacsclient' as an editor for mutt. Then I had this snippet

(add-to-list 'auto-mode-alist '(".*mutt.*" . message-mode))
(setq mail-header-separator "")

in my .emacs to enable message mode for mail composition. The second
line is problematic since the orgiginal functionality of message mode
will fail (since it cannot say where the header stops). Note that I use
emacsclient only for editing, I'm not sending through emacs, but through
mutt (and then msmtp).

> I used to use post mode, but have recently switched to message mode
> because of tab completion of addresses, and the ability to attach files
> while writing the message using C-c C-a. When I do this, I use C-c C-c
> to send, and the message goes out fine[*]. Maybe I've misunderstood your
> question?

This all does not apply since I do those things in mutt.

Anyway, my original question is moot since setting the header separator
to nothing is not needed in my current setup. It was probably a fix for
a problem that I had a couple of years ago...

Cheers,
signature.asc

Stephen Eglen

unread,
Nov 5, 2012, 4:37:16 PM11/5/12
to mu-di...@googlegroups.com

I use 'emacsclient' as an editor for mutt.  Then I had this snippet

(add-to-list 'auto-mode-alist '(".*mutt.*" . message-mode))
(setq mail-header-separator "")

 

How about the following if you want mutt buffers to be slightly different?


(define-derived-mode mutt-message-mode message-mode "Mutt Message"
  "Major mode for editing Mutt messages."
  (setq mail-header-separator ""))


(add-to-list 'auto-mode-alist '(".*mutt.*" . mutt-message-mode))


Stephen Eglen

unread,
Nov 5, 2012, 4:43:09 PM11/5/12
to mu-di...@googlegroups.com

oops, don't try that.  I think this version instead is needed...



(define-derived-mode mutt-message-mode message-mode "Mutt Message"
  "Major mode for editing Mutt messages."
  (set (make-local-variable 'mail-header-separator) ""))


 

Mandar Mitra

unread,
Nov 6, 2012, 7:57:52 AM11/6/12
to mu-di...@googlegroups.com
Thomas Kahle wrote (Mon, Nov 05, 2012 at 09:38:40AM -0800):
> in my .emacs to enable message mode for mail composition. The second
> line is problematic since the orgiginal functionality of message mode
> will fail (since it cannot say where the header stops). Note that I use
> emacsclient only for editing, I'm not sending through emacs, but through
> mutt (and then msmtp).

I have the same default sending method (mutt + msmtp) and
'(mail-header-separator "") works for me in message mode. Perhaps
it really looks for a line that consists only of mail-header-separator
(in this case, an empty line)?


> > I used to use post mode, but have recently switched to message mode
> > because of tab completion of addresses, and the ability to attach files
> > while writing the message using C-c C-a. When I do this, I use C-c C-c
> > to send, and the message goes out fine[*]. Maybe I've misunderstood your
> > question?
>
> This all does not apply since I do those things in mutt.

Just curious: do you add all attachments after you're done editing the
message? Or do you quit the editor in the middle, add the attachment,
and then finish the message?

mandar.

Joost Kremers

unread,
Nov 6, 2012, 8:04:06 AM11/6/12
to mu-di...@googlegroups.com
On Tue, Nov 06 2012, Mandar Mitra <mandar...@gmail.com> wrote:
> Just curious: do you add all attachments after you're done editing the
> message? Or do you quit the editor in the middle, add the attachment,
> and then finish the message?

I used mutt + post-mode for quite a while and could add attachments
while editing with C-c C-a. post-mode adds a pseudo-header to the
message that mutt then uses to attach the file.

It could be that this requires edit_headers to be set in .muttrc, don't
remember exactly.


--
Joost Kremers
Life has its moments

Thomas Kahle

unread,
Nov 6, 2012, 12:06:49 PM11/6/12
to mu-di...@googlegroups.com
Hi,

On 18:27 Tue 06 Nov 2012, Mandar Mitra wrote:
> I have the same default sending method (mutt + msmtp) and
> '(mail-header-separator "") works for me in message mode. Perhaps
> it really looks for a line that consists only of mail-header-separator
> (in this case, an empty line)?

Independent of mutt. If you start to compose a message in emacs
message-mode and your mail-header-separator is set to '', can you send
that message (from emacs)?

> > > I used to use post mode, but have recently switched to message mode
> > > because of tab completion of addresses, and the ability to attach files
> > > while writing the message using C-c C-a. When I do this, I use C-c C-c
> > > to send, and the message goes out fine[*]. Maybe I've misunderstood your
> > > question?
> >
> > This all does not apply since I do those things in mutt.
>
> Just curious: do you add all attachments after you're done editing the
> message? Or do you quit the editor in the middle, add the attachment,
> and then finish the message?

Both,

On 14:04 Tue 06 Nov 2012, Joost Kremers wrote:
> On Tue, Nov 06 2012, Mandar Mitra <mandar...@gmail.com> wrote:
> > Just curious: do you add all attachments after you're done editing the
> > message? Or do you quit the editor in the middle, add the attachment,
> > and then finish the message?
>
> I used mutt + post-mode for quite a while and could add attachments
> while editing with C-c C-a. post-mode adds a pseudo-header to the
> message that mutt then uses to attach the file.

Oh great. I did not know that. I am so used to the typo correction in
zsh and anything.el that I find 'just TAB completion' (like when you
select attachments in mutt) pretty bothersome.
signature.asc

Mandar Mitra

unread,
Nov 7, 2012, 12:03:27 PM11/7/12
to mu-di...@googlegroups.com
Thomas Kahle wrote (Tue, Nov 06, 2012 at 09:06:49AM -0800):
> Independent of mutt. If you start to compose a message in emacs
> message-mode and your mail-header-separator is set to '', can you send
> that message (from emacs)?

Yes, I just tried this and it worked.

Summary: with mail-header-separator set to "", I can send through emacs or
mutt without problems.


> On 14:04 Tue 06 Nov 2012, Joost Kremers wrote:
> > I used mutt + post-mode for quite a while and could add attachments
> > while editing with C-c C-a. post-mode adds a pseudo-header to the
> > message that mutt then uses to attach the file.

Thanks for the tip! I didn't know C-c C-a also works in post-mode. This
solves the problem I'd mentioned earlier. I continue to use message-mode,
but I've now bound C-c C-a to post-attach-file instead of mml-attach-file
(the default in message mode). Because mutt understands the headers added
by post-mode, I can use my usual method of sending (quit the emacsclient
session and send through mutt). I no longer need to bypass mutt by using
C-c C-c (message-send-and-exit).

mandar.

ps: post-attach-file causes problems with files that have spaces in their
names. The following (temporary?) fix solves this problem for me:

@@ -946,7 +946,7 @@
(interactive)
(let ((file (read-file-name "Attach file: " nil nil t nil))
(description (string-read "Description: ")))
- (header-attach-file file description)))
+ (header-attach-file (replace-regexp-in-string " " "\\\\ " file)
description)))

;;; Non-interactive functions

Joost Kremers

unread,
Nov 7, 2012, 2:18:03 PM11/7/12
to mu-di...@googlegroups.com
On Wed, Nov 07 2012, Mandar Mitra <mandar...@gmail.com> wrote:
> ps: post-attach-file causes problems with files that have spaces in their
> names.

Yes, I remember running into the same problem. And fixing it in the same
way. :-)
Reply all
Reply to author
Forward
0 new messages