Function: todo-check-file

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

Signature

(todo-check-file FILE)

Documentation

Check the state associated with FILE and update it if necessary.

If FILE exists, return t. If it does not exist and there is no live buffer with its content, return nil; if there is such a buffer and the user tries to show it, ask whether to restore FILE, and if confirmed, do so and return t; else delete the buffer, clean up the state and return nil.

Source Code

;; Defined in /usr/src/emacs/lisp/calendar/todo-mode.el.gz
(defun todo-check-file (file)
  "Check the state associated with FILE and update it if necessary.
If FILE exists, return t.  If it does not exist and there is no
live buffer with its content, return nil; if there is such a
buffer and the user tries to show it, ask whether to restore
FILE, and if confirmed, do so and return t; else delete the
buffer, clean up the state and return nil."
  (setq todo-files (funcall todo-files-function))
  (setq todo-archives (funcall todo-files-function t))
  (if (file-exists-p file)
      t
    (setq todo-visited (delete file todo-visited))
    (let ((buf (find-buffer-visiting file)))
      (if (and buf
	       (y-or-n-p
		(concat
		 (format (concat "Todo file \"%s\" has been deleted but "
				 "its content is still in a buffer!\n")
			 (todo-short-file-name file))
		 "Save that buffer and restore the todo file? ")))
	  (progn
	    (with-current-buffer buf (save-buffer))
	    (setq todo-files (funcall todo-files-function))
	    (setq todo-archives (funcall todo-files-function t))
	    t)
	(let* ((files (append todo-files todo-archives)))
	  (unless (or (not todo-current-todo-file)
		      (member todo-current-todo-file files))
	    (setq todo-current-todo-file nil))
	  (unless (or (not todo-global-current-todo-file)
		      (member todo-global-current-todo-file files))
	    (setq todo-global-current-todo-file nil))
	  (unless (or (not todo-default-todo-file)
		      (member todo-default-todo-file files))
	    (setq todo-default-todo-file (todo-short-file-name
					  (car todo-files))))
          (todo-update-filelist-defcustoms)
	  (when buf (kill-buffer buf))
	  nil)))))