Hello.

Org 9.3.6: when inserting the entry by capture mechanics, it narrows buffer
in a way that cursor can be moved to the last line, which is the beginning
of next (non-capture template) line in the original unnarowed buffer.

So this allows to: start capture, move point to the very last char of the
narrowed buffer, insert something. If this line in unnarowed buffer was
start of heading, it breaks structure of document.

This is patch in attempt to fix it. I followed same approach as in
org-capture-place-item function.

Thanks,
Alexey
Common subdirectories: org-9.3.6/etc and /home/elk/.emacs.d/elpa/org-9.3.6/etc
diff -U5 org-9.3.6/org-capture.el /home/elk/.emacs.d/elpa/org-9.3.6/org-capture.el
--- org-9.3.6/org-capture.el	2020-06-15 19:04:19.061012833 +0300
+++ /home/elk/.emacs.d/elpa/org-9.3.6/org-capture.el	2020-06-28 13:08:04.446045559 +0300
@@ -1149,11 +1149,11 @@
 	  (org-paste-subtree level template 'for-yank))
 	(org-capture-position-for-last-stored beg)
 	(org-capture-empty-lines-after)
 	(unless (org-at-heading-p) (outline-next-heading))
 	(org-capture-mark-kill-region origin (point))
-	(org-capture-narrow beg (point))
+	(org-capture-narrow beg (1- (point)))
 	(when (or (search-backward "%?" beg t)
 		  (search-forward "%?" nil t))
 	  (replace-match ""))))))
 
 (defun org-capture-place-item ()

Reply via email to