aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOliver Seidel1997-08-19 14:00:36 +0000
committerOliver Seidel1997-08-19 14:00:36 +0000
commit7c896f63d6ecc5666ed63cd4d3c452e285dc7ee7 (patch)
tree28629f31b3310b96865a3c7854175f876ef08763
parentda30bf98df0d322e597b2bee1dc0ff747dbe8f82 (diff)
downloademacs-7c896f63d6ecc5666ed63cd4d3c452e285dc7ee7.tar.gz
emacs-7c896f63d6ecc5666ed63cd4d3c452e285dc7ee7.zip
- changed name to todo-mode
- fixed menu descriptions - fixed "pressing abort while filing" - attempted Emacs Lisp Manual *Tips* section compliance
-rw-r--r--lisp/calendar/todo-mode.el177
1 files changed, 113 insertions, 64 deletions
diff --git a/lisp/calendar/todo-mode.el b/lisp/calendar/todo-mode.el
index 5f413b348c1..5cf9e2bec4f 100644
--- a/lisp/calendar/todo-mode.el
+++ b/lisp/calendar/todo-mode.el
@@ -1,53 +1,76 @@
1;;; todomode.el -- Major mode for editing TODO list files 1;;; todo-mode.el -- Major mode for editing TODO list files
2;;; Copyright (C) 1997 by Oliver Seidel
3 2
4;; --------------------------------------------------------------------------- 3;; Copyright (C) 1997 Free Software Foundation, Inc.
5 4
6;; 5;; Author: Oliver.Seidel@cl.cam.ac.uk (was valid on Aug 2, 1997)
7;; Author: Oliver.Seidel@cl.cam.ac.uk (was valid on Aug 2, 1997) 6;; Created: 2 Aug 1997
8;; Created: August 2, 1997 7;; Version: $Id:$
9;; Version: $Id: todomode.el,v 1.11 1997/08/06 09:14:25 os10000 Exp os10000 $ 8;; Keywords: Categorised TODO list editor, todo-mode
10;; Keywords: Categorised TODO list editor, todo-mode
11;; Availability: newsgroup "gnu.emacs.sources" and archives thereof
12;;
13 9
14;; --------------------------------------------------------------------------- 10;; This file is part of GNU Emacs.
15 11
16;; 12;; GNU Emacs is free software; you can redistribute it and/or modify
17;; This program is intended for use with GNU Emacs.
18;;
19;; This program is free software; you can redistribute it and/or modify
20;; it under the terms of the GNU General Public License as published by 13;; it under the terms of the GNU General Public License as published by
21;; the Free Software Foundation; either version 2, or (at your option) 14;; the Free Software Foundation; either version 2, or (at your option)
22;; any later version. 15;; any later version.
23;; 16
24;; This program is distributed in the hope that it will be useful, 17;; GNU Emacs is distributed in the hope that it will be useful,
25;; but WITHOUT ANY WARRANTY; without even the implied warranty of 18;; but WITHOUT ANY WARRANTY; without even the implied warranty of
26;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27;; GNU General Public License for more details. 20;; GNU General Public License for more details.
28;; 21
29;; You should have received a copy of the GNU General Public License 22;; You should have received a copy of the GNU General Public License
30;; along with GNU Emacs; see the file COPYING. If not, write to the 23;; along with GNU Emacs; see the file COPYING. If not, write to the
31;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, 24;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
32;; Boston, MA 02111-1307, USA. 25;; Boston, MA 02111-1307, USA.
33;;
34 26
35;; --------------------------------------------------------------------------- 27;; ---------------------------------------------------------------------------
36 28
37;; 29;;; Commentary:
30
38;; Quickstart Installation: 31;; Quickstart Installation:
39;; ======================== 32;; ========================
40;; 33;;
41;; To get this to work, make emacs execute the line 34;; To get this to work, make emacs execute the line
42;; 35;;
43;; (require 'todomode) ;; load the TODO package 36;; (require 'todo-mode) ;; load the TODO package
44;; 37;;
45;; I would also recommend executing the following commands 38;; You may now enter new items by typing "M-x todo-cmd-inst", or enter
46;; so as to extend the bindings in your global keymap: 39;; your the TODO list file by typing "M-x todo-show".
40;;
41;; The TODO list file has a special format and some auxiliary information,
42;; which will be added by the todo-show function if it attempts to visit
43;; an un-initialised file. Hence it is recommended to use the todo-show
44;; function for the first time, in order to initialise the file, but it
45;; is not necessary afterwards.
46;;
47;; As these commands are quite long to type, I would recommend the addition
48;; of two bindings to your to your global keymap. I personally have the
49;; following in my initialisation file:
47;; 50;;
48;; (global-set-key "\C-ct" 'todo-show) ;; switch to TODO buffer 51;; (global-set-key "\C-ct" 'todo-show) ;; switch to TODO buffer
49;; (global-set-key "\C-ci" 'todo-cmd-inst) ;; insert new item 52;; (global-set-key "\C-ci" 'todo-cmd-inst) ;; insert new item
50;; 53;;
54;; Note, however, that this recommendation has prompted some criticism,
55;; since the keys C-c LETTER are reserved for user functions. I believe
56;; my recommendation is acceptable, since the Emacs Lisp Manual *Tips*
57;; section also details that the mode itself should not bind any functions
58;; to those keys. The express aim of the above two bindings is to work
59;; outside the mode, which doesn't need the show function and offers
60;; a different binding for the insert function. They serve as shortcuts
61;; and are not even needed (since the TODO mode will be entered by
62;; visiting the TODO file, and later by switching to its buffer).
63;;
64;;
65;;
66;; Pre-Requisites
67;; ==============
68;;
69;; This package will require the following packages to be available on
70;; the load-path:
71;; - time-stamp
72;; - easymenu
73;;
51;; 74;;
52;; 75;;
53;; Description: 76;; Description:
@@ -152,12 +175,28 @@
152;; If you set the threshhold to i.e. 8, it will stop as soon as the window 175;; If you set the threshhold to i.e. 8, it will stop as soon as the window
153;; size drops below that amount and will insert the item in the approximate 176;; size drops below that amount and will insert the item in the approximate
154;; centre of that window. I got the idea for this feature after reading 177;; centre of that window. I got the idea for this feature after reading
155;; a very helpful e-mail reply from Trey Jackson <tjackson@ichips.intel.com> 178;; a very helpful e-mail reply from Trey Jackson <trey@cs.berkeley.edu>
156;; who corrected some of my awful coding and pointed me towards some good 179;; who corrected some of my awful coding and pointed me towards some good
157;; reading. Thanks Trey! 180;; reading. Thanks Trey!
158;; 181;;
159;; 182;;
160;; 183;;
184;;
185;; Things to do:
186;; =============
187;;
188;; - licence / version function
189;; - export to diary file
190;; - todo-report-bug
191;; - GNATS support
192;; - add idea from Urban Boquist <boquist@cs.chalmers.se>: multi-line-entries
193;; - 'e' opens buffer for multi-line entry
194;; - elide multiline
195;; - rewrite complete package to store data as lisp objects and have
196;; display modes for display, for diary export, etc.
197;;
198;;
199;;
161;; History and Gossip: 200;; History and Gossip:
162;; =================== 201;; ===================
163;; 202;;
@@ -165,14 +204,6 @@
165;; package! I hope I have listed all of you somewhere in the documentation 204;; package! I hope I have listed all of you somewhere in the documentation
166;; or at least in the RCS history! 205;; or at least in the RCS history!
167;; 206;;
168;; Just for the case that you are wondering about the ugly name of this
169;; package: I am one of those unfortunate people who have DOS, LINUX and
170;; OS/2 on one of their computers, so part of my home-filespace is shared
171;; and stored on a DOS partition, which is accessible to all systems. If
172;; you wish, you can of course rename the name of the file (and the "provide"
173;; command near the end of this package) to something more aisthetically
174;; (please don't argue about this spelling ...) pleasing, like i.e. todo-mode.
175;;
176;; Enjoy this package and express your gratitude by sending nice things 207;; Enjoy this package and express your gratitude by sending nice things
177;; to my parents' address! 208;; to my parents' address!
178;; 209;;
@@ -183,8 +214,14 @@
183 214
184;; --------------------------------------------------------------------------- 215;; ---------------------------------------------------------------------------
185 216
217;; ---------------------------------------------------------------------------
218
219;;; Change Log:
220
221;; $Log: todo-mode.el,v $
222;; Revision 1.12 1997/08/06 10:56:15 os10000
223;; Fixed header, typos, layout, documentation.
186;; 224;;
187;; $Log: todomode.el,v $
188;; Revision 1.11 1997/08/06 09:14:25 os10000 225;; Revision 1.11 1997/08/06 09:14:25 os10000
189;; Applied patch from Istvan Marko <istvan@cmdmail.amd.com> 226;; Applied patch from Istvan Marko <istvan@cmdmail.amd.com>
190;; to make menus work anywhere. 227;; to make menus work anywhere.
@@ -199,11 +236,11 @@
199;; rest of the Emacs distribution files. 236;; rest of the Emacs distribution files.
200;; 237;;
201;; Revision 1.8 1997/08/05 22:39:04 os10000 238;; Revision 1.8 1997/08/05 22:39:04 os10000
202;; Made todomode.el available under GPL. 239;; Made todo-mode.el available under GPL.
203;; 240;;
204;; Revision 1.7 1997/08/05 22:34:14 os10000 241;; Revision 1.7 1997/08/05 22:34:14 os10000
205;; Fixed insertion routine with help from Trey Jackson 242;; Fixed insertion routine with help from Trey Jackson
206;; <tjackson@ichips.intel.com>; added todo-ins-thresh; 243;; <trey@cs.berkeley.edu>; added todo-ins-thresh;
207;; fixed keyboard layout to remove unwanted keys. 244;; fixed keyboard layout to remove unwanted keys.
208;; 245;;
209;; Revision 1.6 1997/08/05 16:47:01 os10000 246;; Revision 1.6 1997/08/05 16:47:01 os10000
@@ -229,6 +266,8 @@
229 266
230;; --------------------------------------------------------------------------- 267;; ---------------------------------------------------------------------------
231 268
269;;; Code:
270
232;; User-configurable variables: 271;; User-configurable variables:
233 272
234(defvar todo-prefix "*/*" "TODO mode prefix for entries.") 273(defvar todo-prefix "*/*" "TODO mode prefix for entries.")
@@ -237,6 +276,14 @@
237(defvar todo-mode-hook nil "TODO mode hooks.") 276(defvar todo-mode-hook nil "TODO mode hooks.")
238(defvar todo-ins-thresh 0 "TODO mode insertion accuracy.") 277(defvar todo-ins-thresh 0 "TODO mode insertion accuracy.")
239 278
279
280;; Thanks for the ISO time stamp format go to Karl Eichwalder <ke@suse.de>
281;; My format string for the appt.el package is "%3b %2d, %y, %02I:%02M%p".
282;;
283(defvar todo-time-string-format "%y-%02m-%02d %02H:%02M"
284 "TODO mode time string format for done entries.
285For details see the variable `time-stamp-format'.")
286
240;; --------------------------------------------------------------------------- 287;; ---------------------------------------------------------------------------
241 288
242;; Get some outside help ... 289;; Get some outside help ...
@@ -382,7 +429,7 @@
382 (while (> (- todo-lst todo-fst) todo-ins-thresh) 429 (while (> (- todo-lst todo-fst) todo-ins-thresh)
383 (let* ((todo-cur (/ (+ todo-fst todo-lst) 2)) 430 (let* ((todo-cur (/ (+ todo-fst todo-lst) 2))
384 (todo-ans (if (< todo-cur todo-lst) 431 (todo-ans (if (< todo-cur todo-lst)
385 (todo-ask todo-cur) nil))) 432 (todo-ask-p todo-cur) nil)))
386 (if todo-ans 433 (if todo-ans
387 (setq todo-lst todo-cur) 434 (setq todo-lst todo-cur)
388 (setq todo-fst (+ todo-cur 1))))) 435 (setq todo-fst (+ todo-cur 1)))))
@@ -395,9 +442,10 @@
395 (insert (concat todo-entry "\n")) 442 (insert (concat todo-entry "\n"))
396 (forward-line -1)) 443 (forward-line -1))
397 (beginning-of-line nil) 444 (beginning-of-line nil)
445 (save-buffer)
398 (message ""))) 446 (message "")))
399 447
400(defun todo-ask (lne) 448(defun todo-ask-p (lne)
401 "Ask whether entry is more important than at LNE." 449 "Ask whether entry is more important than at LNE."
402 (if (not (equal todo-prv-lne lne)) 450 (if (not (equal todo-prv-lne lne))
403 (progn 451 (progn
@@ -421,7 +469,7 @@
421 (delete-region (point-at-bol) (+ 1 (point-at-eol))) 469 (delete-region (point-at-bol) (+ 1 (point-at-eol)))
422 (forward-line -1)))) 470 (forward-line -1))))
423 (message "")) 471 (message ""))
424 (message "No TODO list entry to delete.")) 472 (error "No TODO list entry to delete"))
425 (beginning-of-line nil)) 473 (beginning-of-line nil))
426 474
427(defun todo-cmd-rais () "Raise priority of current entry." 475(defun todo-cmd-rais () "Raise priority of current entry."
@@ -434,7 +482,7 @@
434 (insert (concat todo-entry "\n")) 482 (insert (concat todo-entry "\n"))
435 (forward-line -1) 483 (forward-line -1)
436 (message "")) 484 (message ""))
437 (message "No TODO list entry to raise.")) 485 (error "No TODO list entry to raise"))
438 (beginning-of-line nil)) 486 (beginning-of-line nil))
439 487
440(defun todo-cmd-lowr () "Lower priority of current entry." 488(defun todo-cmd-lowr () "Lower priority of current entry."
@@ -447,24 +495,25 @@
447 (insert (concat todo-entry "\n")) 495 (insert (concat todo-entry "\n"))
448 (forward-line -1) 496 (forward-line -1)
449 (message "")) 497 (message ""))
450 (message "No TODO list entry to raise.")) 498 (error "No TODO list entry to lower"))
451 (beginning-of-line nil)) 499 (beginning-of-line nil))
452 500
453(defun todo-cmd-file () "File away the current TODO list entry." 501(defun todo-cmd-file () "File away the current TODO list entry."
454 (interactive) 502 (interactive)
455 (if (> (count-lines (point-min) (point-max)) 0) 503 (if (> (count-lines (point-min) (point-max)) 0)
456 (progn 504 (progn
457 (let ((time-stamp-format "%3b %2d, %y, %02I:%02M%p")) 505 (let ((todo-comment (read-from-minibuffer "Comment: "))
506 (time-stamp-format todo-time-string-format))
458 (beginning-of-line nil) 507 (beginning-of-line nil)
459 (delete-region (point-at-bol) (search-forward todo-prefix)) 508 (delete-region (point-at-bol) (search-forward todo-prefix))
460 (insert (time-stamp-string)) 509 (insert (time-stamp-string))
461 (end-of-line nil) 510 (end-of-line nil)
462 (insert (concat " (" (read-from-minibuffer "Comment: ") ")")) 511 (insert (concat " (" todo-comment ")"))
463 (append-to-file (point-at-bol) (+ 1 (point-at-eol)) todo-file-done) 512 (append-to-file (point-at-bol) (+ 1 (point-at-eol)) todo-file-done)
464 (delete-region (point-at-bol) (+ 1 (point-at-eol))) 513 (delete-region (point-at-bol) (+ 1 (point-at-eol)))
465 (forward-line -1)) 514 (forward-line -1))
466 (message "")) 515 (message ""))
467 (message "No TODO list entry to delete.")) 516 (error "No TODO list entry to file away"))
468 (beginning-of-line nil)) 517 (beginning-of-line nil))
469 518
470;; --------------------------------------------------------------------------- 519;; ---------------------------------------------------------------------------
@@ -486,25 +535,25 @@
486;; --------------------------------------------------------------------------- 535;; ---------------------------------------------------------------------------
487 536
488(easy-menu-define todo-menu todo-mode-map "Todo Menu" 537(easy-menu-define todo-menu todo-mode-map "Todo Menu"
489 '("Todo" 538 '("Todo"
490 ["Forward item" todo-cmd-forw t] 539 ["Next category" todo-cmd-forw t]
491 ["Backward item" todo-cmd-back t] 540 ["Previous category" todo-cmd-back t]
492 "---" 541 "---"
493 ["Edit item" todo-cmd-edit t] 542 ["Edit item" todo-cmd-edit t]
494 ["File item" todo-cmd-file t] 543 ["File item" todo-cmd-file t]
495 ["Insert new item" todo-cmd-inst t] 544 ["Insert new item" todo-cmd-inst t]
496 ["Kill item" todo-cmd-kill t] 545 ["Kill item" todo-cmd-kill t]
497 "---" 546 "---"
498 ["Lower item priority" todo-cmd-lowr t] 547 ["Lower item priority" todo-cmd-lowr t]
499 ["Raise item priority" todo-cmd-rais t] 548 ["Raise item priority" todo-cmd-rais t]
500 "---" 549 "---"
501 ["Next item" todo-cmd-next t] 550 ["Next item" todo-cmd-next t]
502 ["Previous item" todo-cmd-prev t] 551 ["Previous item" todo-cmd-prev t]
503 "---" 552 "---"
504 ["Save" todo-cmd-save t] 553 ["Save" todo-cmd-save t]
505 "---" 554 "---"
506 ["Quit" todo-cmd-done t] 555 ["Quit" todo-cmd-done t]
507 )) 556 ))
508 557
509(defun todo-mode () "Major mode for editing TODO lists.\n\n\\{todo-mode-map}" 558(defun todo-mode () "Major mode for editing TODO lists.\n\n\\{todo-mode-map}"
510 (interactive) 559 (interactive)
@@ -535,10 +584,10 @@
535 (beginning-of-line nil) 584 (beginning-of-line nil)
536 (todo-cat-slct)) 585 (todo-cat-slct))
537 586
538(provide 'todomode) 587(provide 'todo-mode)
539 588
540;; --------------------------------------------------------------------------- 589;; ---------------------------------------------------------------------------
541 590
542;; todomode.el ends here 591;;; todo-mode.el ends here
543 592
544;; --------------------------------------------------------------------------- 593;; ---------------------------------------------------------------------------