Commit | Line | Data |
---|---|---|
15f3eb73 MO |
1 | ;;; remember --- a mode for quickly jotting down things to remember |
2 | ||
dcb8ac09 | 3 | ;; Copyright (C) 1999, 2000, 2001, 2003, 2004, 2005, 2006, 2007, |
5df4f04c | 4 | ;; 2008, 2009, 2010, 2011 Free Software Foundation, Inc. |
15f3eb73 MO |
5 | |
6 | ;; Author: John Wiegley <johnw@gnu.org> | |
7 | ;; Created: 29 Mar 1999 | |
62f01d5e | 8 | ;; Version: 2.0 |
15f3eb73 MO |
9 | ;; Keywords: data memory todo pim |
10 | ;; URL: http://gna.org/projects/remember-el/ | |
11 | ||
12 | ;; This file is part of GNU Emacs. | |
13 | ||
1fecc8fe | 14 | ;; GNU Emacs is free software: you can redistribute it and/or modify |
15f3eb73 | 15 | ;; it under the terms of the GNU General Public License as published by |
1fecc8fe GM |
16 | ;; the Free Software Foundation, either version 3 of the License, or |
17 | ;; (at your option) any later version. | |
15f3eb73 MO |
18 | |
19 | ;; GNU Emacs is distributed in the hope that it will be useful, | |
20 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
21 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
22 | ;; GNU General Public License for more details. | |
23 | ||
24 | ;; You should have received a copy of the GNU General Public License | |
1fecc8fe | 25 | ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. |
15f3eb73 MO |
26 | |
27 | ;;; Commentary: | |
28 | ||
77210f1e | 29 | ;; * The idea |
15f3eb73 MO |
30 | ;; |
31 | ;; Todo lists, schedules, phone databases... everything we use | |
32 | ;; databases for is really just a way to extend the power of our | |
33 | ;; memory. To be able to remember what our conscious mind may not | |
34 | ;; currently have access to. | |
35 | ;; | |
36 | ;; There are many different databases out there -- and good ones -- | |
37 | ;; which this mode is not trying to replace. Rather, it's how that | |
38 | ;; data gets there that's the question. Most of the time, we just | |
39 | ;; want to say "Remember so-and-so's phone number, or that I have to | |
40 | ;; buy dinner for the cats tonight." That's the FACT. How it's | |
41 | ;; stored is really the computer's problem. But at this point in | |
42 | ;; time, it's most definitely also the user's problem, and sometimes | |
43 | ;; so laboriously so that people just let data slip, rather than | |
44 | ;; expend the effort to record it. | |
45 | ;; | |
46 | ;; "Remember" is a mode for remembering data. It uses whatever | |
47 | ;; back-end is appropriate to record and correlate the data, but it's | |
48 | ;; main intention is to allow you to express as _little_ structure as | |
49 | ;; possible up front. If you later want to express more powerful | |
50 | ;; relationships between your data, or state assumptions that were at | |
51 | ;; first too implicit to be recognized, you can "study" the data later | |
52 | ;; and rearrange it. But the initial "just remember this" impulse | |
53 | ;; should be as close to simply throwing the data at Emacs as | |
54 | ;; possible. | |
55 | ;; | |
77210f1e | 56 | ;; * Implementation |
15f3eb73 MO |
57 | ;; |
58 | ;; Hyperbole, as a data presentation tool, always struck me as being | |
59 | ;; very powerful, but it seemed to require a lot of "front-end" work | |
60 | ;; before that data was really available. The problem with BBDB, or | |
61 | ;; keeping up a Bibl-mode file, is that you have to use different | |
62 | ;; functions to record the data, and it always takes time to stop what | |
63 | ;; you're doing, format the data in the manner expected by that | |
64 | ;; particular data interface, and then resume your work. | |
65 | ;; | |
66 | ;; With "remember", you just hit `M-x remember' (you'd probably want | |
67 | ;; to bind this to an easily accessible keystroke, like C-x M-r), slam | |
68 | ;; in your text however you like, and then hit C-c C-c. It will file | |
69 | ;; the data away for later retrieval, and possibly indexing. | |
70 | ;; | |
71 | ;; Indexing is to data what "studying" is in the real world. What you | |
72 | ;; do when you study (or lucubrate, for some of us) is to realize | |
73 | ;; certain relationships implicit in the data, so that you can make | |
74 | ;; use of those relationships. Expressing that a certain quote you | |
75 | ;; remembered was a religious quote, and that you want the ability to | |
76 | ;; pull up all quotes of a religious nature, is what studying does. | |
77 | ;; This is a more labor intensive task than the original remembering | |
78 | ;; of the data, and it's typical in real life to set aside a special | |
79 | ;; period of time for doing this work. | |
80 | ;; | |
81 | ;; "Remember" works in the same way. When you enter data, either by | |
82 | ;; typing it into a buffer, or using the contents of the selected | |
83 | ;; region, it will store that data -- unindexed, uninterpreted -- in a | |
84 | ;; data pool. It will also try to remember as much context | |
85 | ;; information as possible (any text properties that were set, where | |
86 | ;; you copied it from, when, how, etc). Later, you can walk through | |
87 | ;; your accumulated set of data (both organized, and unorganized) and | |
88 | ;; easily begin moving things around, and making annotations that will | |
89 | ;; express the full meaning of that data, as far as you know it. | |
90 | ;; | |
91 | ;; Obviously this latter stage is more user-interface intensive, and | |
92 | ;; it would be nice if "remember" could do it as elegantly as | |
93 | ;; possible, rather than requiring a billion keystrokes to reorganize | |
94 | ;; your hierarchy. Well, as the future arrives, hopefully experience | |
95 | ;; and user feedback will help to make this as intuitive a tool as | |
96 | ;; possible. | |
97 | ;; | |
77210f1e | 98 | ;; * Future Goals |
15f3eb73 MO |
99 | ;; |
100 | ;; This tool hopes to track (and by doing it with as little new code | |
101 | ;; as possible): | |
102 | ;; | |
103 | ;; - The raw data that gets entered | |
104 | ;; | |
105 | ;; - The relationships between that data (either determined | |
106 | ;; implicitly by parsing the input, or explicitly by the user's | |
107 | ;; studying the data). | |
108 | ;; | |
109 | ;; - Revisioning of the data | |
110 | ;; | |
111 | ;; - Where it came from, and any context information that can be | |
112 | ;; programmatically determined. | |
113 | ;; | |
114 | ;; - Allowing particular views of the initially amorphous data pool | |
115 | ;; (ala the Xanadu concept). | |
116 | ;; | |
117 | ;; - Storage of the data in a manner most appopriate to that data, | |
118 | ;; such as keeping address-book type information in BBDB, etc. | |
119 | ;; | |
77210f1e | 120 | ;; * Using "remember" |
15f3eb73 MO |
121 | ;; |
122 | ;; As a rough beginning, what I do is to keep my .notes file in | |
123 | ;; outline-mode format, with a final entry called "* Raw data". Then, | |
124 | ;; at intervals, I can move the data that gets appended there into | |
125 | ;; other places. But certainly this should evolve into an intuitive | |
126 | ;; mechanism for shuffling data off to its appropriate corner of the | |
127 | ;; universe. | |
128 | ;; | |
77210f1e MO |
129 | ;; To map the primary remember function to the keystroke F8, do the |
130 | ;; following. | |
15f3eb73 | 131 | ;; |
77210f1e | 132 | ;; (autoload 'remember "remember" nil t) |
15f3eb73 | 133 | ;; |
77210f1e | 134 | ;; (define-key global-map [f8] 'remember) |
15f3eb73 | 135 | ;; |
77210f1e | 136 | ;; * Feedback |
15f3eb73 MO |
137 | ;; |
138 | ;; If Emacs could become a more intelligent data store, where | |
139 | ;; brainstorming would focus on the IDEAS involved -- rather than the | |
140 | ;; structuring and format of those ideas, or having to stop your | |
141 | ;; current flow of work in order to record them -- it would map much | |
142 | ;; more closely to how the mind (well, at least mine) works, and hence | |
143 | ;; would eliminate that very manual-ness which computers from the very | |
144 | ;; beginning have been championed as being able to reduce. | |
145 | ;; | |
146 | ;; Have you ever noticed that having a laptop to write on doesn't | |
147 | ;; _actually_ increase the amount of quality material that you turn | |
148 | ;; out, in the long run? Perhaps its because the time we save | |
149 | ;; electronically in one way, we're losing electronically in another; | |
150 | ;; the tool should never dominate one's focus. As the mystic | |
151 | ;; Faridu'd-Din `Attar wrote: "Be occupied as little as possible with | |
152 | ;; things of the outer world but much with things of the inner world; | |
153 | ;; then right action will overcome inaction." | |
3728bf03 MO |
154 | ;; |
155 | ;; * Diary integration | |
156 | ;; | |
157 | ;; To use, add the following to your .emacs: | |
158 | ;; | |
159 | ;; ;; This should be before other entries that may return t | |
160 | ;; (add-to-list 'remember-handler-functions 'remember-diary-extract-entries) | |
161 | ;; | |
162 | ;; This module recognizes entries of the form | |
163 | ;; | |
164 | ;; DIARY: .... | |
165 | ;; | |
166 | ;; and puts them in your ~/.diary (or remember-diary-file) together | |
167 | ;; with an annotation. Dates in the form YYYY.MM.DD are converted to | |
168 | ;; YYYY-MM-DD so that diary can understand them. | |
169 | ;; | |
170 | ;; For example: | |
171 | ;; | |
172 | ;; DIARY: 2003.08.12 Sacha's birthday | |
173 | ;; | |
174 | ;; is stored as | |
175 | ;; | |
176 | ;; 2003.08.12 Sacha's birthday | |
15f3eb73 MO |
177 | |
178 | ;;; History: | |
179 | ||
180 | ;;; Code: | |
181 | ||
182 | (provide 'remember) | |
183 | ||
62f01d5e | 184 | (defconst remember-version "2.0" |
15f3eb73 MO |
185 | "This version of remember.") |
186 | ||
187 | (defgroup remember nil | |
188 | "A mode to remember information." | |
189 | :group 'data) | |
190 | ||
191 | ;;; User Variables: | |
192 | ||
193 | (defcustom remember-mode-hook nil | |
194 | "Functions run upon entering `remember-mode'." | |
195 | :type 'hook | |
e0628060 | 196 | :options '(flyspell-mode turn-on-auto-fill org-remember-apply-template) |
15f3eb73 MO |
197 | :group 'remember) |
198 | ||
199 | (defcustom remember-in-new-frame nil | |
200 | "Non-nil means use a separate frame for capturing remember data." | |
201 | :type 'boolean | |
202 | :group 'remember) | |
203 | ||
204 | (defcustom remember-register ?R | |
205 | "The register in which the window configuration is stored." | |
206 | :type 'character | |
207 | :group 'remember) | |
208 | ||
209 | (defcustom remember-filter-functions nil | |
7ee68ed5 | 210 | "Functions run to filter remember data. |
15f3eb73 MO |
211 | All functions are run in the remember buffer." |
212 | :type 'hook | |
213 | :group 'remember) | |
214 | ||
215 | (defcustom remember-handler-functions '(remember-append-to-file) | |
7ee68ed5 | 216 | "Functions run to process remember data. |
15f3eb73 MO |
217 | Each function is called with the current buffer narrowed to what the |
218 | user wants remembered. | |
219 | If any function returns non-nil, the data is assumed to have been | |
220 | recorded somewhere by that function. " | |
221 | :type 'hook | |
e0628060 MO |
222 | :options '(remember-store-in-mailbox |
223 | remember-append-to-file | |
224 | remember-diary-extract-entries | |
225 | org-remember-handler) | |
15f3eb73 MO |
226 | :group 'remember) |
227 | ||
228 | (defcustom remember-all-handler-functions nil | |
7ee68ed5 | 229 | "If non-nil every function in `remember-handler-functions' is called." |
15f3eb73 MO |
230 | :type 'boolean |
231 | :group 'remember) | |
232 | ||
233 | ;;; Internal Variables: | |
234 | ||
235 | (defvar remember-buffer "*Remember*" | |
236 | "The name of the remember data entry buffer.") | |
237 | ||
238 | (defcustom remember-save-after-remembering t | |
7ee68ed5 | 239 | "Non-nil means automatically save after remembering." |
15f3eb73 MO |
240 | :type 'boolean |
241 | :group 'remember) | |
242 | ||
243 | ;;; User Functions: | |
244 | ||
77210f1e MO |
245 | (defcustom remember-annotation-functions '(buffer-file-name) |
246 | "Hook that returns an annotation to be inserted into the remember buffer." | |
15f3eb73 | 247 | :type 'hook |
e0628060 | 248 | :options '(org-remember-annotation buffer-file-name) |
15f3eb73 MO |
249 | :group 'remember) |
250 | ||
251 | (defvar remember-annotation nil | |
252 | "Current annotation.") | |
253 | (defvar remember-initial-contents nil | |
254 | "Initial contents to place into *Remember* buffer.") | |
174a72ea MO |
255 | |
256 | (defcustom remember-before-remember-hook nil | |
257 | "Functions run before switching to the *Remember* buffer." | |
258 | :type 'hook | |
259 | :group 'remember) | |
15f3eb73 MO |
260 | |
261 | (defcustom remember-run-all-annotation-functions-flag nil | |
7ee68ed5 | 262 | "Non-nil means use all annotations returned by `remember-annotation-functions'." |
15f3eb73 MO |
263 | :type 'boolean |
264 | :group 'remember) | |
265 | ||
266 | ;;;###autoload | |
267 | (defun remember (&optional initial) | |
268 | "Remember an arbitrary piece of data. | |
174a72ea MO |
269 | INITIAL is the text to initially place in the *Remember* buffer, |
270 | or nil to bring up a blank *Remember* buffer. | |
271 | ||
043989e3 | 272 | With a prefix or a visible region, use the region as INITIAL." |
15f3eb73 | 273 | (interactive |
043989e3 MO |
274 | (list (when (or current-prefix-arg |
275 | (and mark-active | |
276 | transient-mark-mode)) | |
277 | (buffer-substring (region-beginning) (region-end))))) | |
15f3eb73 MO |
278 | (funcall (if remember-in-new-frame |
279 | #'frame-configuration-to-register | |
280 | #'window-configuration-to-register) remember-register) | |
281 | (let* ((annotation | |
282 | (if remember-run-all-annotation-functions-flag | |
283 | (mapconcat 'identity | |
284 | (delq nil | |
285 | (mapcar 'funcall remember-annotation-functions)) | |
286 | "\n") | |
287 | (run-hook-with-args-until-success | |
288 | 'remember-annotation-functions))) | |
289 | (buf (get-buffer-create remember-buffer))) | |
290 | (run-hooks 'remember-before-remember-hook) | |
291 | (funcall (if remember-in-new-frame | |
292 | #'switch-to-buffer-other-frame | |
293 | #'switch-to-buffer-other-window) buf) | |
294 | (if remember-in-new-frame | |
295 | (set-window-dedicated-p | |
296 | (get-buffer-window (current-buffer) (selected-frame)) t)) | |
297 | (remember-mode) | |
298 | (when (= (point-max) (point-min)) | |
299 | (when initial (insert initial)) | |
300 | (setq remember-annotation annotation) | |
301 | (when remember-initial-contents (insert remember-initial-contents)) | |
302 | (when (and (stringp annotation) | |
303 | (not (equal annotation ""))) | |
304 | (insert "\n\n" annotation)) | |
305 | (setq remember-initial-contents nil) | |
306 | (goto-char (point-min))) | |
307 | (message "Use C-c C-c to remember the data."))) | |
308 | ||
309 | ;;;###autoload | |
310 | (defun remember-other-frame (&optional initial) | |
311 | "Call `remember' in another frame." | |
312 | (interactive | |
313 | (list (when current-prefix-arg | |
314 | (buffer-substring (point) (mark))))) | |
315 | (let ((remember-in-new-frame t)) | |
316 | (remember initial))) | |
317 | ||
318 | (defsubst remember-time-to-seconds (time) | |
319 | "Convert TIME to a floating point number." | |
320 | (+ (* (car time) 65536.0) | |
321 | (cadr time) | |
322 | (/ (or (car (cdr (cdr time))) 0) 1000000.0))) | |
323 | ||
324 | (defsubst remember-mail-date (&optional rfc822-p) | |
325 | "Return a simple date. Nothing fancy." | |
326 | (if rfc822-p | |
327 | (format-time-string "%a, %e %b %Y %T %z" (current-time)) | |
b152c5d3 | 328 | (format-time-string "%a %b %e %T %Y" (current-time)))) |
15f3eb73 MO |
329 | |
330 | (defun remember-buffer-desc () | |
331 | "Using the first line of the current buffer, create a short description." | |
332 | (buffer-substring (point-min) | |
333 | (save-excursion | |
334 | (goto-char (point-min)) | |
335 | (end-of-line) | |
336 | (if (> (- (point) (point-min)) 60) | |
337 | (goto-char (+ (point-min) 60))) | |
338 | (point)))) | |
339 | ||
340 | ;; Remembering to UNIX mailboxes | |
341 | ||
342 | (defcustom remember-mailbox "~/Mail/remember" | |
7ee68ed5 | 343 | "The file in which to store remember data as mail." |
15f3eb73 MO |
344 | :type 'file |
345 | :group 'remember) | |
346 | ||
347 | (defcustom remember-default-priority "medium" | |
7ee68ed5 | 348 | "The default priority for remembered mail messages." |
15f3eb73 MO |
349 | :type 'string |
350 | :group 'remember) | |
351 | ||
352 | (defun remember-store-in-mailbox () | |
353 | "Store remember data as if it were incoming mail. | |
354 | In which case `remember-mailbox' should be the name of the mailbox. | |
7ee68ed5 | 355 | Each piece of pseudo-mail created will have an `X-Todo-Priority' |
15f3eb73 MO |
356 | field, for the purpose of appropriate splitting." |
357 | (let ((who (read-string "Who is this item related to? ")) | |
358 | (moment | |
359 | (format "%.0f" (remember-time-to-seconds (current-time)))) | |
360 | (desc (remember-buffer-desc)) | |
361 | (text (buffer-string))) | |
362 | (with-temp-buffer | |
b152c5d3 | 363 | (insert (format "From %s %s |
15f3eb73 MO |
364 | Date: %s |
365 | From: %s | |
366 | Message-Id: <remember-%s@%s> | |
367 | X-Todo-Priority: %s | |
368 | To: %s <%s> | |
369 | Subject: %s\n\n" | |
370 | (user-login-name) | |
371 | (remember-mail-date) | |
372 | (remember-mail-date t) | |
373 | who | |
374 | moment (system-name) | |
375 | remember-default-priority | |
376 | (user-full-name) user-mail-address | |
377 | desc)) | |
378 | (let ((here (point))) | |
379 | (insert text) | |
380 | (unless (bolp) | |
381 | (insert "\n")) | |
382 | (insert "\n") | |
383 | (goto-char here) | |
384 | (while (re-search-forward "^\\(From[: ]\\)" nil t) | |
385 | (replace-match ">\\1"))) | |
386 | (append-to-file (point-min) (point-max) remember-mailbox) | |
387 | t))) | |
388 | ||
15f3eb73 MO |
389 | ;; Remembering to plain files |
390 | ||
d6ab9840 | 391 | (defcustom remember-data-file (convert-standard-filename "~/.notes") |
7ee68ed5 | 392 | "The file in which to store unprocessed data." |
15f3eb73 MO |
393 | :type 'file |
394 | :group 'remember) | |
395 | ||
396 | (defcustom remember-leader-text "** " | |
7ee68ed5 | 397 | "The text used to begin each remember item." |
15f3eb73 MO |
398 | :type 'string |
399 | :group 'remember) | |
400 | ||
401 | (defun remember-append-to-file () | |
402 | "Remember, with description DESC, the given TEXT." | |
403 | (let ((text (buffer-string)) | |
404 | (desc (remember-buffer-desc))) | |
405 | (with-temp-buffer | |
406 | (insert "\n" remember-leader-text (current-time-string) | |
407 | " (" desc ")\n\n" text) | |
408 | (if (not (bolp)) | |
409 | (insert "\n")) | |
410 | (if (find-buffer-visiting remember-data-file) | |
411 | (let ((remember-text (buffer-string))) | |
412 | (set-buffer (get-file-buffer remember-data-file)) | |
413 | (save-excursion | |
414 | (goto-char (point-max)) | |
415 | (insert remember-text) | |
416 | (when remember-save-after-remembering (save-buffer)))) | |
417 | (append-to-file (point-min) (point-max) remember-data-file))))) | |
418 | ||
15f3eb73 MO |
419 | (defun remember-region (&optional beg end) |
420 | "Remember the data from BEG to END. | |
174a72ea | 421 | It is called from within the *Remember* buffer to save the text |
043989e3 | 422 | that was entered. |
174a72ea MO |
423 | |
424 | If BEG and END are nil, the entire buffer will be remembered. | |
15f3eb73 | 425 | |
15f3eb73 | 426 | If you want to remember a region, supply a universal prefix to |
7ee68ed5 | 427 | `remember' instead. For example: \\[universal-argument] \\[remember] RET." |
15f3eb73 MO |
428 | ;; Sacha: I have no idea where remember.el gets this context information, but |
429 | ;; you can just use remember-annotation-functions. | |
430 | (interactive) | |
431 | (let ((b (or beg (min (point) (or (mark) (point-min))))) | |
432 | (e (or end (max (point) (or (mark) (point-max)))))) | |
433 | (save-restriction | |
434 | (narrow-to-region b e) | |
435 | (if remember-all-handler-functions | |
436 | (run-hooks 'remember-handler-functions) | |
437 | (run-hook-with-args-until-success 'remember-handler-functions)) | |
438 | (remember-destroy)))) | |
439 | ||
440 | ;;;###autoload | |
441 | (defun remember-clipboard () | |
442 | "Remember the contents of the current clipboard. | |
443 | Most useful for remembering things from Netscape or other X Windows | |
444 | application." | |
445 | (interactive) | |
446 | (remember (current-kill 0))) | |
447 | ||
174a72ea | 448 | (defun remember-finalize () |
15f3eb73 MO |
449 | "Remember the contents of the current buffer." |
450 | (interactive) | |
451 | (remember-region (point-min) (point-max))) | |
452 | ||
246a4316 | 453 | ;; Org needs this |
cb5b40ee | 454 | (define-obsolete-function-alias 'remember-buffer 'remember-finalize "23.1") |
246a4316 | 455 | |
15f3eb73 MO |
456 | (defun remember-destroy () |
457 | "Destroy the current *Remember* buffer." | |
458 | (interactive) | |
459 | (when (equal remember-buffer (buffer-name)) | |
460 | (kill-buffer (current-buffer)) | |
461 | (jump-to-register remember-register))) | |
462 | ||
3728bf03 MO |
463 | ;;; Diary integration |
464 | ||
465 | (defcustom remember-diary-file nil | |
7ee68ed5 | 466 | "File for extracted diary entries. |
3728bf03 MO |
467 | If this is nil, then `diary-file' will be used instead." |
468 | :type 'file | |
469 | :group 'remember) | |
470 | ||
471 | (defun remember-diary-convert-entry (entry) | |
472 | "Translate MSG to an entry readable by diary." | |
473 | (save-match-data | |
474 | (when remember-annotation | |
475 | (setq entry (concat entry " " remember-annotation))) | |
476 | (if (string-match "\\([0-9]+\\)\\.\\([0-9]+\\)\\.\\([0-9]+\\)" entry) | |
3f651ee6 GM |
477 | (progn |
478 | ;; For calendar-date-style. This costs us nothing because | |
c5de0a17 | 479 | ;; the call to diary-make-entry below loads diary-lib |
3f651ee6 GM |
480 | ;; which requires calendar. |
481 | (require 'calendar) | |
482 | (replace-match | |
483 | (let ((style (if (boundp 'calendar-date-style) | |
484 | calendar-date-style | |
485 | ;; Don't complain about obsoleteness. | |
486 | (if (with-no-warnings european-calendar-style) | |
487 | 'european | |
488 | 'american)))) | |
489 | (cond ((eq style 'european) | |
490 | (concat (match-string 3 entry) "/" | |
491 | (match-string 2 entry) "/" | |
492 | (match-string 1 entry))) | |
493 | ((eq style 'iso) | |
494 | (concat (match-string 1 entry) "-" | |
495 | (match-string 2 entry) "-" | |
496 | (match-string 3 entry))) | |
497 | (t (concat (match-string 2 entry) "/" | |
498 | (match-string 3 entry) "/" | |
499 | (match-string 1 entry))))) | |
500 | t t entry)) | |
3728bf03 MO |
501 | entry))) |
502 | ||
c5de0a17 | 503 | (autoload 'diary-make-entry "diary-lib") |
3728bf03 MO |
504 | |
505 | ;;;###autoload | |
506 | (defun remember-diary-extract-entries () | |
507 | "Extract diary entries from the region." | |
508 | (save-excursion | |
509 | (goto-char (point-min)) | |
510 | (let (list) | |
511 | (while (re-search-forward "^DIARY:\\s-*\\(.+\\)" nil t) | |
512 | (add-to-list 'list (remember-diary-convert-entry (match-string 1)))) | |
513 | (when list | |
800aaa89 | 514 | (diary-make-entry (mapconcat 'identity list "\n") |
612b0592 | 515 | nil remember-diary-file)) |
3728bf03 MO |
516 | nil))) ;; Continue processing |
517 | ||
15f3eb73 MO |
518 | ;;; Internal Functions: |
519 | ||
80f0c18f MO |
520 | (defvar remember-mode-map |
521 | (let ((map (make-sparse-keymap))) | |
522 | (define-key map "\C-x\C-s" 'remember-finalize) | |
523 | (define-key map "\C-c\C-c" 'remember-finalize) | |
869dc290 | 524 | (define-key map "\C-c\C-k" 'remember-destroy) |
869dc290 | 525 | map) |
15f3eb73 | 526 | "Keymap used in Remember mode.") |
15f3eb73 | 527 | |
7ee68ed5 | 528 | (define-derived-mode remember-mode indented-text-mode "Remember" |
15f3eb73 | 529 | "Major mode for output from \\[remember]. |
869dc290 | 530 | This buffer is used to collect data that you want to remember. |
7ee68ed5 JB |
531 | \\<remember-mode-map> |
532 | Just hit \\[remember-finalize] when you're done entering, and it will file | |
869dc290 MO |
533 | the data away for latter retrieval, and possible indexing. |
534 | ||
535 | \\{remember-mode-map}" | |
7ee68ed5 | 536 | (set-keymap-parent remember-mode-map nil)) |
15f3eb73 | 537 | |
904fac67 | 538 | ;; arch-tag: 59312a05-06c7-4da1-b6f7-5ea41c9d5577 |
15f3eb73 | 539 | ;;; remember.el ends here |