From 5381ebd910e417571d0ce684f101c73132eb0fb8 Mon Sep 17 00:00:00 2001 From: Bastien Guerry Date: Mon, 1 Jul 2013 01:16:38 +0200 Subject: [PATCH] org.el (org-refile): Fix refiling the active region within an list * org.el (org-refile): Fix refiling the active region within an list. Thanks to Jeff Horn and Samuel Wales. --- lisp/org.el | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lisp/org.el b/lisp/org.el index a876979c6..4266e27c2 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -11471,7 +11471,6 @@ prefix argument (`C-u C-u C-u C-c C-w')." (regionp (org-region-active-p)) (region-start (and regionp (region-beginning))) (region-end (and regionp (region-end))) - (region-length (and regionp (- region-end region-start))) (filename (buffer-file-name (buffer-base-buffer cbuf))) pos it nbuf file re level reversed) (setq last-command nil) @@ -11482,7 +11481,9 @@ prefix argument (`C-u C-u C-u C-c C-w')." (unless (or (org-kill-is-subtree-p (buffer-substring region-start region-end)) (prog1 org-refile-active-region-within-subtree - (org-toggle-heading))) + (let ((s (point-at-eol))) + (org-toggle-heading) + (setq region-end (+ (- (point-at-eol) s) region-end))))) (user-error "The region is not a (sequence of) subtree(s)"))) (if (equal goto '(16)) (org-refile-goto-last-stored) @@ -11564,8 +11565,7 @@ prefix argument (`C-u C-u C-u C-c C-w')." (if (not (bolp)) (newline)) (org-paste-subtree level) (when org-log-refile - (org-add-log-setup 'refile nil nil 'findpos - org-log-refile) + (org-add-log-setup 'refile nil nil 'findpos org-log-refile) (unless (eq org-log-refile 'note) (save-excursion (org-add-log-note)))) (and org-auto-align-tags @@ -11583,7 +11583,7 @@ prefix argument (`C-u C-u C-u C-c C-w')." (run-hooks 'org-after-refile-insert-hook)))) (unless org-refile-keep (if regionp - (delete-region (point) (+ (point) region-length)) + (delete-region (point) (+ (point) (- region-end region-start))) (delete-region (point-at-bol) (min (buffer-size) (1+ (org-end-of-subtree t)))))) -- 2.11.4.GIT