]> git.eshelyaron.com Git - emacs.git/commitdiff
Second commit to todos.el.
authorStephen Berman <stephen.berman@gmx.net>
Thu, 12 Feb 2009 21:35:50 +0000 (22:35 +0100)
committerStephen Berman <stephen.berman@gmx.net>
Thu, 12 Feb 2009 21:35:50 +0000 (22:35 +0100)
* 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.

lisp/ChangeLog
lisp/calendar/todos.el

index 96d79e8c15fc3b4569b44fc3d9d96bdd90e486c8..3e8e3d71c6628f3b07108b52c05d5c3249b1490f 100644 (file)
@@ -1,3 +1,11 @@
+2012-09-12  Stephen Berman  <stephen.berman@gmx.net>
+
+       * 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.
+
 2012-09-11  Stephen Berman  <stephen.berman@gmx.net>
 
        * calendar/todos.el: New file.  This is a copy of todo-mode.el
index 883f2081b3e351f41e6b9a690a6c78773b62ea5d..9e0cf90a04876083b43f141f85b0d8302899f521 100644 (file)
@@ -423,9 +423,6 @@ For details see the variable `time-stamp-format'."
 (defvar todos-category-end "--- End"
   "Separator after a category.")
 
-(defvar todos-header "-*- mode: todo; "
-  "Header of todo files.")
-
 ;; ---------------------------------------------------------------------------
 
 (defun todos-category-select ()
@@ -539,12 +536,12 @@ For details see the variable `time-stamp-format'."
       (setq todos-categories (cons cat todos-categories))
       (widen)
       (goto-char (point-min))
-      (if (search-forward "-*- mode: todo; " 17 t)
-         (kill-line)
-       (insert "-*- mode: todo; \n")
-       (forward-char -1))
-      (insert (format "todos-categories: %S; -*-" todos-categories))
-      (forward-char 1)
+      ;; (if (search-forward "-*- mode: todo; " 17 t)
+      ;;         (kill-line)
+      ;;       (insert "-*- mode: todo; \n")
+      ;;       (forward-char -1))
+      ;; (insert (format "todos-categories: %S; -*-" todos-categories))
+      ;; (forward-char 1)
       (insert (format "%s%s%s\n%s\n%s %s\n"
                      todos-prefix todos-category-beg cat
                      todos-category-end
@@ -793,6 +790,22 @@ Number of entries for each category is given by `todos-print-priorities'."
             (kill-this-buffer))
        (message "Todo printing done.")))))
 
+(defun todos-list-categories ()
+  "Return a list of the Todo mode categories."
+  (let ((todos-buf (find-file-noselect todos-file-do))
+       categories)
+    (with-current-buffer todos-buf
+      (save-excursion
+       (save-restriction
+         (widen)
+         (goto-char (point-max))
+         (while (re-search-backward
+                 (concat "^" (regexp-quote (concat todo-prefix todo-category-beg))
+                         "\\(.*\\)\n")
+                 (point-min) t)
+           (push (match-string-no-properties 1) categories)))))
+    categories))
+
 (defun todos-jump-to-category ()
   "Jump to a category.  Default is previous category."
   (interactive)
@@ -937,16 +950,9 @@ Number of entries for each category is given by `todos-print-priorities'."
            (equal (expand-file-name todos-file-do) bufname)))
       (find-file todos-file-do)
     (todos-initial-setup))
-  (if (null todos-categories)
-      (if (null todos-cats)
-          (error "Error in %s: No categories in list `todos-categories'"
-                 todos-file-do)
-        (goto-char (point-min))
-        (and (search-forward "todos-cats:" nil t)
-             (replace-match "todos-categories:"))
-        (make-local-variable 'todos-categories)
-        (setq todos-categories todos-cats)))
-  (beginning-of-line)
+  (unless todos-categories
+    (setq todos-categories (todos-list-categories)))
+  ;; (beginning-of-line)
   (todos-category-select))
 
 (defun todos-initial-setup ()