diff options
author | Nicolas Goaziou <mail@nicolasgoaziou.fr> | 2018-12-06 15:05:50 +0100 |
---|---|---|
committer | Nicolas Goaziou <mail@nicolasgoaziou.fr> | 2018-12-06 15:07:03 +0100 |
commit | 1d60d5ee036e5b44416316616e4adbd84828711e (patch) | |
tree | f1cc7aa61da3863eeebcf39625a1876c931924f0 | |
parent | 503ede74bc0a1db59fd2fb7bac0bf1ba7352d15b (diff) | |
download | org-mode-1d60d5ee036e5b44416316616e4adbd84828711e.tar.gz |
org-capture: Correctly store position of captured entry
* lisp/org-capture.el (org-capture-place-entry): Store position at the
beginning of the capture entry, not at its end.
* testing/lisp/test-org-capture.el (test-org-caputre/entry): Add test.
-rw-r--r-- | lisp/org-capture.el | 2 | ||||
-rw-r--r-- | testing/lisp/test-org-capture.el | 14 |
2 files changed, 14 insertions, 2 deletions
diff --git a/lisp/org-capture.el b/lisp/org-capture.el index bb83e07..2d72c39 100644 --- a/lisp/org-capture.el +++ b/lisp/org-capture.el @@ -1133,9 +1133,9 @@ may have been stored before." (let ((origin (point))) (unless (bolp) (insert "\n")) (org-capture-empty-lines-before) - (org-capture-position-for-last-stored (point)) (let ((beg (point))) (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)) diff --git a/testing/lisp/test-org-capture.el b/testing/lisp/test-org-capture.el index 9d9ef10..fd4f21a 100644 --- a/testing/lisp/test-org-capture.el +++ b/testing/lisp/test-org-capture.el @@ -206,7 +206,19 @@ (goto-char (point-max)) (insert "Capture text") (org-capture-finalize)) - (buffer-string))))) + (buffer-string)))) + ;; Correctly save position of inserted entry. + (should + (equal + "** H" + (org-test-with-temp-text-in-file "* A" + (let* ((file (buffer-file-name)) + (org-capture-templates + `(("t" "Test" entry (file+headline ,file "A") "** H\nFoo" + :immediate-finish t)))) + (org-capture nil "t") + (org-capture '(16)) + (buffer-substring (point) (line-end-position))))))) (ert-deftest test-org-capture/item () "Test `item' type in capture template." |