diff options
| author | Glenn Morris | 2008-03-15 02:54:24 +0000 |
|---|---|---|
| committer | Glenn Morris | 2008-03-15 02:54:24 +0000 |
| commit | 17a1af5370a66f9cd6be29989fef7de2b23a1743 (patch) | |
| tree | ba2c88fe72b60b6484d5f712437a56f0053f9f05 | |
| parent | 956ae531fc19e110213721a32ea4e9cbf51777b2 (diff) | |
| download | emacs-17a1af5370a66f9cd6be29989fef7de2b23a1743.tar.gz emacs-17a1af5370a66f9cd6be29989fef7de2b23a1743.zip | |
(todo-add-category): Simplify.
(todo-more-important-p, todo-delete-item, todo-file-item): Use unless, when.
(todo-top-priorities): Use zerop.
| -rw-r--r-- | lisp/calendar/todo-mode.el | 61 |
1 files changed, 29 insertions, 32 deletions
diff --git a/lisp/calendar/todo-mode.el b/lisp/calendar/todo-mode.el index 0763454abba..bf54a1c7cf6 100644 --- a/lisp/calendar/todo-mode.el +++ b/lisp/calendar/todo-mode.el | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | ;;; todo-mode.el --- major mode for editing TODO list files | 1 | ;;; todo-mode.el --- major mode for editing TODO list files |
| 2 | 2 | ||
| 3 | ;; Copyright (C) 1997, 1999, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 | 3 | ;; Copyright (C) 1997, 1999, 2001, 2002, 2003, 2004, 2005, 2006, 2007, |
| 4 | ;; Free Software Foundation, Inc. | 4 | ;; 2008 Free Software Foundation, Inc. |
| 5 | 5 | ||
| 6 | ;; Author: Oliver Seidel <os10000@seidel-space.de> | 6 | ;; Author: Oliver Seidel <os10000@seidel-space.de> |
| 7 | ;; [Not clear the above works, July 2000] | 7 | ;; [Not clear the above works, July 2000] |
| @@ -73,8 +73,8 @@ | |||
| 73 | ;; the addition of two bindings to your to your global keymap. I | 73 | ;; the addition of two bindings to your to your global keymap. I |
| 74 | ;; personally have the following in my initialisation file: | 74 | ;; personally have the following in my initialisation file: |
| 75 | ;; | 75 | ;; |
| 76 | ;; (global-set-key "\C-ct" 'todo-show) ;; switch to TODO buffer | 76 | ;; (global-set-key "\C-ct" 'todo-show) ; switch to TODO buffer |
| 77 | ;; (global-set-key "\C-ci" 'todo-insert-item) ;; insert new item | 77 | ;; (global-set-key "\C-ci" 'todo-insert-item) ; insert new item |
| 78 | ;; | 78 | ;; |
| 79 | ;; Note, however, that this recommendation has prompted some | 79 | ;; Note, however, that this recommendation has prompted some |
| 80 | ;; criticism, since the keys C-c LETTER are reserved for user | 80 | ;; criticism, since the keys C-c LETTER are reserved for user |
| @@ -538,12 +538,12 @@ Use `todo-categories' instead.") | |||
| 538 | (widen) | 538 | (widen) |
| 539 | (goto-char (point-min)) | 539 | (goto-char (point-min)) |
| 540 | (let ((posn (search-forward "-*- mode: todo; " 17 t))) | 540 | (let ((posn (search-forward "-*- mode: todo; " 17 t))) |
| 541 | (if (not (null posn)) (goto-char posn)) | 541 | (if posn |
| 542 | (if (equal posn nil) | ||
| 543 | (progn | 542 | (progn |
| 544 | (insert "-*- mode: todo; \n") | 543 | (goto-char posn) |
| 545 | (forward-char -1)) | 544 | (kill-line)) |
| 546 | (kill-line))) | 545 | (insert "-*- mode: todo; \n") |
| 546 | (forward-char -1))) | ||
| 547 | (insert (format "todo-categories: %S; -*-" todo-categories)) | 547 | (insert (format "todo-categories: %S; -*-" todo-categories)) |
| 548 | (forward-char 1) | 548 | (forward-char 1) |
| 549 | (insert (format "%s%s%s\n%s\n%s %s\n" | 549 | (insert (format "%s%s%s\n%s\n%s %s\n" |
| @@ -577,7 +577,7 @@ Use `todo-categories' instead.") | |||
| 577 | (setq bottom current) | 577 | (setq bottom current) |
| 578 | (setq top (1+ current))))) | 578 | (setq top (1+ current))))) |
| 579 | (setq top (/ (+ top bottom) 2)) | 579 | (setq top (/ (+ top bottom) 2)) |
| 580 | ;; goto-line doesn't have the desired behavior in a narrowed buffer | 580 | ;; goto-line doesn't have the desired behavior in a narrowed buffer. |
| 581 | (goto-char (point-min)) | 581 | (goto-char (point-min)) |
| 582 | (forward-line (1- top))) | 582 | (forward-line (1- top))) |
| 583 | (insert new-item "\n") | 583 | (insert new-item "\n") |
| @@ -625,14 +625,13 @@ category." | |||
| 625 | 625 | ||
| 626 | (defun todo-more-important-p (line) | 626 | (defun todo-more-important-p (line) |
| 627 | "Ask whether entry is more important than the one at LINE." | 627 | "Ask whether entry is more important than the one at LINE." |
| 628 | (if (not (equal todo-previous-line line)) | 628 | (unless (equal todo-previous-line line) |
| 629 | (progn | 629 | (setq todo-previous-line line) |
| 630 | (setq todo-previous-line line) | 630 | (goto-char (point-min)) |
| 631 | (goto-char (point-min)) | 631 | (forward-line (1- todo-previous-line)) |
| 632 | (forward-line (1- todo-previous-line)) | 632 | (let ((item (todo-item-string-start))) |
| 633 | (let ((item (todo-item-string-start))) | 633 | (setq todo-previous-answer |
| 634 | (setq todo-previous-answer | 634 | (y-or-n-p (concat "More important than '" item "'? "))))) |
| 635 | (y-or-n-p (concat "More important than '" item "'? ")))))) | ||
| 636 | todo-previous-answer) | 635 | todo-previous-answer) |
| 637 | (defalias 'todo-ask-p 'todo-more-important-p) | 636 | (defalias 'todo-ask-p 'todo-more-important-p) |
| 638 | 637 | ||
| @@ -643,10 +642,9 @@ category." | |||
| 643 | (let* ((todo-entry (todo-item-string-start)) | 642 | (let* ((todo-entry (todo-item-string-start)) |
| 644 | (todo-answer (y-or-n-p (concat "Permanently remove '" | 643 | (todo-answer (y-or-n-p (concat "Permanently remove '" |
| 645 | todo-entry "'? ")))) | 644 | todo-entry "'? ")))) |
| 646 | (if todo-answer | 645 | (when todo-answer |
| 647 | (progn | 646 | (todo-remove-item) |
| 648 | (todo-remove-item) | 647 | (todo-backward-item)) |
| 649 | (todo-backward-item))) | ||
| 650 | (message "")) | 648 | (message "")) |
| 651 | (error "No TODO list entry to delete"))) | 649 | (error "No TODO list entry to delete"))) |
| 652 | (defalias 'todo-cmd-kill 'todo-delete-item) | 650 | (defalias 'todo-cmd-kill 'todo-delete-item) |
| @@ -684,15 +682,14 @@ category." | |||
| 684 | (or (> (count-lines (point-min) (point-max)) 0) | 682 | (or (> (count-lines (point-min) (point-max)) 0) |
| 685 | (error "No TODO list entry to file away")) | 683 | (error "No TODO list entry to file away")) |
| 686 | (let ((time-stamp-format todo-time-string-format)) | 684 | (let ((time-stamp-format todo-time-string-format)) |
| 687 | (if (and comment (> (length comment) 0)) | 685 | (when (and comment (> (length comment) 0)) |
| 688 | (progn | 686 | (goto-char (todo-item-end)) |
| 689 | (goto-char (todo-item-end)) | 687 | (insert |
| 690 | (insert | 688 | (if (save-excursion (beginning-of-line) |
| 691 | (if (save-excursion (beginning-of-line) | 689 | (looking-at (regexp-quote todo-prefix))) |
| 692 | (looking-at (regexp-quote todo-prefix))) | 690 | " " |
| 693 | " " | 691 | "\n\t") |
| 694 | "\n\t") | 692 | "(" comment ")")) |
| 695 | "(" comment ")"))) | ||
| 696 | (goto-char (todo-item-end)) | 693 | (goto-char (todo-item-end)) |
| 697 | (insert " [" (nth todo-category-number todo-categories) "]") | 694 | (insert " [" (nth todo-category-number todo-categories) "]") |
| 698 | (goto-char (todo-item-start)) | 695 | (goto-char (todo-item-start)) |
| @@ -755,7 +752,7 @@ between each category." | |||
| 755 | (replace-match todo-category-break) | 752 | (replace-match todo-category-break) |
| 756 | (narrow-to-region beg end) ;In case we have too few entries. | 753 | (narrow-to-region beg end) ;In case we have too few entries. |
| 757 | (goto-char (point-min)) | 754 | (goto-char (point-min)) |
| 758 | (if (= 0 nof-priorities) ;Traverse entries. | 755 | (if (zerop nof-priorities) ;Traverse entries. |
| 759 | (goto-char end) ;All entries | 756 | (goto-char end) ;All entries |
| 760 | (todo-forward-item nof-priorities)) | 757 | (todo-forward-item nof-priorities)) |
| 761 | (setq beg (point)) | 758 | (setq beg (point)) |