comparison lisp/calendar/todo-mode.el @ 20199:70fcbe6a5e23

Three insertion options: i without prefix: ask for category, do binary insertion i with prefix: do binary insertion in current category uppercase I: insert directly under cursor
author Oliver Seidel <os10000@seidel-space.de>
date Tue, 28 Oct 1997 22:16:24 +0000
parents 8fa6333a22f2
children fa0ae5cb8ab2
comparison
equal deleted inserted replaced
20198:8fa6333a22f2 20199:70fcbe6a5e23
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.29 1997/10/28 21:47:12 os10000 Exp os10000 $ 7 ;; Version: $Id: todo-mode.el,v 1.30 1997/10/28 21:59:48 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
94 ;; 94 ;;
95 ;; Version 95 ;; Version
96 ;; 96 ;;
97 ;; Which version of todo-mode.el does this documentation refer to? 97 ;; Which version of todo-mode.el does this documentation refer to?
98 ;; 98 ;;
99 ;; $Id: todo-mode.el,v 1.29 1997/10/28 21:47:12 os10000 Exp os10000 $ 99 ;; $Id: todo-mode.el,v 1.30 1997/10/28 21:59:48 os10000 Exp os10000 $
100 ;; 100 ;;
101 ;; Pre-Requisites 101 ;; Pre-Requisites
102 ;; 102 ;;
103 ;; This package will require the following packages to be 103 ;; This package will require the following packages to be
104 ;; available on the load-path: 104 ;; available on the load-path:
118 ;; comment and timestamp 118 ;; comment and timestamp
119 ;; e to edit the current entry 119 ;; e to edit the current entry
120 ;; E to edit a multi-line entry 120 ;; E to edit a multi-line entry
121 ;; f to file the current entry, including a 121 ;; f to file the current entry, including a
122 ;; comment and timestamp 122 ;; comment and timestamp
123 ;; i to insert a new entry 123 ;; i to insert a new entry, with prefix, omit category
124 ;; I to insert a new entry at current cursor position 124 ;; I to insert a new entry at current cursor position
125 ;; j jump to category 125 ;; j jump to category
126 ;; k to kill the current entry 126 ;; k to kill the current entry
127 ;; l to lower the current entry's priority 127 ;; l to lower the current entry's priority
128 ;; n for the next entry 128 ;; n for the next entry
265 ;; --------------------------------------------------------------------------- 265 ;; ---------------------------------------------------------------------------
266 266
267 ;;; Change Log: 267 ;;; Change Log:
268 268
269 ;; $Log: todo-mode.el,v $ 269 ;; $Log: todo-mode.el,v $
270 ;; Revision 1.30 1997/10/28 21:59:48 os10000
271 ;; Improved documentation, fixed insertion with prefix.
272 ;;
270 ;; Revision 1.29 1997/10/28 21:47:12 os10000 273 ;; Revision 1.29 1997/10/28 21:47:12 os10000
271 ;; Implemented "insert-under-cursor" as suggested by 274 ;; Implemented "insert-under-cursor" as suggested by
272 ;; Kai Grossjohann <grossjohann@ls6.cs.uni-dortmund.de>. 275 ;; Kai Grossjohann <grossjohann@ls6.cs.uni-dortmund.de>.
273 ;; 276 ;;
274 ;; Revision 1.28 1997/10/28 21:37:05 os10000 277 ;; Revision 1.28 1997/10/28 21:37:05 os10000
748 todo-category-end 751 todo-category-end
749 todo-prefix todo-category-sep))) 752 todo-prefix todo-category-sep)))
750 0) 753 0)
751 754
752 ;;;### autoload 755 ;;;### autoload
753 (defun todo-add-item-non-interactively (new-item category ARG) 756 (defun todo-add-item-non-interactively (new-item category)
754 "Insert NEW-ITEM in TODO list as a new entry in CATEGORY." 757 "Insert NEW-ITEM in TODO list as a new entry in CATEGORY."
755 (save-excursion 758 (save-excursion
756 (todo-show)) 759 (todo-show))
757 (save-excursion 760 (save-excursion
758 (if (string= "" category) 761 (if (string= "" category)
760 (let ((cat-exists (member category todo-categories))) 763 (let ((cat-exists (member category todo-categories)))
761 (setq todo-category-number 764 (setq todo-category-number
762 (if cat-exists 765 (if cat-exists
763 (- (length todo-categories) (length cat-exists)) 766 (- (length todo-categories) (length cat-exists))
764 (todo-add-category category)))) 767 (todo-add-category category))))
765 (if (not ARG) 768 (todo-show)
766 (progn 769 (setq todo-previous-line 0)
767 (todo-show) 770 (let ((top 1)
768 (setq todo-previous-line 0) 771 (bottom (1+ (count-lines (point-min) (point-max)))))
769 (let ((top 1) 772 (while (> (- bottom top) todo-insert-threshold)
770 (bottom (1+ (count-lines (point-min) (point-max))))) 773 (let* ((current (/ (+ top bottom) 2))
771 (while (> (- bottom top) todo-insert-threshold) 774 (answer (if (< current bottom)
772 (let* ((current (/ (+ top bottom) 2)) 775 (todo-more-important-p current) nil)))
773 (answer (if (< current bottom) 776 (if answer
774 (todo-more-important-p current) nil))) 777 (setq bottom current)
775 (if answer 778 (setq top (1+ current)))))
776 (setq bottom current) 779 (setq top (/ (+ top bottom) 2))
777 (setq top (1+ current))))) 780 ;; goto-line doesn't have the desired behavior in a narrowed buffer
778 (setq top (/ (+ top bottom) 2)) 781 (goto-char (point-min))
779 ;; goto-line doesn't have the desired behavior in a narrowed buffer 782 (forward-line (1- top)))
780 (goto-char (point-min))
781 (forward-line (1- top))))
782 (beginning-of-line))
783 (insert new-item "\n") 783 (insert new-item "\n")
784 (todo-backward-item) 784 (todo-backward-item)
785 (todo-save) 785 (todo-save)
786 (message ""))) 786 (message "")))
787 787
806 current-category 806 current-category
807 (completing-read 807 (completing-read
808 (concat "Category [" 808 (concat "Category ["
809 current-category "]: ") 809 current-category "]: ")
810 (todo-category-alist) nil nil nil history)))) 810 (todo-category-alist) nil nil nil history))))
811 (todo-add-item-non-interactively new-item category ARG)))) 811 (todo-add-item-non-interactively new-item category))))
812 812
813 (defalias 'todo-cmd-inst 'todo-insert-item) 813 (defalias 'todo-cmd-inst 'todo-insert-item)
814 814
815 ;;;### autoload 815 ;;;### autoload
816 (defun todo-insert-item-here () 816 (defun todo-insert-item-here ()
817 "Insert new TODO list entry under the cursor." 817 "Insert new TODO list entry under the cursor."
818 (interactive) 818 (interactive "")
819 (todo-insert-item t)) 819 (save-excursion
820 (if (not (string-equal mode-name "TODO")) (todo-show))
821 (let* ((new-item (concat todo-prefix " "
822 (read-from-minibuffer
823 "New TODO entry: "
824 (if todo-entry-prefix-function
825 (funcall todo-entry-prefix-function))))))
826 (insert (concat new-item "\n")))))
820 827
821 (defun todo-more-important-p (line) 828 (defun todo-more-important-p (line)
822 "Ask whether entry is more important than the one at LINE." 829 "Ask whether entry is more important than the one at LINE."
823 (if (not (equal todo-previous-line line)) 830 (if (not (equal todo-previous-line line))
824 (progn 831 (progn