From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eric Abrahamsen Subject: Re: email ui choices? Date: Wed, 15 Jul 2015 09:46:17 +0800 Message-ID: <87h9p6ur9y.fsf@ericabrahamsen.net> References: <20150714084809.GB11584@unser.net> <87lhejvwox.fsf@ericabrahamsen.net> <874ml7vv0j.fsf@ericabrahamsen.net> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:36717) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZFBmU-0006vF-7p for emacs-orgmode@gnu.org; Tue, 14 Jul 2015 21:46:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZFBmP-0002wQ-6V for emacs-orgmode@gnu.org; Tue, 14 Jul 2015 21:46:42 -0400 Received: from plane.gmane.org ([80.91.229.3]:57716) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZFBmO-0002w7-WD for emacs-orgmode@gnu.org; Tue, 14 Jul 2015 21:46:37 -0400 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1ZFBmM-0006U6-Mz for emacs-orgmode@gnu.org; Wed, 15 Jul 2015 03:46:35 +0200 Received: from 222.128.167.57 ([222.128.167.57]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 15 Jul 2015 03:46:34 +0200 Received: from eric by 222.128.167.57 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 15 Jul 2015 03:46:34 +0200 List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org Matt Price writes: > On Tue, Jul 14, 2015 at 7:27 AM, Eric Abrahamsen wrote: > > > Matt Price writes: > > > On Tue, Jul 14, 2015 at 6:51 AM, Eric Abrahamsen 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