summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Guerry <bzg@altern.org>2013-11-06 15:51:57 +0100
committerBastien Guerry <bzg@altern.org>2013-11-06 15:51:57 +0100
commit747f46aa1f94fc8375fddd3620e15b9b0c0ff86e (patch)
tree8c88eff4fe35f828ec1c2d667d4110a2f913621f
parent2911965bfef9072a3031d48dfe2ea50bcb3ff9df (diff)
downloadorg-mode-747f46aa1f94fc8375fddd3620e15b9b0c0ff86e.tar.gz
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.
-rw-r--r--lisp/org-capture.el17
1 files changed, 11 insertions, 6 deletions
diff --git a/lisp/org-capture.el b/lisp/org-capture.el
index 871382d..804539e 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"))