From: Christopher League <league@contrapunctus.net>
To: org-mode mailing list <emacs-orgmode@gnu.org>
Subject: Re: processing pending emails as part of your GTD system
Date: Tue, 22 Apr 2008 12:55:55 -0400 [thread overview]
Message-ID: <3D9B5F2E-A15C-45C6-AF49-8E0E62248936@contrapunctus.net> (raw)
In-Reply-To: <24266.1208760913@localhost>
[-- Attachment #1: Type: text/plain, Size: 2064 bytes --]
On Apr 21, 2008, at 2:55 AM, Pete Phillips wrote:
> 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.
Interesting, I have a similar script that also requires cron/shell
access to mail server, but works with mbox format instead of MH, and
is compatible with, e.g., dovecot IMAP server. Mine is slightly less
fancy, in that I file messages to absolute folders named "days/25" or
"months/07-July" (rather than "nextweek") to have them dumped back
into my spool at the indicated time. See the 'email-tickler-update'
script attached.
More relevant to org-mode, I have an emacs-lisp/apple-script combo for
pasting links to Apple Mail messages into org files:
(defun cal-grab-mail-links ()
(interactive)
(call-process "/usr/bin/osascript" nil t nil
"/home/league/Library/Scripts/Applications/Mail/Copy
Message for OrgMode.scpt")
(yank))
(define-key org-mode-map "\C-cm" 'cal-grab-mail-links)
;;;;; and the .scpt component:
-- Replace all occurences of one string for another in a text
-- The trick here is to change the internal delimiter,
-- spliting and joining the text
--
on replaceString(theText, oldString, newString)
set AppleScript's text item delimiters to oldString
set tempList to every text item of theText
set AppleScript's text item delimiters to newString
set theText to the tempList as string
set AppleScript's text item delimiters to ""
return theText
end replaceString
tell application "Mail"
set _sel to get selection
set _links to {}
repeat with _msg in _sel
set _subj to _msg's subject
set _subj to my replaceString(_subj, "[", "(")
set _subj to my replaceString(_subj, "]", ")")
set _messageURL to "[[message://%3c" & _msg's message id & "%3e][" &
_subj & "]]"
set end of _links to _messageURL
end repeat
set AppleScript's text item delimiters to return
set the clipboard to (_links as string)
end tell
[-- Attachment #2: email-tickler-update.txt --]
[-- Type: text/plain, Size: 2160 bytes --]
#!/usr/bin/env zsh
## email-tickler-update -- manage a set of 43 mailboxes as a 'tickler' file
## Written by and for Christopher League <league@contrapunctus.net>
## but released to the public domain.
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
### Settings ###
mail_spool=/var/mail
mail_dir=mail
today=$(date +%d) # 03, 14, 31, ...
month=$(date +%m-%b) # 02-Feb, 11-Nov, ...
day_mbox=${mail_dir}/days/${today}
month_mbox=${mail_dir}/months/${month}
users=($*)
### Helper functions ###
## Maybe run a command; maybe print it instead. If this script is run
## with DRYRUN set (to anything except empty string), it will avoid
## taking any real actions, and just print the commands.
run() {
if [[ -z $DRYRUN ]]; then # do it for real
$*
else # output only
print '%' $*
fi
}
## Run a command, but exit with message on error.
guard() {
run $*
if [[ $? != 0 ]]; then
print "FATAL($?): $*"
exit $?
fi
}
readable() {
if [[ ! -r $1 ]]; then
print unreadable: $1
exit 1
fi
}
### Primary actions ###
## Append given file to mail spool, then empty it out.
move_to_spool() {
cat $1 >>${user_mail_spool}
print -n >$1
}
## This wraps the above with the proper locking protocol, and does it
## only if given mailbox is non-empty.
protected_move() {
guard lockfile $1.lock
if [[ -s $1 ]]; then
guard lockfile ${user_mail_spool}.lock
guard move_to_spool $1
guard rm -f ${user_mail_spool}.lock
fi
guard rm -f $1.lock
}
### Main loop ###
for u in $users; do
user_mail_spool=${mail_spool}/$u
readable ${user_mail_spool}
readable ~$u/${day_mbox}
readable ~$u/${month_mbox}
protected_move ~$u/${day_mbox}
if [[ $today == 01 ]]; then
protected_move ~$u/${month_mbox}
fi
done
exit 0
[-- Attachment #3: Type: text/plain, Size: 1 bytes --]
[-- Attachment #4: 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
next prev parent reply other threads:[~2008-04-22 16:56 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 [this message]
2008-04-23 19:25 ` Erik Hetzner
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=3D9B5F2E-A15C-45C6-AF49-8E0E62248936@contrapunctus.net \
--to=league@contrapunctus.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 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).