diff options
| author | Stephen Berman | 2013-07-27 17:58:56 +0200 |
|---|---|---|
| committer | Stephen Berman | 2013-07-27 17:58:56 +0200 |
| commit | ae43b66aba93d11b6dde84209154169d54c97aae (patch) | |
| tree | dd5a017c8981790856c86c26d146eac5fea1895f | |
| parent | e95da6d36ca628fd7ae4d1bd1affa11ff489daa4 (diff) | |
| download | emacs-ae43b66aba93d11b6dde84209154169d54c97aae.tar.gz emacs-ae43b66aba93d11b6dde84209154169d54c97aae.zip | |
* calendar/todo-mode.el: Add command to rename todo files.
(todo-rename-file): New command.
(todo-key-bindings-t): Add key binding for it. Change the
bindings of todo-filter-regexp-items(-multifile) to use `x'
instead of `r', since the latter is better suited to the new
renaming command.
| -rw-r--r-- | lisp/ChangeLog | 9 | ||||
| -rw-r--r-- | lisp/calendar/todo-mode.el | 43 |
2 files changed, 50 insertions, 2 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index e74c4ffe486..9dec56b78e8 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,12 @@ | |||
| 1 | 2013-07-27 Stephen Berman <stephen.berman@gmx.net> | ||
| 2 | |||
| 3 | * calendar/todo-mode.el: Add command to rename todo files. | ||
| 4 | (todo-rename-file): New command. | ||
| 5 | (todo-key-bindings-t): Add key binding for it. Change the | ||
| 6 | bindings of todo-filter-regexp-items(-multifile) to use `x' | ||
| 7 | instead of `r', since the latter is better suited to the new | ||
| 8 | renaming command. | ||
| 9 | |||
| 1 | 2013-07-27 Alan Mackenzie <acm@muc.de> | 10 | 2013-07-27 Alan Mackenzie <acm@muc.de> |
| 2 | 11 | ||
| 3 | Make Java try-with-resources statement parse properly. | 12 | Make Java try-with-resources statement parse properly. |
diff --git a/lisp/calendar/todo-mode.el b/lisp/calendar/todo-mode.el index 934dfb92a57..d578950a802 100644 --- a/lisp/calendar/todo-mode.el +++ b/lisp/calendar/todo-mode.el | |||
| @@ -1099,6 +1099,44 @@ Noninteractively, return the name of the new file." | |||
| 1099 | (todo-show)) | 1099 | (todo-show)) |
| 1100 | file))) | 1100 | file))) |
| 1101 | 1101 | ||
| 1102 | (defun todo-rename-file (&optional arg) | ||
| 1103 | "Rename the current todo file. | ||
| 1104 | With prefix ARG, prompt for a todo file and rename it. | ||
| 1105 | If there are corresponding archive or filtered items files, | ||
| 1106 | rename these accordingly. If there are live buffers visiting | ||
| 1107 | these files, also rename them accordingly." | ||
| 1108 | (interactive "P") | ||
| 1109 | (let* ((oname (or (and arg | ||
| 1110 | (todo-read-file-name "Choose a file to rename: " | ||
| 1111 | nil t)) | ||
| 1112 | (buffer-file-name))) | ||
| 1113 | (soname (todo-short-file-name oname)) | ||
| 1114 | (nname (todo-read-file-name "New name for this file: ")) | ||
| 1115 | (snname (todo-short-file-name nname)) | ||
| 1116 | (files (directory-files todo-directory t | ||
| 1117 | (concat ".*" (regexp-quote soname) | ||
| 1118 | ".*\.tod[aorty]$") t))) | ||
| 1119 | (dolist (f files) | ||
| 1120 | (let ((sfname (todo-short-file-name f)) | ||
| 1121 | (fext (file-name-extension f t)) | ||
| 1122 | (fbuf (find-buffer-visiting f))) | ||
| 1123 | (when (string-match (regexp-quote soname) sfname) | ||
| 1124 | (let* ((snfname (replace-match snname t t sfname)) | ||
| 1125 | (nfname (concat todo-directory snfname fext))) | ||
| 1126 | (rename-file f nfname) | ||
| 1127 | (when fbuf | ||
| 1128 | (with-current-buffer fbuf | ||
| 1129 | (set-visited-file-name nfname t t) | ||
| 1130 | (cond ((member fext '(".todo" ".toda")) | ||
| 1131 | (setq todo-current-todo-file (buffer-file-name)) | ||
| 1132 | (setq mode-line-buffer-identification | ||
| 1133 | (funcall todo-mode-line-function | ||
| 1134 | (todo-current-category)))) | ||
| 1135 | (t | ||
| 1136 | (rename-buffer | ||
| 1137 | (replace-regexp-in-string | ||
| 1138 | (regexp-quote soname) snfname)))))))))))) | ||
| 1139 | |||
| 1102 | (defun todo-delete-file () | 1140 | (defun todo-delete-file () |
| 1103 | "Delete the current todo, archive or filtered items file. | 1141 | "Delete the current todo, archive or filtered items file. |
| 1104 | If the todo file has a corresponding archive file, or vice versa, | 1142 | If the todo file has a corresponding archive file, or vice versa, |
| @@ -6163,6 +6201,7 @@ Filtered Items mode following todo (not done) items." | |||
| 6163 | ("Cey" todo-edit-category-diary-inclusion) | 6201 | ("Cey" todo-edit-category-diary-inclusion) |
| 6164 | ("Cek" todo-edit-category-diary-nonmarking) | 6202 | ("Cek" todo-edit-category-diary-nonmarking) |
| 6165 | ("Fa" todo-add-file) | 6203 | ("Fa" todo-add-file) |
| 6204 | ("Fr" todo-rename-file) | ||
| 6166 | ("Ff" todo-find-filtered-items-file) | 6205 | ("Ff" todo-find-filtered-items-file) |
| 6167 | ("FV" todo-toggle-view-done-only) | 6206 | ("FV" todo-toggle-view-done-only) |
| 6168 | ("V" todo-toggle-view-done-only) | 6207 | ("V" todo-toggle-view-done-only) |
| @@ -6171,8 +6210,8 @@ Filtered Items mode following todo (not done) items." | |||
| 6171 | ("Fts" todo-set-top-priorities-in-file) | 6210 | ("Fts" todo-set-top-priorities-in-file) |
| 6172 | ("Fyy" todo-filter-diary-items) | 6211 | ("Fyy" todo-filter-diary-items) |
| 6173 | ("Fym" todo-filter-diary-items-multifile) | 6212 | ("Fym" todo-filter-diary-items-multifile) |
| 6174 | ("Frr" todo-filter-regexp-items) | 6213 | ("Fxx" todo-filter-regexp-items) |
| 6175 | ("Frm" todo-filter-regexp-items-multifile) | 6214 | ("Fxm" todo-filter-regexp-items-multifile) |
| 6176 | ("ee" todo-edit-item) | 6215 | ("ee" todo-edit-item) |
| 6177 | ("em" todo-edit-multiline-item) | 6216 | ("em" todo-edit-multiline-item) |
| 6178 | ("edt" todo-edit-item-header) | 6217 | ("edt" todo-edit-item-header) |