Browse Source

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.
Bastien Guerry 11 years ago
parent
commit
5381ebd910
1 changed files with 5 additions and 5 deletions
  1. 5 5
      lisp/org.el

+ 5 - 5
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))))))