emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Eric S Fraga <e.fraga@ucl.ac.uk>
To: Richard Lawrence <richard.lawrence@berkeley.edu>
Cc: emacs-orgmode@gnu.org
Subject: Re: [OT] Importing plain text attachments into Org
Date: Mon, 24 Jan 2011 18:37:49 +0000	[thread overview]
Message-ID: <874o8yf8qq.fsf@ucl.ac.uk> (raw)
In-Reply-To: <87pqrnf8v9.fsf@berkeley.edu> (Richard Lawrence's message of "Sun, 23 Jan 2011 16:22:50 -0800")

Richard Lawrence <richard.lawrence@berkeley.edu> writes:

> Dear Orgsters,
>
> I'm hoping I can solicit a little advice about pulling email attachments
> into Org (via Gnus), since some of the folks on this list seem to have
> experience interacting with Gnus from Org.  I realize that the meat of
> my question may be better asked on the Gnus list, but if anyone here has
> knowledge and/or a similar setup that you'd be willing to share, I would
> very much appreciate hearing about it.
>
> The background: I am about to begin teaching a writing-intensive course.
> Students will email me their papers every week.  I have no desire to
> download, print, and read a bunch of .doc files by hand every week.
> (This is a pain, and requires proprietary software I don't have; and I
> find 12pt double-spaced Times New Roman much more difficult to read than
> a LaTeX article anyway.)  So I am considering asking my students to
> email their papers in plain text.  I would like to then apply some
> automated processing on my end that would:

A lot depends on what you use to read your emails.  Since you are using
gnus, I think some aspects of what you want to do are possible.  You may
need to upgrade to no-gnus (the development version of gnus which goes
under various names...).

> 1) Download each student's paper into a file in my "teaching"
> directory.

I would avoid downloading the papers.  Simply use org-capture to create
a task for each paper you need to read that links automatically to the
gnus email.  Store a link first (org-store-link) when in the email and
then capture a task (org-capture) in which you insert the link
(org-insert-link).  You may wish to create a custom template and it may
be possible to extract the From and Subject fields from the link
information automatically (see messages in this list from a few weeks
ago, I believe -- I'm offline at the moment unfortunately).

> 2) Apply some *very* simple transformations, like adding #+TITLE before
> their title, replacing Windows `smart quote' characters with ASCII ` and
> ', and generally making the files play nice with Org on a GNU box.  I
> might also like to do things like run a word count at this stage to make
> sure they are within the guidelines for the course.

Assuming you follow my suggestion for 1) above, you can read the
document in the email with appropriate transformations (by "washing" the
email in gnus parlance; e.g. function gnus-article-fill-long-lines and
variable gnus-treat-strip-cr, amongst others).  You can display MS Word
documents inline in the message using mm-decode functions.  I have the
following set:

#+begin_src emacs-lisp
;; --- for MS Word files
(add-to-list 'mm-attachment-override-types "application/msword")
(add-to-list 'mm-attachment-override-types "application/vnd.openxmlformats-officedocument.wordprocessingml.document")
(add-to-list 'mm-automatic-display "application/msword")
(add-to-list 'mm-inline-media-tests '("application/msword" mm-inline-text identity))
(add-to-list 'mm-automatic-display "application/vnd.openxmlformats-officedocument.wordprocessingml.document")
(add-to-list 'mm-inline-media-tests '("application/vnd.openxmlformats-officedocument.wordprocessingml.document" mm-inline-text identity))
#+end_src

I don't pretend to understand some of this incantation, mind you...  in
any case, some of this will depend on your ~/.mailcap (or /etc/mailcap)
entries.  I have:

--8<---------------cut here---------------start------------->8---
application/msword; antiword -w 0 %s; copiousoutput
application/vnd.openxmlformats-officedocument.wordprocessingml.document; /home/ucecesf/s/bin/docx2txt.pl %s -; copiousoutput
--8<---------------cut here---------------end--------------->8---

where docx2txt.pl is a perl script I found on the web somewhere (I can
send it to you if you wish) that handles the latest MS Word format.

> 3) Use Org's export abilities to compile each paper into a PDF (or
> perhaps a single PDF for the whole week's submissions).
>
> 4) [Not necessary, but would be cool:] Automatically insert TODO items
> into my agenda for each paper I have to read; automatically grade
> students who don't turn in papers on time; etc.

You can tag your capture tasks created above appropriately and then use,
for instance, properties to enter marks which you can subsequently
collate (I believe -- I don't know how to do this but I believe it is
possible).

> Does anyone have any ideas about how I might go about this, and whether
> it's worth the effort to automate it?  (I will have about 100 papers to
> read this semester.)  

Enjoy!  ;-)
-- 
: Eric S Fraga (GnuPG: 0xC89193D8FFFCF67D) in Emacs 24.0.50.1
: using Org-mode version 7.4 (release_7.4.232.g8d003)

  parent reply	other threads:[~2011-01-24 19:39 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-24  0:22 [OT] Importing plain text attachments into Org Richard Lawrence
2011-01-24 10:15 ` Jeff Horn
2011-01-24 18:37 ` Eric S Fraga [this message]
  -- strict thread matches above, loose matches on Subject: below --
2011-01-24  8:59 Rustom Mody

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

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=874o8yf8qq.fsf@ucl.ac.uk \
    --to=e.fraga@ucl.ac.uk \
    --cc=emacs-orgmode@gnu.org \
    --cc=richard.lawrence@berkeley.edu \
    /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 public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).