emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [PATCH] C-3 C-c C-w to copy the subtree instead of moving it
@ 2013-07-05 12:45 Bastien
  2013-07-08  8:01 ` Carsten Dominik
  0 siblings, 1 reply; 4+ messages in thread
From: Bastien @ 2013-07-05 12:45 UTC (permalink / raw)
  To: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 253 bytes --]

When taking notes in a meeting, I often need to refile a subtree by
copying it (so that it stays in the meeting's notes.)  For now you
can do this by setting (setq org-refile-keep t) but having this on
a temporary basis is nice.

This patch does this.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-org.el-org-refile-allow-to-only-copy-the-subtree-wit.patch --]
[-- Type: text/x-patch, Size: 1785 bytes --]

From d35926a24d3741453d9ee2bc837ec540cccfae09 Mon Sep 17 00:00:00 2001
From: Bastien Guerry <bzg@altern.org>
Date: Fri, 5 Jul 2013 13:47:28 +0200
Subject: [PATCH] org.el (org-refile): allow to only copy the subtree without
 moving it

* org.el (org-refile): With a numeric prefix argument of `3',
emulate (setq org-refile-keep t) and copy the subtree to the
target location, don't delete it.
---
 lisp/org.el | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/lisp/org.el b/lisp/org.el
index 7ba78f5..5a386a0 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -11485,7 +11485,11 @@ and not actually move anything.
 
 With a double prefix arg \\[universal-argument] \\[universal-argument], \
 go to the location where the last refiling operation has put the subtree.
-With a prefix argument of `2', refile to the running clock.
+
+With a numeric prefix argument of `2', refile to the running clock.
+
+With a numeric prefix argument of `3', emulate `org-refile-keep'
+being set to `t' and copy to the target location, don't move it.
 
 RFLOC can be a refile location obtained in a different way.
 
@@ -11508,6 +11512,7 @@ prefix argument (`C-u C-u C-u C-c C-w')."
 	   (region-start (and regionp (region-beginning)))
 	   (region-end (and regionp (region-end)))
 	   (filename (buffer-file-name (buffer-base-buffer cbuf)))
