diff options
author | Xavier Martinez-Hidalgo <xavier@martinezhidalgo.org> | 2017-11-02 11:47:19 +0100 |
---|---|---|
committer | Nicolas Goaziou <mail@nicolasgoaziou.fr> | 2017-11-03 22:20:11 +0100 |
commit | f38a7d433b857e7d86f808cd8ed29d63ac841a99 (patch) | |
tree | 8f51f7ad5ad96d977e5c6eff984450c2165b6346 | |
parent | b5f075aa05244b7b05c207d0c7c01b442876cd88 (diff) | |
download | org-mode-f38a7d433b857e7d86f808cd8ed29d63ac841a99.tar.gz |
org-capture: Fix aborting after inserting text at end of buffer
* lisp/org-capture.el (org-capture-mark-kill-region): Set end marker
insertion type so that it advances when inserting text at the end of
the capture buffer.
* testing/lisp/test-org-capture.el (test-org-capture/insert-at-end-abort):
Add test case.
Inserting text at the end of the capture buffer does not advance the
end kill marker. This causes the narrowing region and the kill
markers to get out of sync, which prevents 'org-capture-finalize' from
correctly cleaning the target buffer when aborting the capture.
Setting the kill end marker insertion type fixes this.
TINYCHANGE
-rw-r--r-- | lisp/org-capture.el | 4 | ||||
-rw-r--r-- | testing/lisp/test-org-capture.el | 16 |
2 files changed, 18 insertions, 2 deletions
diff --git a/lisp/org-capture.el b/lisp/org-capture.el index 25af674..2222bf4 100644 --- a/lisp/org-capture.el +++ b/lisp/org-capture.el @@ -1311,8 +1311,8 @@ Of course, if exact position has been required, just put it there." (defun org-capture-mark-kill-region (beg end) "Mark the region that will have to be killed when aborting capture." - (let ((m1 (move-marker (make-marker) beg)) - (m2 (move-marker (make-marker) end))) + (let ((m1 (copy-marker beg)) + (m2 (copy-marker end t))) (org-capture-put :begin-marker m1) (org-capture-put :end-marker m2))) diff --git a/testing/lisp/test-org-capture.el b/testing/lisp/test-org-capture.el index 4d5dfb7..b98166a 100644 --- a/testing/lisp/test-org-capture.el +++ b/testing/lisp/test-org-capture.el @@ -146,5 +146,21 @@ (list file1 file2 (buffer-file-name))))))))) +(ert-deftest test-org-capture/insert-at-end-abort () + "Test that capture can be aborted after inserting at end of capture buffer." + (should + (equal + "* A\n* B\n" + (org-test-with-temp-text-in-file "* A\n* B\n" + (let* ((file (buffer-file-name)) + (org-capture-templates + `(("t" "Todo" entry (file+headline ,file "A") "** H1 %?")))) + (org-capture nil "t") + (goto-char (point-max)) + (insert "Capture text") + (org-capture-kill)) + (buffer-string))))) + + (provide 'test-org-capture) ;;; test-org-capture.el ends here |