summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien <bzg@gnu.org>2020-02-05 00:13:24 +0100
committerBastien <bzg@gnu.org>2020-02-05 00:13:24 +0100
commitd8c51531c0716f5e73f6e517037632ea863d8c34 (patch)
tree5147aef0c3442209d8954423d0e9017c4c87447d
parent6671e41e4027f92fff345a45c46f4d8113f6c98c (diff)
downloadorg-mode-d8c51531c0716f5e73f6e517037632ea863d8c34.tar.gz
org-capture.el: Fix narrowing when placing an entry
* lisp/org-capture.el (org-capture-place-entry): Fix narrowing boundaries. Thanks to Gustavo Barros for the detailed bug report.
-rw-r--r--lisp/org-capture.el15
1 files changed, 7 insertions, 8 deletions
diff --git a/lisp/org-capture.el b/lisp/org-capture.el
index 23f06e4..2d5e2f1 100644
--- a/lisp/org-capture.el
+++ b/lisp/org-capture.el
@@ -1148,14 +1148,13 @@ may have been stored before."
(when insert-here? (narrow-to-region beg beg))
(org-paste-subtree level template 'for-yank))
(org-capture-position-for-last-stored beg)
- (let ((end (if (org-at-heading-p) (line-end-position 0) (point))))
- (org-capture-empty-lines-after)
- (unless (org-at-heading-p) (outline-next-heading))
- (org-capture-mark-kill-region origin (point))
- (org-capture-narrow beg end)
- (when (or (search-backward "%?" beg t)
- (search-forward "%?" end t))
- (replace-match "")))))))
+ (org-capture-empty-lines-after)
+ (unless (org-at-heading-p) (outline-next-heading))
+ (org-capture-mark-kill-region origin (point))
+ (org-capture-narrow beg (1- (point)))
+ (when (or (search-backward "%?" beg t)
+ (search-forward "%?" nil t))
+ (replace-match ""))))))
(defun org-capture-place-item ()
"Place the template as a new plain list item."