Mercurial > emacs
annotate lisp/calendar/todo-mode.el @ 19102:b605b8dbb880
Cleaned up variables, prefix and cursor position.
author | Oliver Seidel <os10000@seidel-space.de> |
---|---|
date | Sun, 03 Aug 1997 12:47:26 +0000 |
parents | 31ba6200863a |
children | 96a5705f73d5 |
rev | line source |
---|---|
19100 | 1 ;; todomode.el -- major mode for editing Todo-List files |
2 | |
3 ;; --------------------------------------------------------------------------- | |
4 | |
5 ;; Note: You may copy this file freely for non-commercial use; otherwise, | |
6 ;; please contact (address) O Seidel, Lessingstr 8, Eschborn, FRG | |
7 ;; (e-mail ) Oliver.Seidel@cl.cam.ac.uk (2 Aug 1997) | |
8 | |
19102
b605b8dbb880
Cleaned up variables, prefix and cursor position.
Oliver Seidel <os10000@seidel-space.de>
parents:
19101
diff
changeset
|
9 ;; $Id: todomode.el,v 1.2 1997/08/03 12:15:28 os10000 Exp os10000 $ |
19100 | 10 ;; |
19101
31ba6200863a
It appears to work.
Oliver Seidel <os10000@seidel-space.de>
parents:
19100
diff
changeset
|
11 ;; $Log: todomode.el,v $ |
19102
b605b8dbb880
Cleaned up variables, prefix and cursor position.
Oliver Seidel <os10000@seidel-space.de>
parents:
19101
diff
changeset
|
12 ;; Revision 1.2 1997/08/03 12:15:28 os10000 |
b605b8dbb880
Cleaned up variables, prefix and cursor position.
Oliver Seidel <os10000@seidel-space.de>
parents:
19101
diff
changeset
|
13 ;; It appears to work. |
b605b8dbb880
Cleaned up variables, prefix and cursor position.
Oliver Seidel <os10000@seidel-space.de>
parents:
19101
diff
changeset
|
14 ;; |
19101
31ba6200863a
It appears to work.
Oliver Seidel <os10000@seidel-space.de>
parents:
19100
diff
changeset
|
15 ;; Revision 1.1 1997/08/03 12:15:13 os10000 |
31ba6200863a
It appears to work.
Oliver Seidel <os10000@seidel-space.de>
parents:
19100
diff
changeset
|
16 ;; Initial revision |
19100 | 17 ;; |
18 | |
19 ;; --------------------------------------------------------------------------- | |
20 | |
19102
b605b8dbb880
Cleaned up variables, prefix and cursor position.
Oliver Seidel <os10000@seidel-space.de>
parents:
19101
diff
changeset
|
21 ;; Description: |
b605b8dbb880
Cleaned up variables, prefix and cursor position.
Oliver Seidel <os10000@seidel-space.de>
parents:
19101
diff
changeset
|
22 ;; |
b605b8dbb880
Cleaned up variables, prefix and cursor position.
Oliver Seidel <os10000@seidel-space.de>
parents:
19101
diff
changeset
|
23 ;; To get this to work, make emacs execute the line "(require 'todomode)" |
b605b8dbb880
Cleaned up variables, prefix and cursor position.
Oliver Seidel <os10000@seidel-space.de>
parents:
19101
diff
changeset
|
24 ;; and maybe initialise the variables below on startup. |
b605b8dbb880
Cleaned up variables, prefix and cursor position.
Oliver Seidel <os10000@seidel-space.de>
parents:
19101
diff
changeset
|
25 ;; |
b605b8dbb880
Cleaned up variables, prefix and cursor position.
Oliver Seidel <os10000@seidel-space.de>
parents:
19101
diff
changeset
|
26 ;; Then you have the following facilities available: |
b605b8dbb880
Cleaned up variables, prefix and cursor position.
Oliver Seidel <os10000@seidel-space.de>
parents:
19101
diff
changeset
|
27 ;; |
b605b8dbb880
Cleaned up variables, prefix and cursor position.
Oliver Seidel <os10000@seidel-space.de>
parents:
19101
diff
changeset
|
28 ;; M-x todo-mode will enter the todo list screen, here type |
b605b8dbb880
Cleaned up variables, prefix and cursor position.
Oliver Seidel <os10000@seidel-space.de>
parents:
19101
diff
changeset
|
29 ;; p for the previous entry |
b605b8dbb880
Cleaned up variables, prefix and cursor position.
Oliver Seidel <os10000@seidel-space.de>
parents:
19101
diff
changeset
|
30 ;; n for the next entry |
b605b8dbb880
Cleaned up variables, prefix and cursor position.
Oliver Seidel <os10000@seidel-space.de>
parents:
19101
diff
changeset
|
31 ;; q to save the list and exit the buffer |
b605b8dbb880
Cleaned up variables, prefix and cursor position.
Oliver Seidel <os10000@seidel-space.de>
parents:
19101
diff
changeset
|
32 ;; e to edit the current entry |
b605b8dbb880
Cleaned up variables, prefix and cursor position.
Oliver Seidel <os10000@seidel-space.de>
parents:
19101
diff
changeset
|
33 ;; i to insert a new entry |
b605b8dbb880
Cleaned up variables, prefix and cursor position.
Oliver Seidel <os10000@seidel-space.de>
parents:
19101
diff
changeset
|
34 ;; k to kill the current entry |
b605b8dbb880
Cleaned up variables, prefix and cursor position.
Oliver Seidel <os10000@seidel-space.de>
parents:
19101
diff
changeset
|
35 ;; f to file the current entry, including a |
b605b8dbb880
Cleaned up variables, prefix and cursor position.
Oliver Seidel <os10000@seidel-space.de>
parents:
19101
diff
changeset
|
36 ;; comment and timestamp |
b605b8dbb880
Cleaned up variables, prefix and cursor position.
Oliver Seidel <os10000@seidel-space.de>
parents:
19101
diff
changeset
|
37 ;; |
b605b8dbb880
Cleaned up variables, prefix and cursor position.
Oliver Seidel <os10000@seidel-space.de>
parents:
19101
diff
changeset
|
38 ;; I would recommend to add the following bindings to your global keymap: |
b605b8dbb880
Cleaned up variables, prefix and cursor position.
Oliver Seidel <os10000@seidel-space.de>
parents:
19101
diff
changeset
|
39 ;; |
b605b8dbb880
Cleaned up variables, prefix and cursor position.
Oliver Seidel <os10000@seidel-space.de>
parents:
19101
diff
changeset
|
40 ;; (global-set-key "\C-ct" 'todo-mode) |
b605b8dbb880
Cleaned up variables, prefix and cursor position.
Oliver Seidel <os10000@seidel-space.de>
parents:
19101
diff
changeset
|
41 ;; (global-set-key "\C-ci" 'todo-cmd-inst) |
b605b8dbb880
Cleaned up variables, prefix and cursor position.
Oliver Seidel <os10000@seidel-space.de>
parents:
19101
diff
changeset
|
42 ;; |
b605b8dbb880
Cleaned up variables, prefix and cursor position.
Oliver Seidel <os10000@seidel-space.de>
parents:
19101
diff
changeset
|
43 ;; This will enable you to quickly find the todo-list, or to simply add an |
b605b8dbb880
Cleaned up variables, prefix and cursor position.
Oliver Seidel <os10000@seidel-space.de>
parents:
19101
diff
changeset
|
44 ;; entry, without changing to it and getting sidetracked from your current |
b605b8dbb880
Cleaned up variables, prefix and cursor position.
Oliver Seidel <os10000@seidel-space.de>
parents:
19101
diff
changeset
|
45 ;; project. |
b605b8dbb880
Cleaned up variables, prefix and cursor position.
Oliver Seidel <os10000@seidel-space.de>
parents:
19101
diff
changeset
|
46 ;; |
b605b8dbb880
Cleaned up variables, prefix and cursor position.
Oliver Seidel <os10000@seidel-space.de>
parents:
19101
diff
changeset
|
47 ;; I would also recommend that you execute the command |
b605b8dbb880
Cleaned up variables, prefix and cursor position.
Oliver Seidel <os10000@seidel-space.de>
parents:
19101
diff
changeset
|
48 ;; |
b605b8dbb880
Cleaned up variables, prefix and cursor position.
Oliver Seidel <os10000@seidel-space.de>
parents:
19101
diff
changeset
|
49 ;; (setq todo-prefix "*/* ") |
b605b8dbb880
Cleaned up variables, prefix and cursor position.
Oliver Seidel <os10000@seidel-space.de>
parents:
19101
diff
changeset
|
50 ;; |
b605b8dbb880
Cleaned up variables, prefix and cursor position.
Oliver Seidel <os10000@seidel-space.de>
parents:
19101
diff
changeset
|
51 ;; to have all your entries prefixed in such a way that the diary displays |
b605b8dbb880
Cleaned up variables, prefix and cursor position.
Oliver Seidel <os10000@seidel-space.de>
parents:
19101
diff
changeset
|
52 ;; them every day. |
b605b8dbb880
Cleaned up variables, prefix and cursor position.
Oliver Seidel <os10000@seidel-space.de>
parents:
19101
diff
changeset
|
53 |
b605b8dbb880
Cleaned up variables, prefix and cursor position.
Oliver Seidel <os10000@seidel-space.de>
parents:
19101
diff
changeset
|
54 ;; --------------------------------------------------------------------------- |
b605b8dbb880
Cleaned up variables, prefix and cursor position.
Oliver Seidel <os10000@seidel-space.de>
parents:
19101
diff
changeset
|
55 |
19100 | 56 ;; User-configurable variables: |
57 | |
19102
b605b8dbb880
Cleaned up variables, prefix and cursor position.
Oliver Seidel <os10000@seidel-space.de>
parents:
19101
diff
changeset
|
58 (defvar todo-prefix "" "TODO mode prefix when creating entries") |
b605b8dbb880
Cleaned up variables, prefix and cursor position.
Oliver Seidel <os10000@seidel-space.de>
parents:
19101
diff
changeset
|
59 (defvar todo-file-do "~/.todo-do" "TODO mode filename of list file") |
19100 | 60 (defvar todo-file-done "~/.todo-done" "TODO mode filename of archive file") |
61 (defvar todo-mode-hook nil "Hooks invoked when the *TODO* buffer is created.") | |
62 | |
63 ;; --------------------------------------------------------------------------- | |
64 | |
65 (require 'time-stamp) | |
66 | |
67 (defvar todo-begin (point-min) "TODO mode beginning of line") | |
68 (defvar todo-end (point-min) "TODO mode end of line") | |
69 | |
70 (setq todo-mode-map (make-keymap)) | |
71 (suppress-keymap todo-mode-map) | |
72 (define-key todo-mode-map "p" 'todo-cmd-prev) | |
73 (define-key todo-mode-map "n" 'todo-cmd-next) | |
74 (define-key todo-mode-map "q" 'todo-cmd-done) | |
75 (define-key todo-mode-map "e" 'todo-cmd-edit) | |
76 (define-key todo-mode-map "i" 'todo-cmd-inst) | |
77 (define-key todo-mode-map "k" 'todo-cmd-kill) | |
78 (define-key todo-mode-map "f" 'todo-cmd-file) | |
79 | |
80 (defun todo-cmd-prev () "Select previous entry." | |
81 (interactive) | |
82 (forward-line -1) | |
83 (beginning-of-line nil) | |
84 (message "") | |
85 ) | |
86 | |
87 (defun todo-cmd-next () "Select next entry." | |
88 (interactive) | |
89 (forward-line 1) | |
90 (beginning-of-line nil) | |
91 (message "") | |
92 ) | |
93 | |
94 (defun todo-cmd-done () "Done with todo list for now." | |
95 (interactive) | |
19102
b605b8dbb880
Cleaned up variables, prefix and cursor position.
Oliver Seidel <os10000@seidel-space.de>
parents:
19101
diff
changeset
|
96 (beginning-of-line nil) |
b605b8dbb880
Cleaned up variables, prefix and cursor position.
Oliver Seidel <os10000@seidel-space.de>
parents:
19101
diff
changeset
|
97 (message "") |
19100 | 98 (save-buffer) |
99 (bury-buffer) | |
100 ) | |
101 | |
102 (defun todo-line () "Find current line in buffer." | |
103 (end-of-line nil) (setq todo-end (point)) | |
104 (beginning-of-line nil) (setq todo-begin (point)) | |
105 (buffer-substring todo-begin todo-end) | |
106 ) | |
107 | |
108 (defun todo-cmd-edit () "Edit current todo list entry." | |
109 (interactive) | |
110 (setq todo-entry (todo-line)) | |
111 (delete-region todo-begin todo-end) | |
112 (insert (read-from-minibuffer "Edit: " todo-entry)) | |
113 (beginning-of-line nil) | |
114 (message "") | |
115 ) | |
116 | |
117 (defvar todo-prv-lne 0 "previous line that I asked about.") | |
118 (defvar todo-prv-ans 0 "previous answer that I got.") | |
119 | |
120 (defun todo-ask (lne) "Ask whether entry is more important than at LNE." | |
121 (if (not (equal todo-prv-lne lne) ) | |
122 (progn | |
123 (setq todo-prv-lne lne) | |
124 (goto-line todo-prv-lne) | |
125 (setq todo-prv-ans (y-or-n-p (concat "More important than '" (todo-line) "'? "))) | |
126 ) | |
127 ) | |
128 todo-prv-ans | |
129 ) | |
130 | |
131 (defun todo-cmd-inst () "Insert new todo list entry." | |
132 (interactive) | |
19102
b605b8dbb880
Cleaned up variables, prefix and cursor position.
Oliver Seidel <os10000@seidel-space.de>
parents:
19101
diff
changeset
|
133 (beginning-of-line nil) |
b605b8dbb880
Cleaned up variables, prefix and cursor position.
Oliver Seidel <os10000@seidel-space.de>
parents:
19101
diff
changeset
|
134 (setq todo-entry (concat "*/* " (read-from-minibuffer "New TODO entry: "))) |
19100 | 135 (save-window-excursion |
136 (find-file todo-file-do) | |
137 (setq todo-prv-lne 0) | |
138 (let* ((todo-fst 1) | |
139 (todo-lst (+ 1 (count-lines (point-min) (point-max))))) | |
140 (while (< todo-fst todo-lst) | |
141 (setq todo-cur (/ (+ todo-fst todo-lst) 2)) | |
142 (setq todo-ans (if (< todo-cur todo-lst) (todo-ask todo-cur) nil)) | |
143 (if todo-ans | |
144 (setq todo-lst todo-cur) | |
145 (setq todo-fst (+ todo-cur 1))) | |
146 ) | |
147 (goto-line todo-fst) | |
148 ) | |
149 (insert (concat todo-entry "\n")) | |
150 (forward-char -1) | |
151 ) | |
152 (beginning-of-line nil) | |
153 (message "") | |
154 ) | |
155 | |
156 (defun todo-cmd-kill () "Delete current todo list entry." | |
157 (interactive) | |
158 (if (> (count-lines (point-min) (point-max)) 0) | |
159 (progn | |
160 (setq todo-entry (todo-line)) | |
161 (setq todo-answer (y-or-n-p (concat "Permanently remove '" todo-entry "'? "))) | |
162 (if todo-answer (progn (delete-region todo-begin (+ 1 todo-end)) (forward-char -1))) | |
163 ) | |
164 (message "No entry to delete.") | |
165 ) | |
166 (beginning-of-line nil) | |
167 (message "") | |
168 ) | |
169 | |
170 (defun todo-cmd-file () "File away the current todo list entry." | |
171 (interactive) | |
172 (if (> (count-lines (point-min) (point-max)) 0) | |
173 (progn | |
174 (setq time-stamp-format " %2d, %y, %02I:%02M%p %b") | |
175 (setq tmp (time-stamp-string)) | |
176 (beginning-of-line nil) | |
177 (insert (concat (substring tmp 19 22) (substring tmp 0 19))) | |
178 (end-of-line nil) | |
179 (insert (concat " (" (read-from-minibuffer "Comment: ") ")")) | |
180 (todo-line) | |
181 (append-to-file todo-begin (+ 1 todo-end) todo-file-done) | |
182 (delete-region todo-begin (+ 1 todo-end)) | |
183 (forward-char -1) | |
184 ) | |
185 (message "No entry to delete.") | |
186 ) | |
187 (beginning-of-line nil) | |
188 (message "") | |
189 ) | |
190 | |
191 ;; --------------------------------------------------------------------------- | |
192 | |
193 (defun todo-mode () | |
194 "Major mode for editing TODO lists.\n\n\\{todo-mode-map}" | |
195 (interactive) | |
196 (find-file todo-file-do) | |
197 (setq major-mode 'todo-mode) | |
198 (setq mode-name "TODO") | |
199 (use-local-map todo-mode-map) | |
19102
b605b8dbb880
Cleaned up variables, prefix and cursor position.
Oliver Seidel <os10000@seidel-space.de>
parents:
19101
diff
changeset
|
200 (beginning-of-line nil) |
19100 | 201 (run-hooks 'todo-mode-hook) ) |
202 | |
203 (provide 'todomode) | |
204 | |
205 ;; --------------------------------------------------------------------------- | |
206 | |
207 ;;; todomode.el ends here | |
208 | |
209 ;; --------------------------------------------------------------------------- |