diff lisp/calendar/diary-lib.el @ 90789:c0409ee15cee

Merge from emacs--devo--0 Patches applied: * emacs--devo--0 (patch 670-674) - Update from CVS - Merge from gnus--rel--5.10 * gnus--rel--5.10 (patch 209-210) - Merge from emacs--devo--0 - Update from CVS Revision: emacs@sv.gnu.org/emacs--unicode--0--patch-185
author Miles Bader <miles@gnu.org>
date Wed, 21 Mar 2007 13:33:07 +0000
parents 95d0cdf160ea 5a2583d3a11b
children 4ef881a120fe
line wrap: on
line diff
--- a/lisp/calendar/diary-lib.el	Sun Mar 18 14:12:38 2007 +0000
+++ b/lisp/calendar/diary-lib.el	Wed Mar 21 13:33:07 2007 +0000
@@ -267,10 +267,12 @@
 ;; This can be removed once the kill/yank treatment of invisible text
 ;; (see etc/TODO) is fixed. -- gm
 (defcustom diary-header-line-flag t
-  "If non-nil, `diary-simple-display' will show a header line.
+  "If non-nil, `simple-diary-display' will show a header line.
 The format of the header is specified by `diary-header-line-format'."
   :group   'diary
   :type    'boolean
+  :initialize 'custom-initialize-default
+  :set 'diary-set-maybe-redraw
   :version "22.1")
 
 (defvar diary-selective-display nil)
@@ -282,7 +284,7 @@
 before edit/copy"
                    "Diary"))
            ?\s (frame-width)))
-  "Format of the header line displayed by `diary-simple-display'.
+  "Format of the header line displayed by `simple-diary-display'.
 Only used if `diary-header-line-flag' is non-nil."
   :group   'diary
   :type    'sexp
@@ -290,6 +292,27 @@
 
 (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))))))
+
+(defun diary-set-maybe-redraw (symbol value)
+  "Set SYMBOL's value to VALUE, and redraw the diary if necessary.
+Redraws the diary if it is being displayed (note this is not the same as
+just visiting the `diary-file'), and SYMBOL's value is to be changed."
+  (let ((oldvalue (eval symbol)))
+    (custom-set-default symbol value)
+    (and (not (equal value oldvalue))
+         (diary-live-p)
+         ;; Note this assumes diary was called without prefix arg.
+         (diary))))
 
 (defcustom number-of-diary-entries 1
   "Specifies how many days of diary entries are to be displayed initially.
@@ -300,10 +323,10 @@
 day's and the next day's entries will be displayed.
 
 The value can also be a vector such as [0 2 2 2 2 4 1]; this value
-says to display no diary entries on Sunday, the display the entries
-for the current date and the day after on Monday through Thursday,
-display Friday through Monday's entries on Friday, and display only
-Saturday's entries on Saturday.
+says to display no diary entries on Sunday, the entries for
+the current date and the day after on Monday through Thursday,
+Friday through Monday's entries on Friday, and only Saturday's
+entries on Saturday.
 
 This variable does not affect the diary display with the `d' command
 from the calendar; in that case, the prefix argument controls the
@@ -317,6 +340,8 @@
 			 (integer :tag "Thursday")
 			 (integer :tag "Friday")
 			 (integer :tag "Saturday")))
+  :initialize 'custom-initialize-default
+  :set 'diary-set-maybe-redraw
   :group 'diary)
 
 
@@ -410,7 +435,10 @@
             (or (verify-visited-file-modtime diary-buffer)
                 (revert-buffer t t))))
         ;; Setup things like the header-line-format and invisibility-spec.
-        (when (eq major-mode default-major-mode) (diary-mode))
+        ;; This used to only run if the major-mode was default-major-mode,
+        ;; but that meant eg changes to header-line-format did not
+        ;; take effect from one diary invocation to the next.
+        (diary-mode)
         ;; d-s-p is passed to the diary display function.
         (let ((diary-saved-point (point)))
           (save-excursion