Function: todo-add-file

todo-add-file is an interactive and byte-compiled function defined in todo-mode.el.gz.

Signature

(todo-add-file)

Documentation

Name and initialize a new todo file.

Interactively, prompt for a category and display it, and if option todo-add-item-if-new-category is non-nil (the default), prompt for the first item. Noninteractively, return the name of the new file.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/calendar/todo-mode.el.gz
;; -----------------------------------------------------------------------------
;;; File and category editing
;; -----------------------------------------------------------------------------

(defun todo-add-file ()
  "Name and initialize a new todo file.
Interactively, prompt for a category and display it, and if
option `todo-add-item-if-new-category' is non-nil (the default),
prompt for the first item.
Noninteractively, return the name of the new file."
  (interactive)
  (let* ((prompt (concat "Enter name of new todo file "
			 "(TAB or SPC to see current names): "))
	 (file (todo-read-file-name prompt)))
    ;; Don't accept the name of an existing todo file.
    (setq file (todo-absolute-file-name
		(todo-validate-name (todo-short-file-name file) 'file)))
    (with-current-buffer (get-buffer-create file)
      (erase-buffer)
      (write-region (point-min) (point-max) file nil 'nomessage nil t)
      (kill-buffer file))
    (setq todo-files (funcall todo-files-function))
    (todo-update-filelist-defcustoms)
    (if (called-interactively-p 'any)
	(progn
	  (set-window-buffer (selected-window)
			     (set-buffer (find-file-noselect file)))
	  ;; Since buffer is not yet in todo-mode, we need to
	  ;; explicitly make todo-current-todo-file buffer local.
          (setq-local todo-current-todo-file file)
	  (todo-show))
      file)))