From 747f46aa1f94fc8375fddd3620e15b9b0c0ff86e Mon Sep 17 00:00:00 2001 From: Bastien Guerry Date: Wed, 6 Nov 2013 15:51:57 +0100 Subject: [PATCH] org-capture: Fix bug when capturing with templates using `function' * org-capture.el (org-capture): Store :return-to-wconf earlier. (org-capture-place-template): Don't store :return-to-wconf when called from a capture template using `function', rely on the early :return-to-wconf value store from `org-capture'. Thanks to Brett Viren for raising this issue. --- lisp/org-capture.el | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/lisp/org-capture.el b/lisp/org-capture.el index 871382d65..804539eb2 100644 --- a/lisp/org-capture.el +++ b/lisp/org-capture.el @@ -577,8 +577,9 @@ of the day at point (if any) or the current HH:MM time." (file-name-nondirectory (buffer-file-name orig-buf))) :annotation annotation - :initial initial) - (org-capture-put :default-time + :initial initial + :return-to-wconf (current-window-configuration) + :default-time (or org-overriding-default-time (org-current-time))) (org-capture-set-target-location) @@ -593,7 +594,8 @@ of the day at point (if any) or the current HH:MM time." ;;insert at point (org-capture-insert-template-here) (condition-case error - (org-capture-place-template) + (org-capture-place-template + (equal (car (org-capture-get :target)) 'function)) ((error quit) (if (and (buffer-base-buffer (current-buffer)) (string-match "\\`CAPTURE-" (buffer-name))) @@ -986,9 +988,12 @@ it. When it is a variable, retrieve the value. Return whatever we get." (ignore-errors (org-set-local (car v) (cdr v)))) (buffer-local-variables buffer))) -(defun org-capture-place-template () - "Insert the template at the target location, and display the buffer." - (org-capture-put :return-to-wconf (current-window-configuration)) +(defun org-capture-place-template (&optional inhibit-wconf-store) + "Insert the template at the target location, and display the buffer. +When `inhibit-wconf-store', don't store the window configuration, as it +may have been stored before." + (unless inhibit-wconf-store + (org-capture-put :return-to-wconf (current-window-configuration))) (delete-other-windows) (org-switch-to-buffer-other-window (org-capture-get-indirect-buffer (org-capture-get :buffer) "CAPTURE")) -- 2.11.4.GIT