GNU bug report logs -
#78957
31.0.50; Wrong mode-line in fancy diary
Previous Next
Reported by: Manuel Giraud <manuel <at> ledu-giraud.fr>
Date: Fri, 4 Jul 2025 19:16:02 UTC
Severity: normal
Found in version 31.0.50
Done: Eli Zaretskii <eliz <at> gnu.org>
Bug is archived. No further changes may be made.
Full log
Message #8 received at 78957 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
On Fri, 04 Jul 2025 21:14:52 +0200 Manuel Giraud <manuel <at> ledu-giraud.fr> wrote:
> Hi,
>
> When viewing diary entry from the calendar, the mode line could be set
> erroneously. The recipe:
>
> - Have a file "/tmp/diary" with the following content:
>
> July 4, 2025 A bitter day for many
>
> - emacs -Q
> - M-: (setopt diary-file "/tmp/diary") <RET>
> - M-: (toggle-frame-fullscreen) <RET>
> - M-: (calendar) <RET>
> - g d
> - 2025 <RET>
> - July <RET>
> - 4 <RET>
> - d
>
> Observe that the date in the mode line of the diary view buffer is not
> centered and maybe partly out of sight. This seems to come from the
> fact that the call to `window-edges' in `calendar-set-mode-line' does
> not return correct values but I can't figure out why.
I think it's because both times `window-edges' is called in
`diary-fancy-display' the selected window is the one displaying the
Calendar, whose `window-width' is the full screen width due to
`toggle-frame-fullscreen', while the window displaying the Fancy Diary
is half as wide. The following patch seems to fix the problem for me:
[Message part 2 (text/x-patch, inline)]
diff --git a/lisp/calendar/diary-lib.el b/lisp/calendar/diary-lib.el
index 8fb6fadfe4c..3b0275d4cee 100644
--- a/lisp/calendar/diary-lib.el
+++ b/lisp/calendar/diary-lib.el
@@ -1058,7 +1058,8 @@ diary-fancy-display
(unless (car (diary-display-no-entries)) ; no entries
;; Prepare the fancy diary buffer.
(calendar-in-read-only-buffer diary-fancy-buffer
- (calendar-set-mode-line "Diary Entries")
+ (with-selected-window (get-buffer-window diary-fancy-buffer)
+ (calendar-set-mode-line "Diary Entries"))
(let ((holiday-list-last-month 1)
(holiday-list-last-year 1)
(date (list 0 0 0))
@@ -1139,7 +1140,8 @@ diary-fancy-display
(if (eq major-mode 'diary-fancy-display-mode)
(run-hooks 'diary-fancy-display-mode-hook)
(diary-fancy-display-mode))
- (calendar-set-mode-line diary--date-string))))
+ (with-selected-window (get-buffer-window diary-fancy-buffer)
+ (calendar-set-mode-line diary--date-string)))))
;; FIXME modernize?
(defun diary-print-entries ()
[Message part 3 (text/plain, inline)]
Steve Berman
This bug report was last modified 13 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.