Commit f8c8f32b authored by Glenn Morris's avatar Glenn Morris

(diary-display-function): New name for diary-display-hook. Keep old

name as obsolete alias.  Doc fix.  Change custom type and version.
(diary-list-entries-hook, diary-list-entries, diary-simple-display)
(diary-fancy-display): Doc fixes.
(diary-list-entries, diary-include-other-diary-files, diary-mail-entries):
Use diary-display-function rather than diary-display-hook.
parent 9d7316f0
...@@ -148,33 +148,33 @@ Used for example by the appointment package - see `appt-activate'." ...@@ -148,33 +148,33 @@ Used for example by the appointment package - see `appt-activate'."
:type 'hook :type 'hook
:group 'diary) :group 'diary)
(defcustom diary-display-hook nil (define-obsolete-variable-alias 'diary-display-hook 'diary-display-function
"List of functions that handle the display of the diary. "23.1")
If nil (the default), `diary-simple-display' is used. Use
`ignore' for no diary display. (defcustom diary-display-function 'diary-simple-display
"Function used to display the diary.
Ordinarily, this just displays the diary buffer (with holidays The default is `diary-simple-display'; `diary-fancy-display' is
indicated in the mode line), if there are any relevant entries. an alternative.
At the time these functions are called, the variable
`diary-entries-list' is a list, in order by date, of all relevant For historical reasons, `nil' is the same as `diary-simple-display'
diary entries in the form of ((MONTH DAY YEAR) STRING), where \(so you must use `ignore' for no display). Also for historical
string is the diary entry for the given date. This can be used, reasons, this variable can be a list of functions to run. These
for example, a different buffer for display (perhaps combined uses are not recommended and may be removed at some point.
with holidays), or produce hard copy output.
When this function is called, the variable `diary-entries-list'
A function `diary-fancy-display' is provided for use with this is a list, in order by date, of all relevant diary entries in the
hook; this function prepares a special noneditable diary buffer form of ((MONTH DAY YEAR) STRING), where string is the diary
with the relevant diary entries that has neat day-by-day entry for the given date. This can be used, for example, to
arrangement with headings. The fancy diary buffer will show the produce a different buffer for display (perhaps combined with
holidays unless the variable `diary-show-holidays-flag' is set to holidays), or hard copy output."
nil. Ordinarily, the fancy diary buffer will not show days for :type '(choice (const diary-simple-display :tag "Basic display")
which there are no diary entries, even if that day is a holiday; (const diary-fancy-display :tag "Fancy display")
if you want such days to be shown in the fancy diary buffer, set (const ignore :tag "No display")
the variable `diary-list-include-blanks' non-nil." (const nil :tag "Obsolete way to choose basic display")
:type 'hook (hook :tag "Obsolete form with list of display functions"))
:options '(diary-fancy-display)
:initialize 'custom-initialize-default :initialize 'custom-initialize-default
:set 'diary-set-maybe-redraw :set 'diary-set-maybe-redraw
:version "23.1"
:group 'diary) :group 'diary)
(define-obsolete-variable-alias 'list-diary-entries-hook (define-obsolete-variable-alias 'list-diary-entries-hook
...@@ -186,9 +186,9 @@ You might wish to add `diary-include-other-diary-files', in which case ...@@ -186,9 +186,9 @@ You might wish to add `diary-include-other-diary-files', in which case
you will probably also want to add `diary-mark-included-diary-files' to you will probably also want to add `diary-mark-included-diary-files' to
`diary-mark-entries-hook'. For example, you could use `diary-mark-entries-hook'. For example, you could use
(setq diary-display-function 'diary-fancy-display)
(add-hook 'diary-list-entries-hook 'diary-include-other-diary-files) (add-hook 'diary-list-entries-hook 'diary-include-other-diary-files)
(add-hook 'diary-list-entries-hook 'diary-sort-entries) (add-hook 'diary-list-entries-hook 'diary-sort-entries)
(add-hook 'diary-display-hook 'diary-fancy-display)
in your `.emacs' file to cause the fancy diary buffer to be displayed with in your `.emacs' file to cause the fancy diary buffer to be displayed with
diary entries from various included files, each day's entries sorted into diary entries from various included files, each day's entries sorted into
...@@ -728,18 +728,16 @@ After the list is prepared, the following hooks are run: ...@@ -728,18 +728,16 @@ After the list is prepared, the following hooks are run:
from other files or to sort the diary entries. Invoked *once* from other files or to sort the diary entries. Invoked *once*
only, before the display hook is run. only, before the display hook is run.
`diary-display-hook' does the actual display of information. If nil, `diary-hook' is run last, after the diary is displayed.
`diary-simple-display' is used. Use `add-hook' to use This is used e.g. by `appt-check'.
`diary-fancy-display', if desired, or `ignore' for no display.
`diary-hook' is run last. This is used e.g. by `appt-check'.
Functions called by these hooks may use the variables ORIGINAL-DATE Functions called by these hooks may use the variables ORIGINAL-DATE
and NUMBER, which are the arguments with which this function was called. and NUMBER, which are the arguments with which this function was called.
Note that hook functions should _not_ use DATE, but ORIGINAL-DATE. Note that hook functions should _not_ use DATE, but ORIGINAL-DATE.
\(Sexp diary entries may use DATE - see `diary-list-sexp-entries'.) \(Sexp diary entries may use DATE - see `diary-list-sexp-entries'.)
If LIST-ONLY is non-nil don't modify or display the buffer, only return a list." This function displays the list using `diary-display-function', unless
LIST-ONLY is non-nil, in which case it just returns the list."
(unless number (unless number
(setq number (if (vectorp diary-number-of-entries) (setq number (if (vectorp diary-number-of-entries)
(aref diary-number-of-entries (calendar-day-of-week date)) (aref diary-number-of-entries (calendar-day-of-week date))
...@@ -795,9 +793,12 @@ If LIST-ONLY is non-nil don't modify or display the buffer, only return a list." ...@@ -795,9 +793,12 @@ If LIST-ONLY is non-nil don't modify or display the buffer, only return a list."
(run-hooks 'diary-nongregorian-listing-hook (run-hooks 'diary-nongregorian-listing-hook
'diary-list-entries-hook) 'diary-list-entries-hook)
(unless list-only (unless list-only
(if diary-display-hook (if (and diary-display-function
(run-hooks 'diary-display-hook) (listp diary-display-function))
(diary-simple-display))) ;; Backwards compatability.
(run-hooks 'diary-display-function)
(funcall (or diary-display-function
'diary-simple-display))))
(run-hooks 'diary-hook) (run-hooks 'diary-hook)
diary-entries-list)))))) diary-entries-list))))))
...@@ -829,7 +830,7 @@ changing the variable `diary-include-string'." ...@@ -829,7 +830,7 @@ changing the variable `diary-include-string'."
(match-string-no-properties 1))) (match-string-no-properties 1)))
(diary-list-include-blanks nil) (diary-list-include-blanks nil)
(diary-list-entries-hook 'diary-include-other-diary-files) (diary-list-entries-hook 'diary-include-other-diary-files)
(diary-display-hook 'ignore) (diary-display-function 'ignore)
(diary-hook nil)) (diary-hook nil))
(if (file-exists-p diary-file) (if (file-exists-p diary-file)
(if (file-readable-p diary-file) (if (file-readable-p diary-file)
...@@ -886,7 +887,9 @@ Returns a cons (NOENTRIES . HOLIDAY-STRING)." ...@@ -886,7 +887,9 @@ Returns a cons (NOENTRIES . HOLIDAY-STRING)."
(defvar diary-saved-point) ; bound in diary-list-entries (defvar diary-saved-point) ; bound in diary-list-entries
(defun diary-simple-display () (defun diary-simple-display ()
"Display the diary buffer if there are any relevant entries or holidays." "Display the diary buffer if there are any relevant entries or holidays.
Entries that do not apply are made invisible. Holidays are shown
in the mode line. This is an option for `diary-display-function'."
;; If selected window is dedicated (to the calendar), need a new one ;; If selected window is dedicated (to the calendar), need a new one
;; to display the diary. ;; to display the diary.
(let* ((pop-up-frames (or pop-up-frames (let* ((pop-up-frames (or pop-up-frames
...@@ -941,7 +944,11 @@ Returns a cons (NOENTRIES . HOLIDAY-STRING)." ...@@ -941,7 +944,11 @@ Returns a cons (NOENTRIES . HOLIDAY-STRING)."
(defun diary-fancy-display () (defun diary-fancy-display ()
"Prepare a diary buffer with relevant entries in a fancy, noneditable form. "Prepare a diary buffer with relevant entries in a fancy, noneditable form.
To use this function, add it to `diary-display-hook'." Holidays are shown unless `diary-show-holidays-flag' is nil.
Days with no diary entries are not shown (even if that day is a
holiday), unless `diary-list-include-blanks' is non-nil.
This is an option for `diary-display-function'."
;; Turn off selective-display in the diary file's buffer. ;; Turn off selective-display in the diary file's buffer.
(with-current-buffer (with-current-buffer
(find-buffer-visiting (substitute-in-file-name diary-file)) (find-buffer-visiting (substitute-in-file-name diary-file))
...@@ -1117,7 +1124,7 @@ should ensure that all relevant variables are set. ...@@ -1117,7 +1124,7 @@ should ensure that all relevant variables are set.
(interactive "P") (interactive "P")
(if (string-equal diary-mail-addr "") (if (string-equal diary-mail-addr "")
(error "You must set `diary-mail-addr' to use this command") (error "You must set `diary-mail-addr' to use this command")
(let ((diary-display-hook 'diary-fancy-display)) (let ((diary-display-function 'diary-fancy-display))
(diary-list-entries (calendar-current-date) (or ndays diary-mail-days))) (diary-list-entries (calendar-current-date) (or ndays diary-mail-days)))
(compose-mail diary-mail-addr (compose-mail diary-mail-addr
(concat "Diary entries generated " (concat "Diary entries generated "
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment