org-capture.el: Fix wrong narrowing with :prepend set to `t'

* org-capture.el (org-capture-finalize): Ensure to widen the
buffer when the target buffer is not initially narrowed.

Thanks to Adam Spiers and Thomas Proschinger for reporting this bug.
This commit is contained in:
Bastien Guerry 2014-03-13 10:44:41 +01:00
parent f94ed64ffd
commit 94f104ad5c
1 changed files with 2 additions and 1 deletions

View File

@ -741,7 +741,8 @@ captured item after finalizing."
(pos (org-capture-get :initial-target-position)) (pos (org-capture-get :initial-target-position))
(ipt (org-capture-get :insertion-point)) (ipt (org-capture-get :insertion-point))
(size (org-capture-get :captured-entry-size))) (size (org-capture-get :captured-entry-size)))
(when reg (if (not reg)
(widen)
(cond ((< ipt (car reg)) (cond ((< ipt (car reg))
;; insertion point is before the narrowed region ;; insertion point is before the narrowed region
(narrow-to-region (+ size (car reg)) (+ size (cdr reg)))) (narrow-to-region (+ size (car reg)) (+ size (cdr reg))))