Index: lisp/calendar/todo-mode.el =================================================================== RCS file: /sources/emacs/emacs/lisp/calendar/todo-mode.el,v retrieving revision 1.57 diff -c -r1.57 todo-mode.el *** lisp/calendar/todo-mode.el 8 Feb 2006 07:54:11 -0000 1.57 --- lisp/calendar/todo-mode.el 4 Jan 2007 12:06:10 -0000 *************** *** 1,6 **** ;;; todo-mode.el --- major mode for editing TODO list files ! ;; Copyright (C) 1997, 1999, 2001, 2002, 2003, 2004, 2005, 2006 ;; Free Software Foundation, Inc. ;; Author: Oliver Seidel --- 1,6 ---- ;;; todo-mode.el --- major mode for editing TODO list files ! ;; Copyright (C) 1997, 1999, 2001, 2002, 2003, 2004, 2005, 2006, 2007 ;; Free Software Foundation, Inc. ;; Author: Oliver Seidel *************** *** 532,555 **** (defun todo-add-category (cat) "Add new category CAT to the TODO list." (interactive "sCategory: ") ! (save-window-excursion ! (setq todo-categories (cons cat todo-categories)) ! (find-file todo-file-do) ! (widen) ! (goto-char (point-min)) ! (let ((posn (search-forward "-*- mode: todo; " 17 t))) ! (if (not (null posn)) (goto-char posn)) ! (if (equal posn nil) ! (progn ! (insert "-*- mode: todo; \n") ! (forward-char -1)) ! (kill-line))) ! (insert (format "todo-categories: %S; -*-" todo-categories)) ! (forward-char 1) ! (insert (format "%s%s%s\n%s\n%s %s\n" ! todo-prefix todo-category-beg cat ! todo-category-end ! todo-prefix todo-category-sep))) 0) ;;;###autoload --- 532,557 ---- (defun todo-add-category (cat) "Add new category CAT to the TODO list." (interactive "sCategory: ") ! (if (member cat todo-categories) ! (error "This category already exists") ! (save-window-excursion ! (setq todo-categories (cons cat todo-categories)) ! (find-file todo-file-do) ! (widen) ! (goto-char (point-min)) ! (let ((posn (search-forward "-*- mode: todo; " 17 t))) ! (if (not (null posn)) (goto-char posn)) ! (if (equal posn nil) ! (progn ! (insert "-*- mode: todo; \n") ! (forward-char -1)) ! (kill-line))) ! (insert (format "todo-categories: %S; -*-" todo-categories)) ! (forward-char 1) ! (insert (format "%s%s%s\n%s\n%s %s\n" ! todo-prefix todo-category-beg cat ! todo-category-end ! todo-prefix todo-category-sep)))) 0) ;;;###autoload *************** *** 952,957 **** --- 954,961 ---- (find-file todo-file-do) (erase-buffer) (todo-mode) + (setq todo-categories nil + todo-cats nil) (todo-add-category "Todo")) (provide 'todo-mode) Index: lisp/ChangeLog =================================================================== RCS file: /sources/emacs/emacs/lisp/ChangeLog,v retrieving revision 1.10526 diff -C0 -r1.10526 ChangeLog *** lisp/ChangeLog 3 Jan 2007 20:17:09 -0000 1.10526 --- lisp/ChangeLog 4 Jan 2007 12:06:30 -0000 *************** *** 0 **** --- 1,7 ---- + 2007-01-04 Michaël Cadilhac + + * calendar/todo-mode.el (todo-add-category): Prevent adding a category + that already exists. + (todo-initial-setup): Make sure the setup is empty by setting the + category lists to nil. +