From mboxrd@z Thu Jan 1 00:00:00 1970 From: Anthony Lander Subject: Re: Add TODO from external app? Date: Tue, 1 Apr 2014 13:08:45 -0400 Message-ID: References: Mime-Version: 1.0 Content-Type: multipart/mixed; boundary=047d7bf1987ef044fb04f5fe3a6e Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:38845) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WV2Bo-0006a7-Pd for emacs-orgmode@gnu.org; Tue, 01 Apr 2014 13:09:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WV2Bk-00073I-Cz for emacs-orgmode@gnu.org; Tue, 01 Apr 2014 13:09:32 -0400 Received: from mail-wg0-x22d.google.com ([2a00:1450:400c:c00::22d]:33366) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WV2Bj-000735-Vw for emacs-orgmode@gnu.org; Tue, 01 Apr 2014 13:09:28 -0400 Received: by mail-wg0-f45.google.com with SMTP id l18so7946774wgh.16 for ; Tue, 01 Apr 2014 10:09:26 -0700 (PDT) In-Reply-To: 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: Lawrence Bottorff , Carsten Dominik Cc: "emacs-orgmode@gnu.org Mode" --047d7bf1987ef044fb04f5fe3a6e Content-Type: multipart/alternative; boundary=047d7bf1987ef044f704f5fe3a6c --047d7bf1987ef044f704f5fe3a6c Content-Type: text/plain; charset=ISO-8859-1 Hi Lawrence, Here is a Python script I use to scrape TODOs from emails. I haven't polished it up and put it on github yet, but you are welcome to give it a whirl (anyone else is too, obviously). You need python 2.5 or greater to run this. Configure by modifying the variables at the top of the file. Carsten: If you think this is a worthwhile addition to contrib, I am happy to clean it up, and write a bit of documentation for inclusion with org mode. Hope this helps, -Anthony On Tue, Apr 1, 2014 at 11:41 AM, Lawrence Bottorff wrote: > I've seen various things for interacting with org mode from external apps. > I found org-protocol, as well as a Mutt-to-org mode article. Per the > tittle, I want to be able to add new TODO items from, say, an email or a > PHP-based web page form. Is this just brute force external file > manipulation, i.e., e.g., my PHP code would simply open a .org file and > concatenate a properly formatted TODO line . . . or are there more > sophisticated ways of talking to emacs/org-mode from without? > > LB > --047d7bf1987ef044f704f5fe3a6c Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
Hi Lawrence,

Here is a Python script I = use to scrape TODOs from emails. I haven't polished it up and put it on= github yet, but you are welcome to give it a whirl (anyone else is too, ob= viously). You need python 2.5 or greater to run this. Configure by modifyin= g the variables at the top of the file.=A0

Carsten: If you think this is a worthwhile addition to = contrib, =A0I am happy to clean it up, and write a bit of documentation for= inclusion with org mode.

Hope this helps,

=A0 -Anthony



On Tue, Apr 1, 2014 at 11:41 = AM, Lawrence Bottorff <borgauf@gmail.com> wrote:
I've seen various thing= s for interacting with org mode from external apps. I found org-protocol, a= s well as a Mutt-to-org mode article. Per the tittle, I want to be able to = add new TODO items from, say, an email or a PHP-based web page form. Is thi= s just brute force external file manipulation, i.e., e.g., my PHP code woul= d simply open a .org file and concatenate a properly formatted TODO line . = . . or are there more sophisticated ways of talking to emacs/org-mode from = without?

LB

