From e3f4245a04442a1d35d454e2a0e8488fde4acf0c Mon Sep 17 00:00:00 2001 From: Glenn Morris Date: Tue, 20 Mar 2007 07:45:06 +0000 Subject: [PATCH] (diary-live-p): New function. (number-of-diary-entries): Add a :set function to redisplay diary when necessary. --- lisp/calendar/diary-lib.el | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/lisp/calendar/diary-lib.el b/lisp/calendar/diary-lib.el index f57120e5924..b6fc4300f3e 100644 --- a/lisp/calendar/diary-lib.el +++ b/lisp/calendar/diary-lib.el @@ -290,6 +290,16 @@ Only used if `diary-header-line-flag' is non-nil." (defvar diary-saved-point) ; internal +(defun diary-live-p () + "Return non-nil if the diary is being displayed. +This is not the same as just visiting the `diary-file'." + (or (get-buffer fancy-diary-buffer) + (when diary-file + (let ((dbuff (find-buffer-visiting + (substitute-in-file-name diary-file)))) + (when dbuff + (with-current-buffer dbuff + diary-selective-display)))))) (defcustom number-of-diary-entries 1 "Specifies how many days of diary entries are to be displayed initially. @@ -317,6 +327,15 @@ number of days of diary entries displayed." (integer :tag "Thursday") (integer :tag "Friday") (integer :tag "Saturday"))) + :initialize 'custom-initialize-default + ;; Redraw a live diary buffer if necessary. Note this assumes diary + ;; was not called with a prefix arg. + :set (lambda (symbol value) + (let ((oldvalue number-of-diary-entries)) + (custom-set-default symbol value) + (and (not (equal value oldvalue)) + (diary-live-p) + (diary)))) :group 'diary) -- 2.39.2