瀏覽代碼

Merge branch 'maint'

Nicolas Goaziou 7 年之前
父節點
當前提交
6a273e30d7
共有 2 個文件被更改,包括 18 次插入2 次删除
  1. 2 2
      lisp/org-capture.el
  2. 16 0
      testing/lisp/test-org-capture.el

+ 2 - 2
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)))
 

+ 16 - 0
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