--047d7bf1987ef044f704f5fe3a6c-- --047d7bf1987ef044fb04f5fe3a6e Content-Type: text/x-python-script; charset=US-ASCII; name="todo-email-scraper.py" Content-Disposition: attachment; filename="todo-email-scraper.py" Content-Transfer-Encoding: base64 X-Attachment-Id: f_hthfv22k0 IyEvdXNyL2Jpbi9lbnYgcHl0aG9uCgojICB0b2RvLWVtYWlsLXNjcmFwZXIucHkgLSBXYXRjaCBh biBlbWFpbCBhZGRyZXNzIGZvciBUT0RPcyBhbmQgYWRkIHRoZW0gdG8gYW4gb3JnIGZpbGUKIwoj IENvcHlyaWdodCAoYykgMjAxNCBGcmVlIFNvZnR3YXJlIEZvd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gICBmaWxl ID0gU3RyaW5nSU8uU3RyaW5nSU8oZGF0YVswXVsxXSkKICAgICAgICBtZXNzYWdlID0gUGFyc2Vy KCkucGFyc2UoZmlsZSkKICAgICAgICB0b2RvX3N1YmplY3QgPSBtZXNzYWdlWydzdWJqZWN0J10K IyAgICAgICAgcHJpbnQgbWVzc2FnZVsnU3ViamVjdCddICsgIlxuIgoKICAgICAgICBib2R5ID0g IiIKICAgICAgICBmb3IgcGFydCBpbiBtZXNzYWdlLndhbGsoKToKICAgICAgICAgICAgdCA9IHBh cnQuZ2V0X2NvbnRlbnRfdHlwZSgpCiAgICAgICAgICAgIGlmIHQgYW5kIHQubG93ZXIoKSA9PSAi dGV4dC9wbGFpbiI6CiAgICAgICAgICAgICAgICAjIEZvdW5kIHRoZSBmaXJzdCB0ZXh0L3BsYWlu IHBhcnQgCiAgICAgICAgICAgICAgICBib2R5ID0gcGFydC5nZXRfcGF5bG9hZChkZWNvZGU9VHJ1 ZSkKICAgICAgICAgICAgICAgIGJyZWFrCiAgICAgICAgCiAjICAgICAgIHByaW50ICI+IiwgYm9k eSwgIjwiCiAgICAgICAgbG9uZ19saW5lID0gIiIKICAgICAgICBmb3IgbGluZSBpbiBbbGluZS5z dHJpcCgpIGZvciBsaW5lIGluIGJvZHkuc3BsaXRsaW5lcygpIGlmIGxlbihsaW5lKSA+IDBdOgog ICAgICAgICAgICBpZiBsaW5lWy0xOl0gPT0gIj0iOgogICAgICAgICAgICAgICAgbG9uZ19saW5l ICs9IGxpbmVbOi0xXQogICAgICAgICAgICBlbHNlOgogICAgICAgICAgICAgICAgaWYgbGVuKGxv bmdfbGluZSkgPiAwOiAgIyBUaGVyZSBpcyBhIGxvbmcgbGluZSB3YWl0aW5nIHRvIGJlIHdyaXR0 ZW4KIyAgICAgICAgICAgICAgICAgICAgcHJpbnQgImxvbmcgbGluZTogIiwgbG9uZ19saW5lCiAg ICAgICAgICAgICAgICAgICAgdG9kb19ib2R5LmFwcGVuZChsb25nX2xpbmUpCiAgICAgICAgICAg ICAgICAgICAgbG9uZ19saW5lID0gIiIKICAgICAgICAgICAgICAgIGVsc2U6CiMgICAgICAgICAg ICAgICAgICAgIHByaW50ICJsaW5lOiAiLCBsaW5lCiAgICAgICAgICAgICAgICAgICAgdG9kb19i b2R5LmFwcGVuZChsaW5lKQogICAgICAgICAgICAgICAgICAgIGxvbmdfbGluZSA9ICIiCiAgICAg ICAgICAgICAgICAKICAgICAgICBpZiBsZW4obG9uZ19saW5lKSA+IDA6CiMgICAgICAgICAgICBw cmludCAibG9uZyBsaW5lIChmaW5hbCk6ICIsIGxvbmdfbGluZQogICAgICAgICAgICB0b2RvX2Jv ZHkuYXBwZW5kKGxvbmdfbGluZSkKICAgICAgICB0b2Rvcy5hcHBlbmQoeydzdWJqZWN0JyA6IHRv ZG9fc3ViamVjdCwgJ2JvZHknIDogdG9kb19ib2R5fSkKICAgICAgICAgICAgICAgIAogICAgaW1h cC5jbG9zZSgpCiAgICBpbWFwLmxvZ291dCgpCiAgICByZXR1cm4gdG9kb3MKICAgIAogICAgCmRl ZiBuZXdfZGlhcnlfbGluZXNfd2l0aF90b2Rvcyh0b2Rvcyk6CiAgICB0cnk6CiAgICAgICAgZmls ZSA9IG9wZW4oZGlhcnlfZmlsZSwgInJ0KyIpCiAgICAgICAgZm91bmQgPSBGYWxzZQogICAgICAg IGRvbmUgPSBGYWxzZQogICAgICAgIHN0YXJzID0gIiIKICAgICAgICB0aW1lc3RhbXAgPSBkYXRl dGltZS5ub3coKS5zdHJmdGltZSgiWyVZLSVtLSVkICVhICVIOiVNXSIpCiAgICAgICAgbG9nX2xp bmVzID0gWyI6TE9HQk9PSzoiLCAnLSBTdGF0ZSAiVE9ETyIgICAgICAgZnJvbSAiIiAgICAgICAg ICAgJyArIHRpbWVzdGFtcCwgIjpFTkQ6Il0KICAgICAgICAKICAgICAgICBsaW5lcyA9IFtdCiAg ICAgICAgd2hpbGUgbm90IGRvbmU6CiAgICAgICAgICAgIGxpbmUgPSBmaWxlLnJlYWRsaW5lKCkK ICAgICAgICAgICAgaWYgbGVuKGxpbmUpID09IDA6CiAgICAgICAgICAgICAgICBkb25lID0gVHJ1 ZQogICAgICAgICAgICBlbHNlOgogICAgICAgICAgICAgICAgbGluZXMuYXBwZW5kKGxpbmUpCgog ICAgICAgICAgICAgICAgaWYgbm90IGZvdW5kOgogICAgICAgICAgICAgICAgICAgIGlmIGxpbmVb MF0gPT0gIioiOgogICAgICAgICAgICAgICAgICAgICAgICBzdGFycyA9IGxpbmUuc3BsaXQoKVsw XQoKICAgICAgICAgICAgICAgICAgICBpZiBsaW5lLnN0cmlwKCkgPT0gIjpUT0RPLVRBUkdFVDog dHJ1ZSI6CiAgICAgICAgICAgICAgICAgICAgICAgIGZvdW5kID0gVHJ1ZQoKICAgICAgICAgICAg ICAgICAgICAgICAgbGluZSA9ICIiCiAgICAgICAgICAgICAgICAgICAgICAgIHdoaWxlIG5vdCBs aW5lLnN0cmlwKCkgPT0gIjpFTkQ6IjoKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxpbmUg PSBmaWxlLnJlYWRsaW5lKCkKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxpbmVzLmFwcGVu ZChsaW5lKQoKICAgICAgICAgICAgICAgICAgICAgICAgZm9yIHRvZG8gaW4gdG9kb3M6CiAgICAg ICAgICAgICAgICAgICAgICAgICAgICBsaW5lID0gIiVzJXMlcyVzIiAlIChzdGFycywgIioqIFRP RE8gIiwgdG9kb1snc3ViamVjdCddLCAiXG4iKQogICAgICAgICAgICAgICAgICAgICAgICAgICAg bGluZXMuYXBwZW5kKGxpbmUpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzcGFjZXMgPSBy ZXBsYWNlKHN0YXJzICsgIioqICIsICIqIiwgIiAiKQogICAgICAgICAgICAgICAgICAgICAgICAg ICAgZm9yIGxpbmUgaW4gbG9nX2xpbmVzOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg IGxpbmVzLmFwcGVuZChzcGFjZXMgKyBsaW5lICsgIlxuIikKCiAgICAgICAgICAgICAgICAgICAg ICAgICAgICBmb3IgbGluZSBpbiB0b2RvWydib2R5J106CiAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgbGluZXMuYXBwZW5kKHNwYWNlcyArIGxpbmUgKyAiXG4iKQogICAgICAgIGZpbGUu Y2xvc2UoKQogICAgZXhjZXB0OgogICAgICAgIHByaW50ICJVbmV4cGVjdGVkIGVycm9yOiIsIHN5 cy5leGNfaW5mbygpWzBdCiAgICAgICAgZmlsZS5jbG9zZSgpCiAgICAgICAgcmFpc2UKICAgIHJl dHVybiBsaW5lcwoKCmRlZiB3cml0ZV90b2RvX2ZpbGUoZmlsZW5hbWUsIHRvZG9zKToKICAgIHRy eToKICAgICAgICBmaWxlID0gb3BlbihmaWxlbmFtZSwgInciKQogICAgICAgIGZvciB0b2RvIGlu IHRvZG9zOgogICAgICAgICAgICBmaWxlLndyaXRlKHRvZG8pCiAgICAgICAgZmlsZS5jbG9zZSgp CiAgICAgICAgcmV0dXJuIFRydWUKICAgIGV4Y2VwdDoKICAgICAgICBwcmludCAiVW5leHBlY3Rl ZCBlcnJvcjoiLCBzeXMuZXhjX2luZm8oKVswXQogICAgICAgIGZpbGUuY2xvc2UoKQogICAgICAg IHJhaXNlCgogICAgcmV0dXJuIEZhbHNlCgpkZWYgc2NyYXBlX3RvZG9zKCk6CiAgICBpZiBub3Qg aXNfZGlhcnlfZmlsZV9hdmFpbGFibGUoKToKICAgICAgICBwcmludCAiTm8gZGlhcnkgZmlsZSBh dmFpbGFibGUgLSBhYm9ydGluZy4iCiAgICAgICAgc3lzLmV4aXQoLTEpCgogICAgdG9kb3MgPSBn ZXRfdG9kb3MoKQogICAgaWYgbGVuKHRvZG9zKSA+IDA6CiAgICAgICAgbmV3X2xpbmVzID0gbmV3 X2RpYXJ5X2xpbmVzX3dpdGhfdG9kb3ModG9kb3MpCiAgICAgICAgdHJ5OgogICAgICAgICAgICBu b3cgPSBkYXRldGltZS5ub3coKS5zdHJmdGltZSgiLiVZLSVtLSVkLSVILSVNIikKICAgICAgICAg ICAgZGlhcnlfYmFja3VwID0gZGlhcnlfZmlsZSArIG5vdyArICIub3JpZyIKIyAgICAgICAgICAg IHByaW50ICJyZW5hbWluZyIsIGRpYXJ5X2ZpbGUsICIgdG8gIiwgZGlhcnlfYmFja3VwCiAgICAg ICAgICAgIHJlbmFtZShkaWFyeV9maWxlLCBkaWFyeV9iYWNrdXApCiAgICAgICAgZXhjZXB0Ogog ICAgICAgICAgICBwcmludCAiVW5leHBlY3RlZCBlcnJvciB3aGlsZSByZW5hbWluZzoiLCBzeXMu ZXhjX2luZm8oKVswXQogICAgICAgICAgICByYWlzZQogICAgICAgIAogICAgICAgIHdyaXRlX3Rv ZG9fZmlsZShkaWFyeV9maWxlLCBuZXdfbGluZXMpCiAgICAgICAgcHJpbnQgIkFkZGVkICIsIGxl bih0b2RvcyksICIgdG9kb3MgYXQgIiwgbm93CgoKaWYgX19uYW1lX18gPT0gJ19fbWFpbl9fJzoK ICAgIHNjcmFwZV90b2RvcygpCiAgICBzeXMuZXhpdCgwKQo= --047d7bf1987ef044fb04f5fe3a6e--