;;; Commentary:
-;; This package provides facilities for making, displaying, navigating and
-;; editing todo lists, which are prioritized lists of todo items. Todo lists
-;; are identified with named categories, so you can group together and
-;; separately prioritize thematically related todo items. Each category is
-;; stored in a file, which thus provides a further level of organization. You
-;; can create as many todo files, and in each as many categories, as you want.
-
-;; With Todos you can navigate among the items of a category, and between
-;; categories in the same and in different todo files. You can edit todo
-;; items, reprioritize them within their category, move them to another
-;; category, delete them, or mark items as done and store them separately from
-;; the not yet done items in a category. You can add new todo files and
-;; categories, rename categories, move them to another file or delete them.
-;; You can also display summary tables of the categories in a file and the
-;; types of items they contain. And you can build cross-categorial lists of
-;; items that satisfy various criteria.
-
-;; To get started, load this package and type `M-x todos-show'. This will
-;; prompt you for the name of the first todo file, its first category and the
-;; category's first item, create these and display them in Todos mode. Now
-;; you can insert further items into the list (i.e., the category) and assign
-;; them priorities by typing `i i'.
-
-;; You will probably find it convenient to give `todos-show' a global key
-;; binding in your init file, since it is one of the entry points to Todos
-;; mode; a good choice is `C-c t', since `todos-show' is bound to `t' in Todos
-;; mode.
-
-;; To see a list of all Todos mode commands and their key bindings, including
-;; other entry points, type `C-h m' in Todos mode. Consult the document
-;; strings of the commands for details of their use. The `todos'
-;; customization group and its subgroups list the options you can set to alter
-;; the behavior of many commands and various aspects of the display.
-
-;; This package is a new version of Oliver Seidel's todo-mode.el, which
-;; retains the same basic organization and handling of todo lists and the
-;; basic UI, but extends these in many ways and reimplements most of the
-;; internals.
+;; This package provides facilities for making, displaying, navigating
+;; and editing todo lists, which are prioritized lists of todo items.
+;; Todo lists are identified with named categories, so you can group
+;; together and separately prioritize thematically related todo items.
+;; Each category is stored in a file, which thus provides a further
+;; level of organization. You can create as many todo files, and in
+;; each as many categories, as you want.
+
+;; With Todos you can navigate among the items of a category, and
+;; between categories in the same and in different todo files. You
+;; can edit todo items, reprioritize them within their category, move
+;; them to another category, delete them, or mark items as done and
+;; store them separately from the not yet done items in a category.
+;; You can add new todo files and categories, rename categories, move
+;; them to another file or delete them. You can also display summary
+;; tables of the categories in a file and the types of items they
+;; contain. And you can build cross-categorial lists of items that
+;; satisfy various criteria.
+
+;; To get started, load this package and type `M-x todos-show'. This
+;; will prompt you for the name of the first todo file, its first
+;; category and the category's first item, create these and display
+;; them in Todos mode. Now you can insert further items into the list
+;; (i.e., the category) and assign them priorities by typing `i i'.
+
+;; You will probably find it convenient to give `todos-show' a global
+;; key binding in your init file, since it is one of the entry points
+;; to Todos mode; a good choice is `C-c t', since `todos-show' is
+;; bound to `t' in Todos mode.
+
+;; To see a list of all Todos mode commands and their key bindings,
+;; including other entry points, type `C-h m' in Todos mode. Consult
+;; the document strings of the commands for details of their use. The
+;; `todos' customization group and its subgroups list the options you
+;; can set to alter the behavior of many commands and various aspects
+;; of the display.
+
+;; This package is a new version of Oliver Seidel's todo-mode.el.
+;; While it retains the same basic organization and handling of todo
+;; lists and the basic UI, it significantly extends these, adds many
+;; features, changes much of the internals and reimplements almost all
+;; of the code.
;;; Code:
(require 'diary-lib)
-;; For cl-remove-duplicates (in todos-insertion-commands-args) and cl-oddp.
+;; For cl-remove-duplicates (in todos-insertion-commands-args) and
+;; cl-oddp.
(require 'cl-lib)
;; -----------------------------------------------------------------------------
(defconst todos-date-pattern
(let ((dayname (diary-name-pattern calendar-day-name-array nil t)))
- (concat "\\(?5:" dayname "\\|"
+ (concat "\\(?4:\\(?5:" dayname "\\)\\|"
(let ((dayname)
(monthname (format "\\(?6:%s\\)" (diary-name-pattern
todos-month-name-array
(line-end-position) t)
(let* ((odate (match-string-no-properties 1))
(otime (match-string-no-properties 2))
+ (odayname (match-string-no-properties 5))
(omonthname (match-string-no-properties 6))
(omonth (match-string-no-properties 7))
(oday (match-string-no-properties 8))
(when (> (length ntime) 0)
(setq ntime (concat " " ntime))))
;; When date string consists only of a day name,
- ;; passing other date components is a NOP.
- ((and (memq what '(year month day))
- (not (or oyear omonth oday))))
+ ;; passing other date components is a noop.
+ ((and odayname (memq what '(year month day))))
((eq what 'year)
(setq day oday
monthname omonthname
(setq monthname (aref tma-array (1- adjmm))))
;; Return changed numerical day as a string.
(number-to-string (nth 1 date)))))))))
- ;; If new year, month or day date string components were
- ;; calculated, rebuild the whole date string from them.
- (when (memq what '(year month day))
- (if (or oyear omonth omonthname oday)
- (setq ndate (mapconcat 'eval calendar-date-display-form ""))
- (message "Cannot edit date component of empty date string")))
+ (unless odayname
+ ;; If year, month or day date string components were
+ ;; changed, rebuild the date string.
+ (when (memq what '(year month day))
+ (setq ndate (mapconcat 'eval calendar-date-display-form ""))))
(when ndate (replace-match ndate nil nil nil 1))
;; Add new time string to the header, if it was supplied.
(when ntime
;; When done items are shown, put cursor on first just done item.
(when opoint (goto-char opoint)))))))
-(defun todos-done-item-add-edit-or-delete-comment (&optional arg)
+(defun todos-edit-done-item-comment (&optional arg)
"Add a comment to this done item or edit an existing comment.
With prefix ARG delete an existing comment."
(interactive "P")
(if to-lim lim (point-max))))
;; For last todo item, skip back over the empty line before the done
;; items section, else just back to the end of the previous line.
- ;; (When byte-comiled, backward-char barfs on an argument that evaluates
- ;; to nil (bug#14565).)
- ;; (backward-char (when (and to-lim (not done) (eq (point) lim)) 2))
- (backward-char (if (and to-lim (not done) (eq (point) lim)) 2 1))
+ (backward-char (when (and to-lim (not done) (eq (point) lim)) 2))
(point))))
(defun todos-item-string ()
("et" todos-edit-item-time)
("eyy" todos-edit-item-diary-inclusion)
("eyk" todos-edit-item-diary-nonmarking)
- ("ec" todos-done-item-add-edit-or-delete-comment)
+ ("ec" todos-edit-done-item-comment)
("d" todos-item-done)
("i" ,todos-insertion-map)
("k" todos-delete-item)