Function: todo-check-format

todo-check-format is a byte-compiled function defined in todo-mode.el.gz.

Signature

(todo-check-format)

Documentation

Signal an error if the current todo file is ill-formatted.

Otherwise return t. Display a warning if the file is well-formed but the categories sexp differs from the current value of todo-categories.

Source Code

;; Defined in /usr/src/emacs/lisp/calendar/todo-mode.el.gz
(defun todo-check-format ()
  "Signal an error if the current todo file is ill-formatted.
Otherwise return t.  Display a warning if the file is well-formed
but the categories sexp differs from the current value of
`todo-categories'."
  (save-excursion
    (save-restriction
      (widen)
      (goto-char (point-min))
      (let* ((print-length nil)
             (print-level nil)
	     (cats (prin1-to-string todo-categories))
	     (ssexp (buffer-substring-no-properties (line-beginning-position)
						    (line-end-position)))
	     (sexp (read ssexp)))
	;; Check the first line for `todo-categories' sexp.
	(dolist (c sexp)
	  (let ((v (cdr c)))
	    (unless (and (stringp (car c))
			 (vectorp v)
			 (= 4 (length v)))
	      (user-error "Invalid or missing todo-categories sexp"))))
	(forward-line)
	;; Check well-formedness of categories.
	(let ((legit (concat
		      "\\(^" (regexp-quote todo-category-beg) "\\)"
		      "\\|\\(" todo-date-string-start todo-date-pattern "\\)"
		      "\\|\\(^[ \t]+[^ \t]*\\)"
		      "\\|^$"
		      "\\|\\(^" (regexp-quote todo-category-done) "\\)"
		      "\\|\\(" todo-done-string-start "\\)")))
	  (while (not (eobp))
	    (unless (looking-at legit)
	      (user-error "Illegitimate todo file format at line %d"
		     (line-number-at-pos (point))))
	    (forward-line)))
	;; Warn user if categories sexp has changed.
	(unless (string= ssexp cats)
          (display-warning 'todo "\

The sexp at the beginning of the file differs from the value of
`todo-categories'. If the sexp is wrong, you can fix it with
M-x todo-repair-categories-sexp, but note this reverts any
changes you have made in the order of the categories.
"
                           )))))
  t)