1 ;;; remember-diary --- extracting diary information from buffers
3 ;; Copyright (C) 1999, 2000, 2001 John Wiegley
4 ;; Copyright (C) 2004 Sandra Jean Chua
6 ;; Author: Sacha Chua <sacha@free.net.ph>
7 ;; Created: 24 Mar 2004
8 ;; Keywords: data memory todo pim diary
9 ;; URL: http://gna.org/projects/remember-el/
11 ;; This file is not part of GNU Emacs.
13 ;; This is free software; you can redistribute it and/or modify it under
14 ;; the terms of the GNU General Public License as published by the Free
15 ;; Software Foundation; either version 2, or (at your option) any later
18 ;; This is distributed in the hope that it will be useful, but WITHOUT
19 ;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20 ;; FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
23 ;; You should have received a copy of the GNU General Public License
24 ;; along with GNU Emacs; see the file COPYING. If not, write to the
25 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
26 ;; MA 02111-1307, USA.
30 ;; This module recognizes entries of the form
34 ;; and puts them in your ~/.diary (or remember-diary-file) together
35 ;; with an annotation. Planner-style dates (yyyy.mm.dd) are converted
36 ;; to yyyy-mm-dd so that diary can understand them.
40 ;; DIARY: 2003.08.12 Sacha's birthday
44 ;; 2003.08.12 Sacha's birthday [[/home/sacha/notebook/emacs/emacs-wiki/remember-diary.el]]
46 ;; To use, add the following to your .emacs:
48 ;; (require 'remember-diary)
49 ;; ;; This should be before other entries that may return t
50 ;; (add-to-list 'remember-handler-functions 'remember-diary-extract-entries)
57 (defcustom remember-diary-file diary-file
58 "*File for extracted diary entries."
62 (defun remember-diary-convert-entry (entry)
63 "Translate MSG to an entry readable by diary."
65 (when remember-annotation
66 (setq entry
(concat entry
" " remember-annotation
)))
67 (if (string-match "\\([0-9]+\\)\\.\\([0-9]+\\)\\.\\([0-9]+\\)" entry
)
69 (if european-calendar-style
70 (concat (match-string 3 entry
) "/"
71 (match-string 2 entry
) "/"
72 (match-string 1 entry
))
73 (concat (match-string 2 entry
) "/"
74 (match-string 3 entry
) "/"
75 (match-string 1 entry
)))
80 (defun remember-diary-extract-entries ()
81 "Extract diary entries from the region."
83 (goto-char (point-min))
85 (while (re-search-forward "^DIARY:\\s-*\\(.+\\)" nil t
)
86 (add-to-list 'list
(remember-diary-convert-entry (match-string 1))))
88 (make-diary-entry (mapconcat 'identity list
"\n")
89 nil remember-diary-file
))
90 nil
))) ;; Continue processing
92 (provide 'remember-diary
)
94 ;;; remember-diary.el ends here