diff options
| author | Glenn Morris | 2008-05-30 02:57:27 +0000 |
|---|---|---|
| committer | Glenn Morris | 2008-05-30 02:57:27 +0000 |
| commit | f8c8f32b3d40f5405505aae82f46d76a670ab8c0 (patch) | |
| tree | c461228f41352665e62362b3f483fda893b6319a | |
| parent | 9d7316f071c48eb302580977e15ee32641203ef1 (diff) | |
| download | emacs-f8c8f32b3d40f5405505aae82f46d76a670ab8c0.tar.gz emacs-f8c8f32b3d40f5405505aae82f46d76a670ab8c0.zip | |
(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.
| -rw-r--r-- | lisp/calendar/diary-lib.el | 85 |
1 files changed, 46 insertions, 39 deletions
diff --git a/lisp/calendar/diary-lib.el b/lisp/calendar/diary-lib.el index 618c06db624..9ece770f324 100644 --- a/lisp/calendar/diary-lib.el +++ b/lisp/calendar/diary-lib.el | |||
| @@ -148,33 +148,33 @@ Used for example by the appointment package - see `appt-activate'." | |||
| 148 | :type 'hook | 148 | :type 'hook |
| 149 | :group 'diary) | 149 | :group 'diary) |
| 150 | 150 | ||
| 151 | (defcustom diary-display-hook nil | 151 | (define-obsolete-variable-alias 'diary-display-hook 'diary-display-function |
| 152 | "List of functions that handle the display of the diary. | 152 | "23.1") |
| 153 | If nil (the default), `diary-simple-display' is used. Use | 153 | |
| 154 | `ignore' for no diary display. | 154 | (defcustom diary-display-function 'diary-simple-display |
| 155 | 155 | "Function used to display the diary. | |
| 156 | Ordinarily, this just displays the diary buffer (with holidays | 156 | The default is `diary-simple-display'; `diary-fancy-display' is |
| 157 | indicated in the mode line), if there are any relevant entries. | 157 | an alternative. |
| 158 | At the time these functions are called, the variable | 158 | |
| 159 | `diary-entries-list' is a list, in order by date, of all relevant | 159 | For historical reasons, `nil' is the same as `diary-simple-display' |
| 160 | diary entries in the form of ((MONTH DAY YEAR) STRING), where | 160 | \(so you must use `ignore' for no display). Also for historical |
| 161 | string is the diary entry for the given date. This can be used, | 161 | reasons, this variable can be a list of functions to run. These |
| 162 | for example, a different buffer for display (perhaps combined | 162 | uses are not recommended and may be removed at some point. |
| 163 | with holidays), or produce hard copy output. | 163 | |
| 164 | 164 | When this function is called, the variable `diary-entries-list' | |
| 165 | A function `diary-fancy-display' is provided for use with this | 165 | is a list, in order by date, of all relevant diary entries in the |
| 166 | hook; this function prepares a special noneditable diary buffer | 166 | form of ((MONTH DAY YEAR) STRING), where string is the diary |
| 167 | with the relevant diary entries that has neat day-by-day | 167 | entry for the given date. This can be used, for example, to |
| 168 | arrangement with headings. The fancy diary buffer will show the | 168 | produce a different buffer for display (perhaps combined with |
| 169 | holidays unless the variable `diary-show-holidays-flag' is set to | 169 | holidays), or hard copy output." |
| 170 | nil. Ordinarily, the fancy diary buffer will not show days for | 170 | :type '(choice (const diary-simple-display :tag "Basic display") |
| 171 | which there are no diary entries, even if that day is a holiday; | 171 | (const diary-fancy-display :tag "Fancy display") |
| 172 | if you want such days to be shown in the fancy diary buffer, set | 172 | (const ignore :tag "No display") |
| 173 | the variable `diary-list-include-blanks' non-nil." | 173 | (const nil :tag "Obsolete way to choose basic display") |
| 174 | :type 'hook | 174 | (hook :tag "Obsolete form with list of display functions")) |
| 175 | :options '(diary-fancy-display) | ||
| 176 | :initialize 'custom-initialize-default | 175 | :initialize 'custom-initialize-default |
| 177 | :set 'diary-set-maybe-redraw | 176 | :set 'diary-set-maybe-redraw |
| 177 | :version "23.1" | ||
| 178 | :group 'diary) | 178 | :group 'diary) |
| 179 | 179 | ||
| 180 | (define-obsolete-variable-alias 'list-diary-entries-hook | 180 | (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 | you will probably also want to add `diary-mark-included-diary-files' to | 186 | you will probably also want to add `diary-mark-included-diary-files' to |
| 187 | `diary-mark-entries-hook'. For example, you could use | 187 | `diary-mark-entries-hook'. For example, you could use |
| 188 | 188 | ||
| 189 | (setq diary-display-function 'diary-fancy-display) | ||
| 189 | (add-hook 'diary-list-entries-hook 'diary-include-other-diary-files) | 190 | (add-hook 'diary-list-entries-hook 'diary-include-other-diary-files) |
| 190 | (add-hook 'diary-list-entries-hook 'diary-sort-entries) | 191 | (add-hook 'diary-list-entries-hook 'diary-sort-entries) |
| 191 | (add-hook 'diary-display-hook 'diary-fancy-display) | ||
| 192 | 192 | ||
| 193 | in your `.emacs' file to cause the fancy diary buffer to be displayed with | 193 | in your `.emacs' file to cause the fancy diary buffer to be displayed with |
| 194 | diary entries from various included files, each day's entries sorted into | 194 | 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 | from other files or to sort the diary entries. Invoked *once* | 728 | from other files or to sort the diary entries. Invoked *once* |
| 729 | only, before the display hook is run. | 729 | only, before the display hook is run. |
| 730 | 730 | ||
| 731 | `diary-display-hook' does the actual display of information. If nil, | 731 | `diary-hook' is run last, after the diary is displayed. |
| 732 | `diary-simple-display' is used. Use `add-hook' to use | 732 | This is used e.g. by `appt-check'. |
| 733 | `diary-fancy-display', if desired, or `ignore' for no display. | ||
| 734 | |||
| 735 | `diary-hook' is run last. This is used e.g. by `appt-check'. | ||
| 736 | 733 | ||
| 737 | Functions called by these hooks may use the variables ORIGINAL-DATE | 734 | Functions called by these hooks may use the variables ORIGINAL-DATE |
| 738 | and NUMBER, which are the arguments with which this function was called. | 735 | and NUMBER, which are the arguments with which this function was called. |
| 739 | Note that hook functions should _not_ use DATE, but ORIGINAL-DATE. | 736 | Note that hook functions should _not_ use DATE, but ORIGINAL-DATE. |
| 740 | \(Sexp diary entries may use DATE - see `diary-list-sexp-entries'.) | 737 | \(Sexp diary entries may use DATE - see `diary-list-sexp-entries'.) |
| 741 | 738 | ||
| 742 | If LIST-ONLY is non-nil don't modify or display the buffer, only return a list." | 739 | This function displays the list using `diary-display-function', unless |
| 740 | LIST-ONLY is non-nil, in which case it just returns the list." | ||
| 743 | (unless number | 741 | (unless number |
| 744 | (setq number (if (vectorp diary-number-of-entries) | 742 | (setq number (if (vectorp diary-number-of-entries) |
| 745 | (aref diary-number-of-entries (calendar-day-of-week date)) | 743 | (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 | (run-hooks 'diary-nongregorian-listing-hook | 793 | (run-hooks 'diary-nongregorian-listing-hook |
| 796 | 'diary-list-entries-hook) | 794 | 'diary-list-entries-hook) |
| 797 | (unless list-only | 795 | (unless list-only |
| 798 | (if diary-display-hook | 796 | (if (and diary-display-function |
| 799 | (run-hooks 'diary-display-hook) | 797 | (listp diary-display-function)) |
| 800 | (diary-simple-display))) | 798 | ;; Backwards compatability. |
| 799 | (run-hooks 'diary-display-function) | ||
| 800 | (funcall (or diary-display-function | ||
| 801 | 'diary-simple-display)))) | ||
| 801 | (run-hooks 'diary-hook) | 802 | (run-hooks 'diary-hook) |
| 802 | diary-entries-list)))))) | 803 | diary-entries-list)))))) |
| 803 | 804 | ||
| @@ -829,7 +830,7 @@ changing the variable `diary-include-string'." | |||
| 829 | (match-string-no-properties 1))) | 830 | (match-string-no-properties 1))) |
| 830 | (diary-list-include-blanks nil) | 831 | (diary-list-include-blanks nil) |
| 831 | (diary-list-entries-hook 'diary-include-other-diary-files) | 832 | (diary-list-entries-hook 'diary-include-other-diary-files) |
| 832 | (diary-display-hook 'ignore) | 833 | (diary-display-function 'ignore) |
| 833 | (diary-hook nil)) | 834 | (diary-hook nil)) |
| 834 | (if (file-exists-p diary-file) | 835 | (if (file-exists-p diary-file) |
| 835 | (if (file-readable-p diary-file) | 836 | (if (file-readable-p diary-file) |
| @@ -886,7 +887,9 @@ Returns a cons (NOENTRIES . HOLIDAY-STRING)." | |||
| 886 | (defvar diary-saved-point) ; bound in diary-list-entries | 887 | (defvar diary-saved-point) ; bound in diary-list-entries |
| 887 | 888 | ||
| 888 | (defun diary-simple-display () | 889 | (defun diary-simple-display () |
| 889 | "Display the diary buffer if there are any relevant entries or holidays." | 890 | "Display the diary buffer if there are any relevant entries or holidays. |
| 891 | Entries that do not apply are made invisible. Holidays are shown | ||
| 892 | in the mode line. This is an option for `diary-display-function'." | ||
| 890 | ;; If selected window is dedicated (to the calendar), need a new one | 893 | ;; If selected window is dedicated (to the calendar), need a new one |
| 891 | ;; to display the diary. | 894 | ;; to display the diary. |
| 892 | (let* ((pop-up-frames (or pop-up-frames | 895 | (let* ((pop-up-frames (or pop-up-frames |
| @@ -941,7 +944,11 @@ Returns a cons (NOENTRIES . HOLIDAY-STRING)." | |||
| 941 | 944 | ||
| 942 | (defun diary-fancy-display () | 945 | (defun diary-fancy-display () |
| 943 | "Prepare a diary buffer with relevant entries in a fancy, noneditable form. | 946 | "Prepare a diary buffer with relevant entries in a fancy, noneditable form. |
| 944 | To use this function, add it to `diary-display-hook'." | 947 | Holidays are shown unless `diary-show-holidays-flag' is nil. |
| 948 | Days with no diary entries are not shown (even if that day is a | ||
| 949 | holiday), unless `diary-list-include-blanks' is non-nil. | ||
| 950 | |||
| 951 | This is an option for `diary-display-function'." | ||
| 945 | ;; Turn off selective-display in the diary file's buffer. | 952 | ;; Turn off selective-display in the diary file's buffer. |
| 946 | (with-current-buffer | 953 | (with-current-buffer |
| 947 | (find-buffer-visiting (substitute-in-file-name diary-file)) | 954 | (find-buffer-visiting (substitute-in-file-name diary-file)) |
| @@ -1117,7 +1124,7 @@ should ensure that all relevant variables are set. | |||
| 1117 | (interactive "P") | 1124 | (interactive "P") |
| 1118 | (if (string-equal diary-mail-addr "") | 1125 | (if (string-equal diary-mail-addr "") |
| 1119 | (error "You must set `diary-mail-addr' to use this command") | 1126 | (error "You must set `diary-mail-addr' to use this command") |
| 1120 | (let ((diary-display-hook 'diary-fancy-display)) | 1127 | (let ((diary-display-function 'diary-fancy-display)) |
| 1121 | (diary-list-entries (calendar-current-date) (or ndays diary-mail-days))) | 1128 | (diary-list-entries (calendar-current-date) (or ndays diary-mail-days))) |
| 1122 | (compose-mail diary-mail-addr | 1129 | (compose-mail diary-mail-addr |
| 1123 | (concat "Diary entries generated " | 1130 | (concat "Diary entries generated " |