forked from mirrors/org-mode
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.
This commit is contained in:
parent
503ede74bc
commit
1d60d5ee03
|
@ -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))
|
||||
|
|
|
@ -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."
|
||||
|
|
Loading…
Reference in New Issue