[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] trunk r113570: * calendar/todo-mode.el: Add command to ren
From: |
Stephen Berman |
Subject: |
[Emacs-diffs] trunk r113570: * calendar/todo-mode.el: Add command to rename todo files. |
Date: |
Sat, 27 Jul 2013 15:59:02 +0000 |
User-agent: |
Bazaar (2.6b2) |
------------------------------------------------------------
revno: 113570
revision-id: address@hidden
parent: address@hidden
committer: Stephen Berman <address@hidden>
branch nick: trunk
timestamp: Sat 2013-07-27 17:58:56 +0200
message:
* 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.
modified:
lisp/ChangeLog changelog-20091113204419-o5vbwnq5f7feedwu-1432
lisp/calendar/todo-mode.el todos.el-20120911155047-0ytqo2nidwqquefa-1
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog 2013-07-27 12:07:43 +0000
+++ b/lisp/ChangeLog 2013-07-27 15:58:56 +0000
@@ -1,3 +1,12 @@
+2013-07-27 Stephen Berman <address@hidden>
+
+ * 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.
+
2013-07-27 Alan Mackenzie <address@hidden>
Make Java try-with-resources statement parse properly.
=== modified file 'lisp/calendar/todo-mode.el'
--- a/lisp/calendar/todo-mode.el 2013-07-05 14:03:35 +0000
+++ b/lisp/calendar/todo-mode.el 2013-07-27 15:58:56 +0000
@@ -1099,6 +1099,44 @@
(todo-show))
file)))
+(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)))
+ (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) snfname))))))))))))
+
(defun todo-delete-file ()
"Delete the current todo, archive or filtered items file.
If the todo file has a corresponding archive file, or vice versa,
@@ -6163,6 +6201,7 @@
("Cey" todo-edit-category-diary-inclusion)
("Cek" todo-edit-category-diary-nonmarking)
("Fa" todo-add-file)
+ ("Fr" todo-rename-file)
("Ff" todo-find-filtered-items-file)
("FV" todo-toggle-view-done-only)
("V" todo-toggle-view-done-only)
@@ -6171,8 +6210,8 @@
("Fts" todo-set-top-priorities-in-file)
("Fyy" todo-filter-diary-items)
("Fym" todo-filter-diary-items-multifile)
- ("Frr" todo-filter-regexp-items)
- ("Frm" todo-filter-regexp-items-multifile)
+ ("Fxx" todo-filter-regexp-items)
+ ("Fxm" todo-filter-regexp-items-multifile)
("ee" todo-edit-item)
("em" todo-edit-multiline-item)
("edt" todo-edit-item-header)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] trunk r113570: * calendar/todo-mode.el: Add command to rename todo files.,
Stephen Berman <=