From 0ca661415469b2434248f96a5fda66f0816f8728 Mon Sep 17 00:00:00 2001 From: Bastien Guerry Date: Tue, 18 Sep 2012 11:09:25 +0200 Subject: [PATCH] org-exp.el (org-export): Set the mark correctly when exporting a subtree * org-exp.el (org-export): Set the mark correctly when exporting a subtree. Thanks to Tyler Smith for reporting this problem. --- lisp/org-exp.el | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lisp/org-exp.el b/lisp/org-exp.el index d76a2952a..6b506cd12 100644 --- a/lisp/org-exp.el +++ b/lisp/org-exp.el @@ -974,6 +974,8 @@ Pressing `1' will switch between these two options." (let* ((bg (org-xor (equal arg '(16)) org-export-run-in-background)) (subtree-p (or (org-region-active-p) (eq org-export-initial-scope 'subtree))) + (regb (and (org-region-active-p) (region-beginning))) + (rege (and (org-region-active-p) (region-end))) (help "[t] insert the export option template \[v] limit export to visible part of outline tree \[1] switch buffer/subtree export @@ -1054,6 +1056,10 @@ Pressing `1' will switch between these two options." ((not subtree-p) (setq subtree-p t) (setq bpos (point)) + (org-mark-subtree) + (org-activate-mark) + (setq regb (and (org-region-active-p) (region-beginning))) + (setq rege (and (org-region-active-p) (region-end))) (message "Export subtree: ")))) (when (eq r1 ?\ ) (let ((case-fold-search t) @@ -1091,8 +1097,9 @@ Pressing `1' will switch between these two options." "-f" (symbol-name (nth 1 ass))))) (set-process-sentinel p 'org-export-process-sentinel) (message "Background process \"%s\": started" p)) - ;; background processing not requested, or not possible - (if subtree-p (progn (org-mark-subtree) (org-activate-mark))) + ;; set the mark correctly when exporting a subtree + (if subtree-p (let (deactivate-mark) (push-mark rege t t) (goto-char regb))) + (call-interactively (nth 1 ass)) (when (and bpos (get-buffer-window cbuf)) (let ((cw (selected-window)))