Add missing `save-restriction' to template copy function
This commit is contained in:
parent
fba18ca527
commit
a404f9a8c2
|
@ -414,22 +414,23 @@ headline of the periodic task, i.e., of the parent of the current
|
||||||
item at point. The body of the template item, without any
|
item at point. The body of the template item, without any
|
||||||
drawers, will be copied to point."
|
drawers, will be copied to point."
|
||||||
(interactive)
|
(interactive)
|
||||||
(let ((template (save-mark-and-excursion
|
(let ((template (save-restriction
|
||||||
(let ((template-element (progn
|
(save-mark-and-excursion
|
||||||
(outline-up-heading 1 'invisible-ok)
|
(let ((template-element (progn
|
||||||
(outline-next-heading)
|
(outline-up-heading 1 'invisible-ok)
|
||||||
(org-element-at-point))))
|
(outline-next-heading)
|
||||||
(unless (string-equal (org-element-property :title template-element)
|
(org-element-at-point))))
|
||||||
"Template")
|
(unless (string-equal (org-element-property :title template-element)
|
||||||
(assert "Template must be first headline in periodic task."))
|
"Template")
|
||||||
;; XXX: trying to get the contents of the current item, without any
|
(assert "Template must be first headline in periodic task."))
|
||||||
;; drawers, by going to the end of the template item and marking the
|
;; XXX: trying to get the contents of the current item, without any
|
||||||
;; element at point, which, incidentally, seems to be the content we are
|
;; drawers, by going to the end of the template item and marking the
|
||||||
;; looking for; this feels hackish, there must be a better way to do it.
|
;; element at point, which, incidentally, seems to be the content we are
|
||||||
(goto-char (org-element-property :contents-end template-element))
|
;; looking for; this feels hackish, there must be a better way to do it.
|
||||||
(org-mark-element)
|
(goto-char (org-element-property :contents-end template-element))
|
||||||
(buffer-substring-no-properties (region-beginning)
|
(org-mark-element)
|
||||||
(region-end))))))
|
(buffer-substring-no-properties (region-beginning)
|
||||||
|
(region-end)))))))
|
||||||
(insert template)
|
(insert template)
|
||||||
(org-update-statistics-cookies nil)))
|
(org-update-statistics-cookies nil)))
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue