Mercurial > emacs
comparison lisp/calendar/todo-mode.el @ 20173:0044ff755ee7
Added three suggestions from Carsten
Dominik <dominik@strw.LeidenUniv.nl>:
- recommend autoloading instead of require
- inserting from different buffer didn't work
(now fixed -- I pray)
- provided public entry point to insert items
from normal lisp code
author | Oliver Seidel <os10000@seidel-space.de> |
---|---|
date | Fri, 24 Oct 1997 17:30:54 +0000 |
parents | 14aea7edd810 |
children | bc27487e43bc |
comparison
equal
deleted
inserted
replaced
20172:14aea7edd810 | 20173:0044ff755ee7 |
---|---|
2 | 2 |
3 ;; Copyright (C) 1997 Free Software Foundation, Inc. | 3 ;; Copyright (C) 1997 Free Software Foundation, Inc. |
4 | 4 |
5 ;; Author: Oliver.Seidel@cl.cam.ac.uk (was valid on Aug 2, 1997) | 5 ;; Author: Oliver.Seidel@cl.cam.ac.uk (was valid on Aug 2, 1997) |
6 ;; Created: 2 Aug 1997 | 6 ;; Created: 2 Aug 1997 |
7 ;; Version: $Id: todo-mode.el,v 1.21 1997/10/24 16:51:02 os10000 Exp os10000 $ | 7 ;; Version: $Id: todo-mode.el,v 1.22 1997/10/24 16:53:20 os10000 Exp os10000 $ |
8 ;; Keywords: Categorised TODO list editor, todo-mode | 8 ;; Keywords: Categorised TODO list editor, todo-mode |
9 | 9 |
10 ;; This file is part of GNU Emacs. | 10 ;; This file is part of GNU Emacs. |
11 | 11 |
12 ;; GNU Emacs is free software; you can redistribute it and/or modify | 12 ;; GNU Emacs is free software; you can redistribute it and/or modify |
30 | 30 |
31 ;; Preface, Quickstart Installation | 31 ;; Preface, Quickstart Installation |
32 ;; | 32 ;; |
33 ;; To get this to work, make emacs execute the line | 33 ;; To get this to work, make emacs execute the line |
34 ;; | 34 ;; |
35 ;; (require 'todo-mode) ;; load the TODO package | |
36 ;; | |
37 ;; If you don't like "require", do as Harald Backer prescribes: | |
38 ;; | |
39 ;; "I don't like require statements as they slow down startup | |
40 ;; emacs. As I include .todo-do in diary and start calendar | |
41 ;; at startup of emacs, the mode indicator of .todo-do will | |
42 ;; make emacs fail, unless the following is defined:" | |
43 ;; | |
44 ;; (autoload 'todo-mode "todo-mode" | 35 ;; (autoload 'todo-mode "todo-mode" |
45 ;; "Major mode for editing TODO lists." t) | 36 ;; "Major mode for editing TODO lists." t) |
37 ;; (autoload 'todo-show "todo-mode" | |
38 ;; "Show TODO items." t) | |
39 ;; (autoload 'todo-insert-item "todo-mode" | |
40 ;; "Add TODO item." t) | |
46 ;; | 41 ;; |
47 ;; You may now enter new items by typing "M-x todo-insert-item", | 42 ;; You may now enter new items by typing "M-x todo-insert-item", |
48 ;; or enter your TODO list file by typing "M-x todo-show". | 43 ;; or enter your TODO list file by typing "M-x todo-show". |
49 ;; | 44 ;; |
50 ;; The TODO list file has a special format and some auxiliary | 45 ;; The TODO list file has a special format and some auxiliary |
75 ;; | 70 ;; |
76 ;; Version | 71 ;; Version |
77 ;; | 72 ;; |
78 ;; Which version of todo-mode.el does this documentation refer to? | 73 ;; Which version of todo-mode.el does this documentation refer to? |
79 ;; | 74 ;; |
80 ;; $Id: todo-mode.el,v 1.21 1997/10/24 16:51:02 os10000 Exp os10000 $ | 75 ;; $Id: todo-mode.el,v 1.22 1997/10/24 16:53:20 os10000 Exp os10000 $ |
81 ;; | 76 ;; |
82 ;; Pre-Requisites | 77 ;; Pre-Requisites |
83 ;; | 78 ;; |
84 ;; This package will require the following packages to be | 79 ;; This package will require the following packages to be |
85 ;; available on the load-path: | 80 ;; available on the load-path: |
248 ;; --------------------------------------------------------------------------- | 243 ;; --------------------------------------------------------------------------- |
249 | 244 |
250 ;;; Change Log: | 245 ;;; Change Log: |
251 | 246 |
252 ;; $Log: todo-mode.el,v $ | 247 ;; $Log: todo-mode.el,v $ |
248 ;; Revision 1.22 1997/10/24 16:53:20 os10000 | |
249 ;; Paul Stodghill <stodghil@CS.Cornell.EDU> writes: | |
250 ;; | |
251 ;; When invoked with a prefix, todo-insert-item | |
252 ;; should not prompt for a category. (He adds: | |
253 ;; At least that's what I think.) | |
254 ;; | |
253 ;; Revision 1.21 1997/10/24 16:51:02 os10000 | 255 ;; Revision 1.21 1997/10/24 16:51:02 os10000 |
254 ;; Rafael Laboissiere <rafael@icp.inpg.fr> writes: | 256 ;; Rafael Laboissiere <rafael@icp.inpg.fr> writes: |
255 ;; | 257 ;; |
256 ;; I was just annoyed with the fact that there is no way | 258 ;; I was just annoyed with the fact that there is no way |
257 ;; to dynamically control the insertion accuracy. I mean: | 259 ;; to dynamically control the insertion accuracy. I mean: |
593 todo-category-end | 595 todo-category-end |
594 todo-prefix todo-category-sep))) | 596 todo-prefix todo-category-sep))) |
595 0) | 597 0) |
596 | 598 |
597 ;;;### autoload | 599 ;;;### autoload |
598 (defun todo-insert-item (ARG) | 600 (defun todo-add-item-non-interactively (new-item category) |
599 "Insert new TODO list entry." | 601 "Insert new TODO list entry." |
600 (interactive "P") | 602 (save-excursion |
601 (let* ((new-item (concat todo-prefix " " | 603 (todo-show) |
602 (read-from-minibuffer | |
603 "New TODO entry: " | |
604 (if todo-entry-prefix-function | |
605 (funcall todo-entry-prefix-function))))) | |
606 (categories todo-categories) | |
607 (history (cons 'categories (1+ todo-category-number))) | |
608 (current-category (nth todo-category-number todo-categories)) | |
609 (category | |
610 (if ARG | |
611 current-category | |
612 (completing-read | |
613 (concat "Category [" | |
614 current-category "]: ") | |
615 (todo-category-alist) nil nil nil history)))) | |
616 (if (string= "" category) | 604 (if (string= "" category) |
617 (setq category (nth todo-category-number todo-categories))) | 605 (setq category (nth todo-category-number todo-categories))) |
618 (let ((cat-exists (member category todo-categories))) | 606 (let ((cat-exists (member category todo-categories))) |
619 (setq todo-category-number | 607 (setq todo-category-number |
620 (if cat-exists | 608 (if cat-exists |
640 (beginning-of-line)) | 628 (beginning-of-line)) |
641 (insert new-item "\n") | 629 (insert new-item "\n") |
642 (todo-backward-item) | 630 (todo-backward-item) |
643 (save-buffer) | 631 (save-buffer) |
644 (message ""))) | 632 (message ""))) |
633 | |
634 ;;;### autoload | |
635 (defun todo-insert-item (ARG) | |
636 "Insert new TODO list entry." | |
637 (interactive "P") | |
638 (todo-show) | |
639 (let* ((new-item (concat todo-prefix " " | |
640 (read-from-minibuffer | |
641 "New TODO entry: " | |
642 (if todo-entry-prefix-function | |
643 (funcall todo-entry-prefix-function))))) | |
644 (categories todo-categories) | |
645 (history (cons 'categories (1+ todo-category-number))) | |
646 (current-category (nth todo-category-number todo-categories)) | |
647 (category | |
648 (if ARG | |
649 current-category | |
650 (completing-read | |
651 (concat "Category [" | |
652 current-category "]: ") | |
653 (todo-category-alist) nil nil nil history)))) | |
654 (todo-add-item-non-interactively new-item category))) | |
655 | |
645 (defalias 'todo-cmd-inst 'todo-insert-item) | 656 (defalias 'todo-cmd-inst 'todo-insert-item) |
646 | 657 |
647 (defun todo-more-important-p (line) | 658 (defun todo-more-important-p (line) |
648 "Ask whether entry is more important than the one at LINE." | 659 "Ask whether entry is more important than the one at LINE." |
649 (if (not (equal todo-previous-line line)) | 660 (if (not (equal todo-previous-line line)) |