]> code.delx.au - gnu-emacs/commitdiff
(diary-header-line-flag): Doc fix. Add custom :set function.
authorGlenn Morris <rgm@gnu.org>
Wed, 21 Mar 2007 06:25:47 +0000 (06:25 +0000)
committerGlenn Morris <rgm@gnu.org>
Wed, 21 Mar 2007 06:25:47 +0000 (06:25 +0000)
(diary-header-line-format): Doc fix.
(diary-set-maybe-redraw): New function.
(number-of-diary-entries): Change :set to use diary-set-maybe-redraw.
(diary-list-entries): Always run diary-mode.

lisp/ChangeLog
lisp/calendar/diary-lib.el

index 1aab93b40f79eeaa68cd5404ac1bdff9a69105dc..f4633f517eff555db820cbb11da458cb0c0f9451 100644 (file)
@@ -1,3 +1,15 @@
+2007-03-21  Glenn Morris  <rgm@gnu.org>
+
+       * calendar/calendar.el (diary-set-maybe-redraw): Autoload it.
+       (diary-display-hook): Add custom :set function.
+
+       * calendar/diary-lib.el (diary-header-line-flag): Doc fix.  Add
+       custom :set function.
+       (diary-header-line-format): Doc fix.
+       (diary-set-maybe-redraw): New function.
+       (number-of-diary-entries): Change :set to use diary-set-maybe-redraw.
+       (diary-list-entries): Always run diary-mode.
+
 2007-03-20  David Kastrup  <dak@gnu.org>
 
        * files.el (magic-mode-alist): Require literal "%!PS" string for
index b6fc4300f3efb49b765036fab0a53e003863d9f0..72620a7f9bb0eaba67e00ac56c45b52edd2b9e07 100644 (file)
@@ -267,10 +267,12 @@ search."
 ;; 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 @@ The format of the header is specified by `diary-header-line-format'."
 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
@@ -301,6 +303,17 @@ This is not the same as just visiting the `diary-file'."
             (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.
 This variable affects the diary display when the command \\[diary] is used,
@@ -328,14 +341,7 @@ number of days of diary entries displayed."
                         (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))))
+  :set 'diary-set-maybe-redraw
   :group 'diary)
 
 
@@ -429,7 +435,10 @@ If LIST-ONLY is non-nil don't modify or display the buffer, only return a list."
             (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