summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorStephen Berman <stephen.berman@gmx.net>2020-08-27 13:53:22 +0200
committerStephen Berman <stephen.berman@gmx.net>2020-08-27 13:53:22 +0200
commited3c971534283b9af2f13e71bf975ed448f2c225 (patch)
tree935c2182b5da69a6ca48a7e9edc1bdae1ec797a1 /test
parent4cf5d2ebee5ac45a435c991e4c0ad12be619d26b (diff)
downloademacs-ed3c971534283b9af2f13e71bf975ed448f2c225.tar.gz
Prevent spurious tabs by RET in todo-edit-mode (bug#43068)
* lisp/calendar/todo-mode.el (todo-key-bindings-t) (todo-edit-mode-map): Remove remapping of `newline' to `newline-and-indent'. (todo-modes-set-1): Remove local setting of `indent-line-function'. (todo-edit-mode): Locally set `indent-line-function' to `todo-indent'. * test/lisp/calendar/todo-mode-tests.el (todo-test-move-item05): Prevent interactive test failure. (Until the addition of testcat4 to todo-test-1.todo, the test passed by chance, since testcat3 is empty and has no archived items.) (todo-test-edit-item-date-month): Refer to bug number. (todo-test-multiline-item-indentation-1) (todo-test-multiline-item-indentation-2) (todo-test-multiline-item-indentation-3): New tests. * test/lisp/calendar/todo-mode-resources/todo-test-1.todo: Remove spurious tabs from testcat1.
Diffstat (limited to 'test')
-rw-r--r--test/lisp/calendar/todo-mode-resources/todo-test-1.todo4
-rw-r--r--test/lisp/calendar/todo-mode-tests.el59
2 files changed, 56 insertions, 7 deletions
diff --git a/test/lisp/calendar/todo-mode-resources/todo-test-1.todo b/test/lisp/calendar/todo-mode-resources/todo-test-1.todo
index 557134fd454..2375772fbe7 100644
--- a/test/lisp/calendar/todo-mode-resources/todo-test-1.todo
+++ b/test/lisp/calendar/todo-mode-resources/todo-test-1.todo
@@ -1,8 +1,8 @@
(("testcat1" . [2 0 2 1]) ("testcat2" . [3 0 1 1]) ("testcat3" . [0 0 0 0]) ("testcat4" . [1 0 0 0]))
--==-- testcat1
[May 29, 2017] testcat1 item3
- has more than one line
- to test item highlighting
+ has more than one line
+ to test item highlighting
[Jul 3, 2017] testcat1 item4
==--== DONE
diff --git a/test/lisp/calendar/todo-mode-tests.el b/test/lisp/calendar/todo-mode-tests.el
index a19612ee562..1fbd39478c5 100644
--- a/test/lisp/calendar/todo-mode-tests.el
+++ b/test/lisp/calendar/todo-mode-tests.el
@@ -414,8 +414,15 @@ the top done item should be the first done item."
(should (todo-done-item-p))
(forward-line -1)
(should (looking-at todo-category-done))
- ;; Make sure marked items are no longer in first category.
- (todo-backward-category)
+ ;; Make sure marked items are no longer in first category. Since
+ ;; cat1 now contains no todo or done items but does have archived
+ ;; items, todo-backward-category would skip it by default, so
+ ;; prevent this. (FIXME: Without this let-binding,
+ ;; todo-backward-category selects the nonempty cat4 and this test
+ ;; fails as expected when run interactively but not in a batch
+ ;; run -- why?)
+ (let (todo-skip-archived-categories)
+ (todo-backward-category))
(should (eq (point-min) (point-max))) ; All todo items were moved.
;; This passes when run interactively but fails in a batch run:
;; the message is displayed but (current-message) evaluates to
@@ -848,7 +855,7 @@ should display the previously current (or default) todo file."
(should (equal todo-current-todo-file todo-test-file-1))
(delete-file (concat file "~")))))
-(ert-deftest todo-test-edit-item-date-month ()
+(ert-deftest todo-test-edit-item-date-month () ; bug#42976 #3 and #4
"Test incrementing and decrementing the month of an item's date.
If the change in month crosses a year boundary, the year of the
item's date should be adjusted accordingly."
@@ -892,8 +899,50 @@ item's date should be adjusted accordingly."
(todo-edit-item--header 'month 25)
(should (equal (funcall get-date) "Feb 1, 2022"))
(todo-edit-item--header 'month -25)
- (should (equal (funcall get-date) "Jan 1, 2020"))
- )))
+ (should (equal (funcall get-date) "Jan 1, 2020")))))
+
+(ert-deftest todo-test-multiline-item-indentation-1 ()
+ "Test inserting a multine item containing a hard line break.
+After insertion the second line of the item should begin with a
+tab character."
+ (with-todo-test
+ (let* ((item0 "Test inserting a multine item")
+ (item1 "containing a hard line break.")
+ (item (concat item0 "\n" item1)))
+ (todo-test--show 1)
+ (todo-test--insert-item item 1)
+ (re-search-forward (concat todo-date-string-start todo-date-pattern
+ (regexp-quote todo-nondiary-end) " ")
+ (line-end-position) t)
+ (should (looking-at (regexp-quote (concat item0 "\n\t" item1)))))))
+
+(ert-deftest todo-test-multiline-item-indentation-2 () ; bug#43068
+ "Test editing an item by adding text on a new line.
+After quitting todo-edit-mode the second line of the item should
+begin with a tab character."
+ (with-todo-test
+ (todo-test--show 2)
+ (let* ((item0 (todo-item-string))
+ (item1 "Second line."))
+ (todo-edit-item--text 'multiline)
+ (insert (concat "\n" item1))
+ (todo-edit-quit)
+ (goto-char (line-beginning-position))
+ (should (looking-at (regexp-quote (concat item0 "\n\t" item1)))))))
+
+(ert-deftest todo-test-multiline-item-indentation-3 ()
+ "Test adding an unindented new line to an item using todo-edit-file.
+Attempting to quit todo-edit-mode should signal a user-error,
+since all non-initial item lines must begin with whitespace."
+ (with-todo-test
+ (todo-test--show 2)
+ (let* ((item0 (todo-item-string))
+ (item1 "Second line."))
+ (todo-edit-file)
+ (should (looking-at (regexp-quote item0)))
+ (goto-char (line-end-position))
+ (insert (concat "\n" item1))
+ (should-error (todo-edit-quit) :type 'user-error))))
(provide 'todo-mode-tests)
;;; todo-mode-tests.el ends here