Function: todo-rename-file
todo-rename-file is an interactive and byte-compiled function defined
in todo-mode.el.gz.
Signature
(todo-rename-file &optional ARG)
Documentation
Rename the current todo file.
With prefix ARG, prompt for a todo file and rename it. If there are corresponding archive or filtered items files, rename these accordingly. If there are live buffers visiting these files, also rename them accordingly.
Key Bindings
Source Code
;; Defined in /usr/src/emacs/lisp/calendar/todo-mode.el.gz
(defun todo-rename-file (&optional arg)
"Rename the current todo file.
With prefix ARG, prompt for a todo file and rename it.
If there are corresponding archive or filtered items files,
rename these accordingly. If there are live buffers visiting
these files, also rename them accordingly."
(interactive "P")
(let* ((oname (or (and arg
(todo-read-file-name "Choose a file to rename: "
nil t))
(buffer-file-name)))
(soname (todo-short-file-name oname))
(nname (todo-read-file-name "New name for this file: "))
(snname (todo-short-file-name nname))
(files (directory-files todo-directory t
(concat ".*" (regexp-quote soname)
".*\\.tod[aorty]$")
t)))
(dolist (f files)
(let* ((sfname (todo-short-file-name f))
(fext (file-name-extension f t))
(fbuf (find-buffer-visiting f))
(fbname (buffer-name fbuf)))
(when (string-match (regexp-quote soname) sfname)
(let* ((snfname (replace-match snname t t sfname))
(nfname (concat todo-directory snfname fext)))
(rename-file f nfname)
(when fbuf
(with-current-buffer fbuf
(set-visited-file-name nfname t t)
(cond ((member fext '(".todo" ".toda"))
(setq todo-current-todo-file (buffer-file-name))
(setq mode-line-buffer-identification
(funcall todo-mode-line-function
(todo-current-category))))
(t
(rename-buffer
(replace-regexp-in-string
(regexp-quote soname) snname fbname))))))))))
(setq todo-files (funcall todo-files-function)
todo-archives (funcall todo-files-function t))
(when (string= todo-default-todo-file soname)
(setq todo-default-todo-file snname))
(when (string= todo-global-current-todo-file oname)
(setq todo-global-current-todo-file nname))
(todo-update-filelist-defcustoms)))