aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephen Berman2009-02-12 22:35:50 +0100
committerStephen Berman2009-02-12 22:35:50 +0100
commit1e3d87b31504034a266a0af4191feb642b5fd7cc (patch)
treedec77e54cb771127bea1d851393eacac01f75b68
parent3f0317671049e0aefe3b10a99b7ad60b8d8eb8bd (diff)
downloademacs-1e3d87b31504034a266a0af4191feb642b5fd7cc.tar.gz
emacs-1e3d87b31504034a266a0af4191feb642b5fd7cc.zip
Second commit to todos.el.
* calendar/todos.el (todos-header): Remove defvar. (todos-add-category): Comment out code that inserts and updates the file local variables first line of the file todos-file-do. (todos-list-categories): New function. (todos-show): Use it; remove use of a previously deleted variable.
-rw-r--r--lisp/ChangeLog8
-rw-r--r--lisp/calendar/todos.el44
2 files changed, 33 insertions, 19 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 96d79e8c15f..3e8e3d71c66 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,11 @@
12012-09-12 Stephen Berman <stephen.berman@gmx.net>
2
3 * calendar/todos.el (todos-header): Remove defvar.
4 (todos-add-category): Comment out code that inserts and updates
5 the file local variables first line of the file todos-file-do.
6 (todos-list-categories): New function.
7 (todos-show): Use it; remove use of a previously deleted variable.
8
12012-09-11 Stephen Berman <stephen.berman@gmx.net> 92012-09-11 Stephen Berman <stephen.berman@gmx.net>
2 10
3 * calendar/todos.el: New file. This is a copy of todo-mode.el 11 * calendar/todos.el: New file. This is a copy of todo-mode.el
diff --git a/lisp/calendar/todos.el b/lisp/calendar/todos.el
index 883f2081b3e..9e0cf90a048 100644
--- a/lisp/calendar/todos.el
+++ b/lisp/calendar/todos.el
@@ -423,9 +423,6 @@ For details see the variable `time-stamp-format'."
423(defvar todos-category-end "--- End" 423(defvar todos-category-end "--- End"
424 "Separator after a category.") 424 "Separator after a category.")
425 425
426(defvar todos-header "-*- mode: todo; "
427 "Header of todo files.")
428
429;; --------------------------------------------------------------------------- 426;; ---------------------------------------------------------------------------
430 427
431(defun todos-category-select () 428(defun todos-category-select ()
@@ -539,12 +536,12 @@ For details see the variable `time-stamp-format'."
539 (setq todos-categories (cons cat todos-categories)) 536 (setq todos-categories (cons cat todos-categories))
540 (widen) 537 (widen)
541 (goto-char (point-min)) 538 (goto-char (point-min))
542 (if (search-forward "-*- mode: todo; " 17 t) 539 ;; (if (search-forward "-*- mode: todo; " 17 t)
543 (kill-line) 540 ;; (kill-line)
544 (insert "-*- mode: todo; \n") 541 ;; (insert "-*- mode: todo; \n")
545 (forward-char -1)) 542 ;; (forward-char -1))
546 (insert (format "todos-categories: %S; -*-" todos-categories)) 543 ;; (insert (format "todos-categories: %S; -*-" todos-categories))
547 (forward-char 1) 544 ;; (forward-char 1)
548 (insert (format "%s%s%s\n%s\n%s %s\n" 545 (insert (format "%s%s%s\n%s\n%s %s\n"
549 todos-prefix todos-category-beg cat 546 todos-prefix todos-category-beg cat
550 todos-category-end 547 todos-category-end
@@ -793,6 +790,22 @@ Number of entries for each category is given by `todos-print-priorities'."
793 (kill-this-buffer)) 790 (kill-this-buffer))
794 (message "Todo printing done."))))) 791 (message "Todo printing done.")))))
795 792
793(defun todos-list-categories ()
794 "Return a list of the Todo mode categories."
795 (let ((todos-buf (find-file-noselect todos-file-do))
796 categories)
797 (with-current-buffer todos-buf
798 (save-excursion
799 (save-restriction
800 (widen)
801 (goto-char (point-max))
802 (while (re-search-backward
803 (concat "^" (regexp-quote (concat todo-prefix todo-category-beg))
804 "\\(.*\\)\n")
805 (point-min) t)
806 (push (match-string-no-properties 1) categories)))))
807 categories))
808
796(defun todos-jump-to-category () 809(defun todos-jump-to-category ()
797 "Jump to a category. Default is previous category." 810 "Jump to a category. Default is previous category."
798 (interactive) 811 (interactive)
@@ -937,16 +950,9 @@ Number of entries for each category is given by `todos-print-priorities'."
937 (equal (expand-file-name todos-file-do) bufname))) 950 (equal (expand-file-name todos-file-do) bufname)))
938 (find-file todos-file-do) 951 (find-file todos-file-do)
939 (todos-initial-setup)) 952 (todos-initial-setup))
940 (if (null todos-categories) 953 (unless todos-categories
941 (if (null todos-cats) 954 (setq todos-categories (todos-list-categories)))
942 (error "Error in %s: No categories in list `todos-categories'" 955 ;; (beginning-of-line)
943 todos-file-do)
944 (goto-char (point-min))
945 (and (search-forward "todos-cats:" nil t)
946 (replace-match "todos-categories:"))
947 (make-local-variable 'todos-categories)
948 (setq todos-categories todos-cats)))
949 (beginning-of-line)
950 (todos-category-select)) 956 (todos-category-select))
951 957
952(defun todos-initial-setup () 958(defun todos-initial-setup ()