emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: info@s-hahn.de
To: emacs-orgmode@gnu.org
Subject: [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	[thread overview]
Message-ID: <20100720082205.GB4680@pille.home> (raw)
In-Reply-To: <1279611661-6628-1-git-send-email-info@s-hahn.de>

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 <stefan.hahn@s-hahn.de>
---
 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	other threads:[~2010-07-20  8:22 UTC|newest]

Thread overview: expand[flat|nested]  mbox.gz  Atom feed
 [parent not found: <1279611661-6628-1-git-send-email-info@s-hahn.de>]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20100720082205.GB4680@pille.home \
    --to=info@s-hahn.de \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).