comparison lisp/textmodes/remember.el @ 87054:25de6f4a58d8

Merge remember-diary.el into remember.el
author Michael Olson <mwolson@gnu.org>
date Wed, 05 Dec 2007 01:16:38 +0000
parents 047b6a6087c2
children a918e56d9947
comparison
equal deleted inserted replaced
87053:f767f1ba8301 87054:25de6f4a58d8
151 ;; electronically in one way, we're losing electronically in another; 151 ;; electronically in one way, we're losing electronically in another;
152 ;; the tool should never dominate one's focus. As the mystic 152 ;; the tool should never dominate one's focus. As the mystic
153 ;; Faridu'd-Din `Attar wrote: "Be occupied as little as possible with 153 ;; Faridu'd-Din `Attar wrote: "Be occupied as little as possible with
154 ;; things of the outer world but much with things of the inner world; 154 ;; things of the outer world but much with things of the inner world;
155 ;; then right action will overcome inaction." 155 ;; then right action will overcome inaction."
156 ;;
157 ;; * Diary integration
158 ;;
159 ;; To use, add the following to your .emacs:
160 ;;
161 ;; ;; This should be before other entries that may return t
162 ;; (add-to-list 'remember-handler-functions 'remember-diary-extract-entries)
163 ;;
164 ;; This module recognizes entries of the form
165 ;;
166 ;; DIARY: ....
167 ;;
168 ;; and puts them in your ~/.diary (or remember-diary-file) together
169 ;; with an annotation. Dates in the form YYYY.MM.DD are converted to
170 ;; YYYY-MM-DD so that diary can understand them.
171 ;;
172 ;; For example:
173 ;;
174 ;; DIARY: 2003.08.12 Sacha's birthday
175 ;;
176 ;; is stored as
177 ;;
178 ;; 2003.08.12 Sacha's birthday
156 179
157 ;;; History: 180 ;;; History:
158 181
159 ;;; Code: 182 ;;; Code:
160 183
438 (interactive) 461 (interactive)
439 (when (equal remember-buffer (buffer-name)) 462 (when (equal remember-buffer (buffer-name))
440 (kill-buffer (current-buffer)) 463 (kill-buffer (current-buffer))
441 (jump-to-register remember-register))) 464 (jump-to-register remember-register)))
442 465
466 ;;; Diary integration
467
468 (defcustom remember-diary-file nil
469 "*File for extracted diary entries.
470 If this is nil, then `diary-file' will be used instead."
471 :type 'file
472 :group 'remember)
473
474 (defun remember-diary-convert-entry (entry)
475 "Translate MSG to an entry readable by diary."
476 (save-match-data
477 (when remember-annotation
478 (setq entry (concat entry " " remember-annotation)))
479 (if (string-match "\\([0-9]+\\)\\.\\([0-9]+\\)\\.\\([0-9]+\\)" entry)
480 (replace-match
481 (if european-calendar-style
482 (concat (match-string 3 entry) "/"
483 (match-string 2 entry) "/"
484 (match-string 1 entry))
485 (concat (match-string 2 entry) "/"
486 (match-string 3 entry) "/"
487 (match-string 1 entry)))
488 t t entry)
489 entry)))
490
491 (autoload 'make-diary-entry "diary-lib")
492
493 ;;;###autoload
494 (defun remember-diary-extract-entries ()
495 "Extract diary entries from the region."
496 (save-excursion
497 (goto-char (point-min))
498 (let (list)
499 (while (re-search-forward "^DIARY:\\s-*\\(.+\\)" nil t)
500 (add-to-list 'list (remember-diary-convert-entry (match-string 1))))
501 (when list
502 (make-diary-entry (mapconcat 'identity list "\n")
503 nil (or remember-diary-file diary-file)))
504 nil))) ;; Continue processing
505
443 ;;; Internal Functions: 506 ;;; Internal Functions:
444 507
445 (defvar remember-mode-map 508 (defvar remember-mode-map
446 (let ((map (make-sparse-keymap))) 509 (let ((map (make-sparse-keymap)))
447 (define-key map "\C-x\C-s" 'remember-finalize) 510 (define-key map "\C-x\C-s" 'remember-finalize)