emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Orgmode] [PATCH] Added command in org-agenda-bulk-action to copy marked


From: info
Subject: [Orgmode] [PATCH] Added command in org-agenda-bulk-action to copy marked entries to a new buffer.
Date: Tue, 20 Jul 2010 10:22:05 +0200
User-agent: Mutt/1.5.20 (2009-06-14)

To print all org items which are shown in agenda buffer, a new command has been
added to org-agenda-bulk-action which copies all marked enntries to an new 
buffer.

Signed-off-by: Stefan-W. Hahn <address@hidden>
---
 doc/org.texi       |    2 ++
 lisp/org-agenda.el |   30 +++++++++++++++++++++++++++++-
 2 files changed, 31 insertions(+), 1 deletions(-)

diff --git a/doc/org.texi b/doc/org.texi
index 27d1874..5bbb5d1 100644
--- a/doc/org.texi
+++ b/doc/org.texi
@@ -7857,6 +7857,8 @@ these special timestamps.
 @example
 r  @r{Prompt for a single refile target and move all entries.  The entries}
    @r{will no longer be in the agenda, refresh (@kbd{g}) to bring them back.}
+c  @r{Copy all marked entries to the buffer *org-temp*. If the buffer does not}
+   @r{exist it will be created.}
 $  @r{Archive all selected entries.}
 A  @r{Archive entries by moving them to their respective archive siblings.}
 t  @r{Change TODO state.  This prompts for a single TODO keyword and}
diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el
index 191ee52..0eabe09 100644
--- a/lisp/org-agenda.el
+++ b/lisp/org-agenda.el
@@ -7466,13 +7466,38 @@ This will remove the markers, and the overlays."
   (setq org-agenda-bulk-marked-entries nil)
   (org-agenda-bulk-remove-overlays (point-min) (point-max)))
 
+(defun org-agenda-copy-marked-items ()
+  "Copy all marked items to buffer *org-temp*. If buffer does not
+exist, create it."
+  (let* ((marker (or (org-get-at-bol 'org-hd-marker)
+                    (org-agenda-error)))
+        (buffer (marker-buffer marker))
+        (dbuf (get-buffer-create "*org-temp*")))
+    (with-current-buffer buffer
+      (save-excursion
+       (save-restriction
+         (widen)
+         (goto-char marker)
+         (org-copy-subtree 1)
+         (set-buffer dbuf)
+         (org-mode)
+         (widen)
+         (goto-char (point-max))
+         (if (not (bolp)) (newline))
+         (org-paste-subtree 1)
+         (show-all)
+         (when (featurep 'org-inlinetask)
+           (org-inlinetask-remove-END-maybe))
+         (message "Copied to \"%s\"" (buffer-name dbuf))
+         (switch-to-buffer dbuf))))))
+
 (defun org-agenda-bulk-action (&optional arg)
   "Execute an remote-editing action on all marked entries.
 The prefix arg is passed through to the command if possible."
   (interactive "P")
   (unless org-agenda-bulk-marked-entries
     (error "No entries are marked"))
-  (message "Bulk: [r]efile [$]archive [A]rch->sib [t]odo [+/-]tag [s]chedule 
[d]eadline")
+  (message "Bulk: [r]efile [c]opy [$]archive [A]rch->sib [t]odo [+/-]tag 
[s]chedule [d]eadline")
   (let* ((action (read-char-exclusive))
         (org-log-refile (if org-log-refile 'time nil))
         (entries (reverse org-agenda-bulk-marked-entries))
@@ -7500,6 +7525,9 @@ The prefix arg is passed through to the command if 
possible."
       (setq cmd (list 'org-agenda-refile nil (list 'quote rfloc) t)
            redo-at-end t))
 
+     ((equal action ?c)
+      (setq cmd '(org-agenda-copy-marked-items)))
+
      ((equal action ?t)
       (setq state (org-icompleting-read
                   "Todo state: "
-- 
1.7.2.rc2



reply via email to

[Prev in Thread] Current Thread [Next in Thread]