+	   (org-refile-keep (if (equal goto 3) t org-refile-keep))
 	   pos it nbuf file re level reversed)
       (setq last-command nil)
       (when regionp
@@ -11566,7 +11571,7 @@ prefix argument (`C-u C-u C-u C-c C-w')."
 
 	  (setq nbuf (or (find-buffer-visiting file)
 			 (find-file-noselect file)))
-	  (if goto
+	  (if (and goto (not (equal goto 3)))
 	      (progn
 		(org-pop-to-buffer-same-window nbuf)
 		(goto-char pos)
-- 
1.8.2.2


[-- Attachment #3: Type: text/plain, Size: 14 bytes --]


-- 
 Bastien

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] C-3 C-c C-w to copy the subtree instead of moving it
  2013-07-05 12:45 [PATCH] C-3 C-c C-w to copy the subtree instead of moving it Bastien
@ 2013-07-08  8:01 ` Carsten Dominik
  2013-07-08  8:26   ` Bastien
  0 siblings, 1 reply; 4+ messages in thread
From: Carsten Dominik @ 2013-07-08  8:01 UTC (permalink / raw)
  To: Bastien; +Cc: emacs-orgmode

Hi Bastien,

this looks like a useful function to me.  However, the documentation
should warn about duplicate IDs that might result from this.

- Carsten

On Jul 5, 2013, at 2:45 PM, Bastien <bzg@gnu.org> wrote:

> When taking notes in a meeting, I often need to refile a subtree by
> copying it (so that it stays in the meeting's notes.)  For now you
> can do this by setting (setq org-refile-keep t) but having this on
> a temporary basis is nice.
> 
> This patch does this.
> 
> From d35926a24d3741453d9ee2bc837ec540cccfae09 Mon Sep 17 00:00:00 2001
> From: Bastien Guerry <bzg@altern.org>
> Date: Fri, 5 Jul 2013 13:47:28 +0200
> Subject: [PATCH] org.el (org-refile): allow to only copy the subtree without
> moving it
> 
> * org.el (org-refile): With a numeric prefix argument of `3',
> emulate (setq org-refile-keep t) and copy the subtree to the
> target location, don't delete it.
> ---
> lisp/org.el | 9 +++++++--
> 1 file changed, 7 insertions(+), 2 deletions(-)
> 
> diff --git a/lisp/org.el b/lisp/org.el
> index 7ba78f5..5a386a0 100644
> --- a/lisp/org.el
> +++ b/lisp/org.el
> @@ -11485,7 +11485,11 @@ and not actually move anything.
> 
> With a double prefix arg \\[universal-argument] \\[universal-argument], \
> go to the location where the last refiling operation has put the subtree.
> -With a prefix argument of `2', refile to the running clock.
> +
> +With a numeric prefix argument of `2', refile to the running clock.
> +
> +With a numeric prefix argument of `3', emulate `org-refile-keep'
> +being set to `t' and copy to the target location, don't move it.
> 
> RFLOC can be a refile location obtained in a different way.
> 
> @@ -11508,6 +11512,7 @@ prefix argument (`C-u C-u C-u C-c C-w')."
> 	   (region-start (and regionp (region-beginning)))
> 	   (region-end (and regionp (region-end)))
> 	   (filename (buffer-file-name (buffer-base-buffer cbuf)))
> +	   (org-refile-keep (if (equal goto 3) t org-refile-keep))
> 	   pos it nbuf file re level reversed)
>       (setq last-command nil)
>       (when regionp
> @@ -11566,7 +11571,7 @@ prefix argument (`C-u C-u C-u C-c C-w')."
> 
> 	  (setq nbuf (or (find-buffer-visiting file)
> 			 (find-file-noselect file)))
> -	  (if goto
> +	  (if (and goto (not (equal goto 3)))
> 	      (progn
> 		(org-pop-to-buffer-same-window nbuf)
> 		(goto-char pos)
> -- 
> 1.8.2.2
> 
> 
> -- 
> Bastien

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] C-3 C-c C-w to copy the subtree instead of moving it
  2013-07-08  8:01 ` Carsten Dominik
@ 2013-07-08  8:26   ` Bastien
  2013-07-08  8:35     ` Carsten Dominik
  0 siblings, 1 reply; 4+ messages in thread
From: Bastien @ 2013-07-08  8:26 UTC (permalink / raw)
  To: Carsten Dominik; +Cc: emacs-orgmode

Hi Carsten,

Carsten Dominik <carsten.dominik@gmail.com> writes:

> this looks like a useful function to me.  However, the documentation
> should warn about duplicate IDs that might result from this.

Thanks.  I've pushed the feature on master and documented it a bit
better, both on the docstring and in the manual (`org-refile-keep'
was not documented so far.)

Best,

-- 
 Bastien

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] C-3 C-c C-w to copy the subtree instead of moving it
  2013-07-08  8:26   ` Bastien
@ 2013-07-08  8:35     ` Carsten Dominik
  0 siblings, 0 replies; 4+ messages in thread
From: Carsten Dominik @ 2013-07-08  8:35 UTC (permalink / raw)
  To: Bastien; +Cc: emacs-orgmode

Excellent, thank you very much!

- Carsten

On Jul 8, 2013, at 10:26 AM, Bastien <bzg@gnu.org> wrote:

> Hi Carsten,
> 
> Carsten Dominik <carsten.dominik@gmail.com> writes:
> 
>> this looks like a useful function to me.  However, the documentation
>> should warn about duplicate IDs that might result from this.
> 
> Thanks.  I've pushed the feature on master and documented it a bit
> better, both on the docstring and in the manual (`org-refile-keep'
> was not documented so far.)
> 
> Best,
> 
> -- 
> Bastien

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2013-07-08  8:35 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-07-05 12:45 [PATCH] C-3 C-c C-w to copy the subtree instead of moving it Bastien
2013-07-08  8:01 ` Carsten Dominik
2013-07-08  8:26   ` Bastien
2013-07-08  8:35     ` Carsten Dominik

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).