From: Eric Abrahamsen <eric@ericabrahamsen.net>
To: emacs-orgmode@gnu.org
Subject: Re: email ui choices?
Date: Wed, 15 Jul 2015 09:46:17 +0800 [thread overview]
Message-ID: <87h9p6ur9y.fsf@ericabrahamsen.net> (raw)
In-Reply-To: CAN_Dec9jp=Nfa3VOPxUUnDPDAoxM8Fi5=9Jy2vauV0s0Wvv3bw@mail.gmail.com
Matt Price <moptop99@gmail.com> writes:
> On Tue, Jul 14, 2015 at 7:27 AM, Eric Abrahamsen <eric@ericabrahamsen.net> wrote:
>
>
> Matt Price <moptop99@gmail.com> writes:
>
> > On Tue, Jul 14, 2015 at 6:51 AM, Eric Abrahamsen <eric@ericabrahamsen.net> wrote:
>
> [...]
>
> I'll include a shameless-plug-cum-general-recommendation: I use
> org-attach a lot to keep files associated with Org headings, and to me
> this feels like a natural use-case for that.
>
>
> Yes, it sounds like a pretty good idea. I am trying to figure out a couple of attachment issues; to start with, I was hoping to set a dnd-handler, anmd have drag-and-dropping local files create an
> attachment. I am close, but the actual attachment isn't being created. This is what I have:
>
> (setq dnd-protocol-alist
> `(("^\\(file\\)://" . mwp-file-dnd) ,@dnd-protocol-alist))
>
> (defun mwp-file-dnd (uri action)
> (cond ((eq major-mode 'org-mode)
> ;; (message uri)
> (insert "[[%s][Description Property")
> (org-attach-attach uri nil "lns" ) ;; this appears to work, but doesn't create the link
> )
> (t
> (let ((dnd-protocol-alist
> (rassq-delete-all
> 'mwp-file-dnd
> (copy-alist dnd-protocol-alist))))
> (dnd-handle-one-url nil action uri)))
> ))
Unfortunately I've never used drag-and-drop anything, so won't really be
able to help there.
[...]
> It sounds like you're digesting quite a bit all at once, so you probably
> don't want to install all of Gnorb. If you're interested in some of the
> bits, I might be able to peel those off into separate functions:
> specifically, taking files from the org-attach directory and attaching
> them to outgoing emails being sent from an Org heading. I can't promise
> I could do it cleanly, but I'd be happy to look into it.
>
>
> If you could do that, that would be just super. Right now my lone mailing function sends me to message-mode:
>
> (defun mime-send-mail ()
> "org-mime-subtree and HTMLize"
> (interactive)
> (org-mark-subtree)
> (let ((subject (nth 4 (org-heading-components))))
> (org-mime-subtree)
> (insert "\nBest,\nMP.\n")
> (org-mime-htmlize)
> (command-execute 'mml-attach-file)
> (message-goto-to)
> )
> )
>
> mml-attach-file asks a whole bunch of questions about mime type, etc. I don't know how to fill those values in automatically, but I guess it would be, in pseudo code
>
> (dolist (thisfile org-attach-all-attachments) (mml-attach-file thisfile FILL IN OTHER ARGUMENTS)
>
> If you have something like that in gnorb that'd be awesome. Thanks once again,
I've extracted some code that ought to be useful.
(defun org-attachment-list (&optional id)
"Get a list of files (absolute filenames) attached to the
current heading, or the heading indicated by optional argument ID."
(when (featurep 'org-attach)
(let* ((attach-dir
(save-excursion
(when id
(org-id-goto id))
(org-attach-dir t)))
(files
(mapcar
(lambda (f)
(expand-file-name f attach-dir))
(org-attach-file-list attach-dir))))
files)))
(defun query-attach-files (files)
(map-y-or-n-p
(lambda (a) (format "Attach %s to outgoing message? "
(file-name-nondirectory a)))
(lambda (a)
(mml-attach-file a (mm-default-file-encoding a)
nil "attachment"))
files
'("file" "files" "attach")))
Then your entry point function could use those functions:
(defun mime-send-mail ()
"org-mime-subtree and HTMLize"
(interactive)
(org-mark-subtree)
(let ((subject (nth 4 (org-heading-components)))
(files (org-attachment-list)))
(org-mime-subtree)
(insert "\nBest,\nMP.\n")
(org-mime-htmlize)
(query-attach-files files)
(message-goto-to)))
See how that works for now -- there will be plenty of adjustments you
might want to make.
One thing that occurred to me is, because `org-mime-subtree' uses the
export process, you can use property substitution in the body of the
subtree/email. So if you have a property like "GRADE" or something, you
can insert that into the body at export time using
{{{property(GRADE)}}}. You didn't really ask for that, but I'll bet it
might come in handy.
Eric
next prev parent reply other threads:[~2015-07-15 1:46 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-14 0:16 email ui choices? Matt Price
2015-07-14 8:48 ` Juergen Christoffel
2015-07-14 10:51 ` Eric Abrahamsen
2015-07-14 11:10 ` Matt Price
2015-07-14 11:27 ` Eric Abrahamsen
2015-07-14 20:51 ` Matt Price
2015-07-15 1:46 ` Eric Abrahamsen [this message]
2015-07-14 22:29 ` Juergen Christoffel
2015-07-14 23:22 ` Matt Price
2015-07-14 11:35 ` Rasmus
2015-07-14 11:41 ` Eric Abrahamsen
2015-07-14 12:01 ` Rasmus
2015-07-14 14:47 ` Jorge A. Alfaro-Murillo
2015-07-15 1:14 ` Eric Abrahamsen
2015-07-15 8:56 ` Rasmus
2015-07-15 9:27 ` Eric Abrahamsen
2015-07-15 9:37 ` Rasmus
2015-07-16 3:27 ` Eric Abrahamsen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87h9p6ur9y.fsf@ericabrahamsen.net \
--to=eric@ericabrahamsen.net \
--cc=emacs-orgmode@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.