Copying/renaming current email file to something.eml

35 views
Skip to first unread message

Jack Baty

unread,
May 10, 2016, 11:39:08 AM5/10/16
to mu-discuss
My goal is to create an easy way to copy the message I'm viewing into DEVONthink as an .eml file and am trying to find the best approach.

DEVONthink (as well as Apple's Finder) handle .eml files nicely. Simply renaming an email in Maildir format to something.eml works fine. Now to figure out how to best do that. I suppose a mu4e "Action" would be best but I'm inexperienced with Lisp so haven't started down that path yet.

Ideally, I could assign a key while in either header or message view that would copy the current message to a pre-defined directory and name it something like [DATE]_[SUBJECT].eml

I've tried piping a message something like | >> ~/Desktop/foo.eml which works, but I end up in an empty buffer and I have to type the path and name the file manually. 

I've also considered flagging the messages I want copied then running something with `mu find` and xargs etc.

I suppose you'll tell me it's gotta be Lisp, and in that case I'll have to finally bite the bullet and learn how to do that :).

Thanks for any pointers.

Jack

Eduardo Mercovich

unread,
May 11, 2016, 4:08:10 PM5/11/16
to mu-di...@googlegroups.com
Hi Jack.

> My goal is to create an easy way to copy the message I'm viewing into
> DEVONthink as an .eml file and am trying to find the best approach.
> [...]

Sorry I can't help with that, I'm (still) not a lisp programmer.

However, since you're obsiously on Emacs, did you analyzed the
possibility to use Org-mode? AFAIK and not being a DEVONthink user, it
does (almost?) everything that DEVONthink does...

Best.


--
eduardo mercovich

Donde se cruzan tus talentos
con las necesidades del mundo,
ahí está tu vocación.

Dirk-Jan C. Binnema

unread,
May 14, 2016, 8:13:20 AM5/14/16
to mu-di...@googlegroups.com
Hi Jack,
Yeah, I think you'll need a little lisp... this should get you started:


--8<---------------cut here---------------start------------->8---
(defun djcb-mu4e-copy-message-at-point (&optional dir)
"Copy message at point to somewhere else as <date>_<subject>.eml."
(interactive)
(let* ((msg (mu4e-message-at-point))
(target (format "%s_%s.eml"
(format-time-string "%F" (mu4e-message-field msg :date))
(or (mu4e-message-field msg :subject) "No subject"))))
(copy-file
(mu4e-message-field msg :path)
(format "%s/%s" (or dir (read-directory-name "Copy message to: ")) target) 1)))
--8<---------------cut here---------------end--------------->8---

Kind regards,
Dirk.


--
Dirk-Jan C. Binnema Helsinki, Finland
e:dj...@djcbsoftware.nl w:www.djcbsoftware.nl
pgp: D09C E664 897D 7D39 5047 A178 E96A C7A1 017D DA3C

Jack Baty

unread,
May 14, 2016, 1:15:34 PM5/14/16
to mu-discuss
On Saturday, May 14, 2016 at 8:13:20 AM UTC-4, djcb wrote:
Hi Jack,


Yeah, I think you'll need a little lisp... this should get you started:


--8<---------------cut here---------------start------------->8---
(defun djcb-mu4e-copy-message-at-point (&optional dir)
  "Copy message at point to somewhere else as <date>_<subject>.eml."
  (interactive)
  (let* ((msg (mu4e-message-at-point))
          (target (format "%s_%s.eml"
                    (format-time-string "%F" (mu4e-message-field msg :date))
                    (or (mu4e-message-field msg :subject) "No subject"))))
    (copy-file
      (mu4e-message-field msg :path)
      (format "%s/%s" (or dir (read-directory-name "Copy message to: ")) target) 1)))
--8<---------------cut here---------------end--------------->8---



Well you sure made that look easy. Works wonderfully, thank you!

Jack 
Reply all
Reply to author
Forward
0 new messages