Fix template copy mechanism when template is in other buffer

Forgot to switch buffer when marker in other buffer is given.
This commit is contained in:
Daniel - 2022-10-03 10:11:17 +02:00
parent 12b001221c
commit bc3ab8b901
Signed by: dbo
GPG Key ID: 784AA8DF0CCDF625
1 changed files with 20 additions and 19 deletions

View File

@ -924,6 +924,7 @@ it. Adds newline before and after the template."
(save-mark-and-excursion
(let ((template-element (org-with-point-at pom
(org-element-at-point))))
(with-current-buffer (if (markerp pom) (marker-buffer pom) (current-buffer))
(let ((content-end (org-element-property :contents-end template-element))
current-element
content-begin)
@ -942,7 +943,7 @@ it. Adds newline before and after the template."
(< content-begin content-end))
(user-error "Cannot find content in template, or content is empty"))
(string-trim-right
(buffer-substring-no-properties content-begin content-end))))))))
(buffer-substring-no-properties content-begin content-end)))))))))
(insert "\n")
(insert body)
(insert "\n")