* calendar/todos.el (todos-copy-item): New command.
authorStephen Berman <stephen.berman@gmx.net>
Sat, 14 Jul 2012 21:18:42 +0000 (22:18 +0100)
committerStephen Berman <stephen.berman@gmx.net>
Sat, 14 Jul 2012 21:18:42 +0000 (22:18 +0100)
(todos-insertion-map): Add key binding for it.

lisp/ChangeLog
lisp/calendar/todos.el

index 05c3436..0c58a99 100644 (file)
@@ -1,3 +1,8 @@
+2012-09-24  Stephen Berman  <stephen.berman@gmx.net>
+
+       * calendar/todos.el (todos-copy-item): New command.
+       (todos-insertion-map): Add key binding for it.
+
 2012-09-24  Stephen Berman  <stephen.berman@gmx.net>
 
        * calendar/todos.el (todos-undo-item-omit-comment): New defcustom.
index b3ff319..5c07f62 100644 (file)
@@ -2382,6 +2382,7 @@ which is the value of the user option
 (defvar todos-insertion-map
   (let ((map (make-keymap)))
     (todos-insertion-key-bindings map)
+    (define-key map "p" 'todos-copy-item)
     map)
   "Keymap for Todos mode insertion commands.")
 
@@ -4241,6 +4242,17 @@ the priority is not given by HERE but by prompting."
        (if (or diary todos-include-in-diary) (todos-update-count 'diary 1))
        (todos-update-categories-sexp)))))
 
+(defun todos-copy-item ()
+  "Copy item at point and insert the copy as a new item."
+  (interactive)
+  (unless (or (todos-done-item-p) (looking-at "^$"))
+    (let ((copy (todos-item-string))
+         (diary-item (todos-diary-item-p)))
+      (todos-set-item-priority copy (todos-current-category) t)
+      (todos-update-count 'todo 1)
+      (when diary-item (todos-update-count 'diary 1))
+      (todos-update-categories-sexp))))
+
 (defvar todos-date-from-calendar nil
   "Helper variable for setting item date from the Emacs Calendar.")