Keep pristine copy of updated Remember manual
[remember-el.git] / remember-bbdb.el
blob3ec8c59504ebfe12391371611d42dc2d81af8833
1 ;;; remember-bbdb --- BBDB support for remember.el
3 ;; Copyright (C) 1999, 2000, 2001 John Wiegley
4 ;; Copyright (C) 2003 Sandra Jean Chua
6 ;; Author: John Wiegley <johnw@gnu.org>
7 ;; Maintainer: Sacha Chua <sacha@free.net.ph>
8 ;; Created: 29 Mar 1999
9 ;; Keywords: data memory todo pim bbdb
10 ;; URL: http://gna.org/projects/remember-el/
12 ;; GNU Emacs is free software; you can redistribute it and/or modify
13 ;; it under the terms of the GNU General Public License as published by
14 ;; the Free Software Foundation; either version 2, or (at your option)
15 ;; any later version.
17 ;; GNU Emacs is distributed in the hope that it will be useful,
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 ;; GNU General Public License for more details.
22 ;; You should have received a copy of the GNU General Public License
23 ;; along with GNU Emacs; see the file COPYING. If not, write to the
24 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
25 ;; Boston, MA 02111-1307, USA.
27 ;;; Commentary:
29 ;; This adds completing reads to remember-bbdb-store-in-mailbox. To
30 ;; use, add (require 'remember-bbdb) to your .emacs, and make your
31 ;; remember-handler-functions include remember-bbdb-store-in-mailbox.
33 ;;; Code:
35 (require 'remember)
36 (require 'bbdb-com)
38 ;;;###autoload
39 (defun remember-bbdb-store-in-mailbox ()
40 "Store remember data as if it were incoming mail.
41 In which case `remember-mailbox' should be the name of the mailbox.
42 Each piece of psuedo-mail created will have an `X-Todo-Priority'
43 field, for the purpose of appropriate splitting."
44 (let ((who (bbdb-completing-read-record
45 "Who is this item related to? "))
46 (moment
47 (format "%.0f" (remember-time-to-seconds (current-time))))
48 (desc (remember-buffer-desc))
49 (text (buffer-string))
50 name address)
51 (with-temp-buffer
52 (if (vectorp who)
53 (let ((net (bbdb-record-net who)))
54 (setq name (bbdb-record-name who)
55 address (if (listp net)
56 (car net)
57 net)))
58 (if (stringp who)
59 (setq name who)
60 (setq name (user-full-name)
61 address user-mail-address)))
62 (insert (format "
63 From %s %s
64 Date: %s
65 From: %s
66 Message-Id: <remember-%s@%s>
67 X-Todo-Priority: %s
68 To: %s <%s>
69 Subject: %s\n\n"
70 (user-login-name)
71 (remember-mail-date)
72 (remember-mail-date t)
73 (if (and name address)
74 (format "%s <%s>" name address)
75 (or name address))
76 moment (system-name)
77 remember-default-priority
78 (user-full-name) user-mail-address
79 desc))
80 (let ((here (point)))
81 (insert text)
82 (unless (bolp)
83 (insert "\n"))
84 (insert "\n")
85 (goto-char here)
86 (while (re-search-forward "^\\(From[: ]\\)" nil t)
87 (replace-match ">\\1")))
88 (append-to-file (point-min) (point-max) remember-mailbox)
89 t)))
91 (custom-add-option 'remember-handler-functions 'remember-bbdb-store-in-mailbox)
93 (provide 'remember-bbdb)
95 ;;; remember-bbdb.el ends here