1 ;;; remember-emacs-wiki-journal.el --- EmacsWiki journal support for remember
3 ;; Copyright (C) 2004 Hoan Ton-That
5 ;; Author: Hoan Ton-That <hoan@ton-that.org>
6 ;; Maintainer: Hoan Ton-That <hoan@ton-that.org>
7 ;; Created: 11 Jul 2004
9 ;; Keywords: hypermedia remember wiki blog journal
10 ;; URL: http://www.ton-that.org/elisp/remember-emacs-wiki-journal.el
12 ;; This file is not part of GNU Emacs.
14 ;; This is free software; you can redistribute it and/or modify it under
15 ;; the terms of the GNU General Public License as published by the Free
16 ;; Software Foundation; either version 2, or (at your option) any later
19 ;; This is distributed in the hope that it will be useful, but WITHOUT
20 ;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21 ;; FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
24 ;; You should have received a copy of the GNU General Public License
25 ;; along with GNU Emacs; see the file COPYING. If not, write to the
26 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
27 ;; MA 02111-1307, USA.
33 ;; When loading remember-emacs-wiki-journal it is a good idea to make
34 ;; remember call all hooks
36 ;; (require 'remember-emacs-wiki-journal)
37 ;; (setq remember-all-handler-functions t)
41 ;; There are three hooks for remember:
42 ;; * `remember-emacs-wiki-journal-add-entry';
43 ;; * `remember-emacs-wiki-journal-add-entry-auto'; and
44 ;; * `remember-emacs-wiki-journal-add-entry-maybe'.
46 ;; When `remember-emacs-wiki-journal-add-entry' is called, you are
47 ;; prompted for a category and title. Just fill those in and the
48 ;; entry will be added.
50 ;; The above hook is clumsy because of the prompt.
51 ;; `remember-emacs-wiki-journal-add-entry-auto' gets rid of the
52 ;; prompt completely. It assumes the category is the first word and
53 ;; the title is the rest of the words on that line.
55 ;; Sometimes you do not want to save *all* your notes to your journal.
56 ;; `emacs-wiki-journal-add-entry-maybe' is similar to the previous
57 ;; hook but only adds the entry if the first word matches
58 ;; `emacs-wiki-journal-category-regexp'. Thus entries will only be
59 ;; added if the first word starts with Category.
63 ;; (require 'remember-emacs-wiki-journal)
64 ;; (setq remember-all-handler-functions t)
65 ;; (add-to-list 'remember-handler-functions
66 ;; 'remember-emacs-wiki-journal-add-entry-maybe)
68 ;; Now when C-c C-c is pressed in remember mode, it checks to see if
69 ;; the buffer is a journal entry. If it is it is added to the
70 ;; journal. The category is the first word and the title the
71 ;; remaining words of the first line. The first word must match
72 ;; `emacs-wiki-journal-category-regexp'. For example, a remember
73 ;; buffer like this would be added:
75 ;; CategoryMisc Title of entry
80 (require 'emacs-wiki-journal
)
84 (defcustom remember-emacs-wiki-journal-add-hook
'()
85 "Functions to run after something has been added to the journal.
86 Buffer will be narrowed to the current entry."
90 ;;;_* Internal Functions
92 ;; From remember-planner.el
93 (defun remember-emacs-wiki-journal-add (category heading
)
94 "Remember this text to WikiJournal under category with heading"
95 (require 'emacs-wiki-journal
)
96 (set-buffer (get-buffer-create remember-buffer
))
97 (let ((text (buffer-string))
99 (save-window-excursion
100 (emacs-wiki-journal-add category heading
)
101 (setq start
(planner-line-beginning-position))
104 (narrow-to-region start
(point))
107 (save-window-excursion
111 remember-emacs-wiki-journal-add-hook
))
112 (when remember-save-after-remembering
119 (defun remember-emacs-wiki-journal-add-entry ()
120 "Prompt for category and heading and add entry."
121 (let ((category (emacs-wiki-journal-prompt-for-category-wiki))
122 (heading (read-from-minibuffer "Journal Heading: ")))
123 (remember-emacs-wiki-journal-add category heading
)))
126 (defun remember-emacs-wiki-journal-add-entry-auto ()
127 "Add entry where the category is the first word and the heading the
128 rest of the words on the first line."
129 (set-buffer (get-buffer-create remember-buffer
))
130 (goto-char (point-min))
131 (let* ((text (buffer-string))
132 (split-first-line (split-string (thing-at-point 'line
)))
133 (category (car split-first-line
))
134 (heading (mapconcat 'concat
135 (cdr split-first-line
)
137 (narrow-to-region (planner-line-beginning-position 2)
139 (remember-emacs-wiki-journal-add category heading
)
144 (defun remember-emacs-wiki-journal-add-entry-maybe ()
145 "Like `remember-emacs-wiki-journal-add-entry-auto' but only adds
146 entry if the first line matches `emacs-wiki-journal-category-regexp'."
147 (set-buffer (get-buffer-create remember-buffer
))
148 (goto-char (point-min))
149 (when (string-match emacs-wiki-journal-category-regexp
150 (thing-at-point 'line
))
151 (remember-emacs-wiki-journal-add-entry-auto)))
154 (custom-add-option 'remember-handler-functions
155 'remember-emacs-wiki-journal-add-entry
)
156 (custom-add-option 'remember-handler-functions
157 'remember-emacs-wiki-journal-add-entry-auto
)
158 (custom-add-option 'remember-handler-functions
159 'remember-emacs-wiki-journal-add-entry-maybe
)
161 (provide 'remember-emacs-wiki-journal
)
163 ;;;_* Local Emacs Vars.
165 ;; allout-layout: (* 0 : )
168 ;;; remember-emacs-wiki-journal.el ends here