emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Erik Hetzner <ehetzner@gmail.com>
To: org-mode mailing list <emacs-orgmode@gnu.org>
Subject: Re: processing pending emails as part of your GTD system
Date: Wed, 23 Apr 2008 12:25:17 -0700	[thread overview]
Message-ID: <87k5iope5e.wl%erik.hetzner@ucop.edu> (raw)
In-Reply-To: <24266.1208760913@localhost>


[-- Attachment #1.1.1: Type: text/plain, Size: 1310 bytes --]

At Mon, 21 Apr 2008 07:55:13 +0100,
Pete Phillips <pete@smtl.co.uk> wrote:
> This post is slighly off-topic, as it is not directly about org-mode.
> 
> As many of you on the list will know, I'm a big fan of David Allen's GTD
> system, and over the years I have tweaked my use of MH and MH-E to help
> support this use.
> 
> One thing I have done is design a method so that I can easily put emails
> into a set of 'pending' mail folders, and then get cron to process these
> and dump the emails back into my +inbox at appropriate dates.
>
> […]

This is a neat trick. I’m giving it a try to help me keep my inbox as
empty as possible.

However, I use IMAP & Wanderlust. Attached is a quick Ruby script that
should provide similar functionality for any IMAP system, and some
cron entries to call it, for anybody who wants it. This works for me,
but I have commented out the lines in the script which actually delete
mail from one mailbox; I don’t want to be responsible for losing mail.

The mailboxes used by the cron entries are (a little different from
yours):

pending/tomorrow
pending/tonight
pending/nextweek
pending/d01 .. pending/day31
pending/january .. pending/december
pending/monday .. pending/sunday
today

Hope this helps somebody.

best,
Erik Hetzner


[-- Attachment #1.1.2: crontab-example --]
[-- Type: application/octet-stream, Size: 1194 bytes --]

IMAP_PASSWORD=...
IMAP_USER=...
IMAP_HOST=...
IMAP_INBOX=INBOX

#############################################################
#  Mail Section
#############################################################
### Each month, refile all the pending stuff back to my inbox.
### 00:01 on the first day of each month
1 0 1 * * $HOME/bin/imap-dump-folder.rb pending/`date +\%B | tr A-Z a-z` $IMAP_INBOX
### Each monday at 00:02 refile all the next-week stuff
2 0 * * 1 $HOME/bin/imap-dump-folder.rb pending/nextweek $IMAP_INBOX
### Each day also has its own pending - Saturday, Sunday etc
3 0 * * * $HOME/bin/imap-dump-folder.rb pending/`date +\%A | tr A-Z a-z` $IMAP_INBOX
### Each date of the month (1-31) also has its own pending - d01, d11, d31 etc
4 0 * * * $HOME/bin/imap-dump-folder.rb pending/d`date +\%d` $IMAP_INBOX
### Each night at 17:30 - refile all pending/tonight to INBOX
30 17 * * * $HOME/bin/imap-dump-folder.rb pending/tonight $IMAP_INBOX
### Each night at 12:30 - refile all today stuff back to INBOX
30 00 * * * $HOME/bin/imap-dump-folder.rb today $IMAP_INBOX
# Each day refile the tomorrow pending back to INBOX
5 0 * * * $HOME/bin/imap-dump-folder.rb pending/tomorrow $IMAP_INBOX


[-- Attachment #1.1.3: imap-dump-folder.rb --]
[-- Type: application/octet-stream, Size: 1632 bytes --]

#!/usr/bin/env ruby
require 'net/imap'

#defaults
host = ENV['IMAP_HOST'] || ''
port = (ENV['IMAP_PORT'] || '143').to_i
use_ssl = !(ENV['IMAP_SSL'].nil?)
user = ENV['IMAP_USER'] || ''
password = ENV['IMAP_PASSWORD'] || ''
source_folder = ""
target_folder = ""
help_me = false

def imap_dump_folder(host, port, use_ssl, user, password, source_folder, target_folder)
  imap = Net::IMAP.new(host, port, use_ssl)
  imap.login(user, password)
  imap.select(source_folder)
  (1..imap.responses["EXISTS"][-1]).each do |mid|
    imap.copy(mid, target_folder)
    #imap.store(mid, "+FLAGS", [:Deleted])
  end
  #imap.expunge()
end

def usage(do_exit = true)
  STDERR.print "usage: #{$0} [options] source target
  --host=string        host server name
  --port=string        host server port
  --ssl                use ssl
  --user=string        username
  --password=string    password
  --help               show this message.
"
  exit if do_exit
end

ARGV.each do |option|
  case (option)
  when /^--host=(.+)/
    host = $1
  when /^--port=([0-9]+)/
    port = $1.to_i
  when /^--user=(.+)/
    user = $1
  when /^--password=(.+)/
    password = $1
  when /^--ssl/
    use_ssl = true
  when /^--help/
    help_me = true
  when /^(.+)/
    if (source_folder == '') then
      source_folder = $1
    elsif (target_folder == '') then
      target_folder = $1
    else
      usage()
    end
  else
    usage()
  end
end

if (host == "" or user == "" or password == "" or source_folder == "" or target_folder == "" or help_me == true) then
  usage(true)
end

imap_dump_folder(host, port, use_ssl, user, password, source_folder, target_folder)

[-- Attachment #1.2: Type: application/pgp-signature, Size: 189 bytes --]

[-- Attachment #2: Type: text/plain, Size: 204 bytes --]

_______________________________________________
Emacs-orgmode mailing list
Remember: use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode

  parent reply	other threads:[~2008-04-23 19:22 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-04-21  6:55 processing pending emails as part of your GTD system Pete Phillips
2008-04-22 16:55 ` Christopher League
2008-04-23 19:25 ` Erik Hetzner [this message]
2008-04-30 21:25 ` Adam Spiers
2008-05-01  6:32   ` Carsten Dominik
2008-05-03 21:32     ` Adam Spiers
  -- strict thread matches above, loose matches on Subject: below --
2008-04-23 15:34 bva
2008-04-24  3:38 ` Christopher League

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=87k5iope5e.wl%erik.hetzner@ucop.edu \
    --to=ehetzner@gmail.com \
    --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 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).