aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorLiu Hui2025-12-29 17:50:00 +0800
committerSean Whitton2025-12-29 11:36:07 +0000
commit1fb98f2002df778beb4fe0ef44c5bbb0c0eea2e6 (patch)
tree6efa36b9cace28f05e918d7f640f2d16333e65ed /test
parente119514ae8b391f41577d22d4e41cc3fea7ab9eb (diff)
downloademacs-1fb98f2002df778beb4fe0ef44c5bbb0c0eea2e6.tar.gz
emacs-1fb98f2002df778beb4fe0ef44c5bbb0c0eea2e6.zip
Fix the date in the calendar mode line (bug#80069)
* lisp/calendar/calendar.el (calendar-redraw) (calendar-other-month): Make sure that the mode line is updated after cursor motion in case 'date' is used in 'calendar-mode-line-format'. (calendar-set-date-style): Delete call to calendar-update-mode-line because it is called in calendar-draw. (calendar-generate-window): Delete calls to calendar-update-mode-line and calendar-cursor-to-visible-date. It's better for the caller to do it. (calendar-basic-setup): Update cursor position and mode line. * lisp/calendar/cal-move.el (calendar-goto-today): Delete calendar-update-mode-line because calendar-move-hook is called last. This is consistent with other cal-move commands. * test/lisp/calendar/calendar-tests.el (calendar-test-date-in-mode-line): New test.
Diffstat (limited to 'test')
-rw-r--r--test/lisp/calendar/calendar-tests.el31
1 files changed, 31 insertions, 0 deletions
diff --git a/test/lisp/calendar/calendar-tests.el b/test/lisp/calendar/calendar-tests.el
index 2aef0bf827b..5fd974f952f 100644
--- a/test/lisp/calendar/calendar-tests.el
+++ b/test/lisp/calendar/calendar-tests.el
@@ -30,5 +30,36 @@
30 (should (eq (calendar-date-is-valid-p (list 1 2)) nil)) 30 (should (eq (calendar-date-is-valid-p (list 1 2)) nil))
31 (should (eq (calendar-date-is-valid-p (list 5 1 2025)) t))) 31 (should (eq (calendar-date-is-valid-p (list 5 1 2025)) t)))
32 32
33(ert-deftest calendar-test-date-in-calendar-mode-line ()
34 "Test whether the calendar mode line displays `date' correctly."
35 (save-window-excursion
36 (unwind-protect
37 (let* ((calendar-mode-line-format (list '(calendar-date-string date)))
38 (calendar-move-hook '(calendar-update-mode-line))
39 (today (calendar-current-date))
40 (month (calendar-extract-month today))
41 (year (calendar-extract-year today))
42 (cursor-date (calendar-gregorian-from-absolute
43 (1+ (calendar-absolute-from-gregorian today)))))
44 (calendar)
45 (should (equal (string-trim mode-line-format)
46 (calendar-date-string today)))
47 (calendar-forward-day 1)
48 (should (equal (string-trim mode-line-format)
49 (calendar-date-string cursor-date)))
50 (calendar-goto-today)
51 (should (equal (string-trim mode-line-format)
52 (calendar-date-string today)))
53 (calendar-cursor-to-visible-date cursor-date)
54 (calendar-redraw)
55 (should (equal (string-trim mode-line-format)
56 (calendar-date-string cursor-date)))
57 (calendar-cursor-to-visible-date cursor-date)
58 (calendar-scroll-left)
59 (calendar-other-month month year)
60 (should (equal (string-trim mode-line-format)
61 (calendar-date-string cursor-date))))
62 (kill-buffer calendar-buffer))))
63
33(provide 'calendar-tests) 64(provide 'calendar-tests)
34;;; calendar-tests.el ends here 65;;; calendar-tests.el ends here