1 ;;; diary-ins.el --- calendar functions for adding diary entries.
3 ;; Copyright (C) 1990, 1994 Free Software Foundation, Inc.
5 ;; Author: Edward M. Reingold <reingold@cs.uiuc.edu>
6 ;; Keywords: diary, calendar
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is distributed in the hope that it will be useful,
11 ;; but WITHOUT ANY WARRANTY. No author or distributor
12 ;; accepts responsibility to anyone for the consequences of using it
13 ;; or for whether it serves any particular purpose or works at all,
14 ;; unless he says so in writing. Refer to the GNU Emacs General Public
15 ;; License for full details.
17 ;; Everyone is granted permission to copy, modify and redistribute
18 ;; GNU Emacs, but only under the conditions described in the
19 ;; GNU Emacs General Public License. A copy of this license is
20 ;; supposed to have been given to you along with GNU Emacs so you
21 ;; can know your rights and responsibilities. It should be in a
22 ;; file named COPYING. Among other things, the copyright notice
23 ;; and this notice must be preserved on all copies.
27 ;; This collection of functions implements the diary insertion features as
28 ;; described in calendar.el.
30 ;; Comments, corrections, and improvements should be sent to
31 ;; Edward M. Reingold Department of Computer Science
32 ;; (217) 333-6733 University of Illinois at Urbana-Champaign
33 ;; reingold@cs.uiuc.edu 1304 West Springfield Avenue
34 ;; Urbana, Illinois 61801
40 (defun make-diary-entry (string &optional nonmarking file
)
41 "Insert a diary entry STRING which may be NONMARKING in FILE.
42 If omitted, NONMARKING defaults to nil and FILE defaults to diary-file."
43 (find-file-other-window
44 (substitute-in-file-name (if file file diary-file
)))
45 (goto-char (point-max))
48 (if nonmarking diary-nonmarking-symbol
"")
51 (defun insert-diary-entry (arg)
52 "Insert a diary entry for the date indicated by point.
53 Prefix arg will make the entry nonmarking."
55 (make-diary-entry (calendar-date-string (calendar-cursor-to-date t
) t t
)
58 (defun insert-weekly-diary-entry (arg)
59 "Insert a weekly diary entry for the day of the week indicated by point.
60 Prefix arg will make the entry nonmarking."
62 (make-diary-entry (calendar-day-name (calendar-cursor-to-date t
))
65 (defun insert-monthly-diary-entry (arg)
66 "Insert a monthly diary entry for the day of the month indicated by point.
67 Prefix arg will make the entry nonmarking."
69 (let* ((calendar-date-display-form
70 (if european-calendar-style
73 (make-diary-entry (calendar-date-string (calendar-cursor-to-date t
) t
)
76 (defun insert-yearly-diary-entry (arg)
77 "Insert an annual diary entry for the day of the year indicated by point.
78 Prefix arg will make the entry nonmarking."
80 (let* ((calendar-date-display-form
81 (if european-calendar-style
83 '(monthname " " day
))))
84 (make-diary-entry (calendar-date-string (calendar-cursor-to-date t
) t
)
87 (defun insert-anniversary-diary-entry (arg)
88 "Insert an anniversary diary entry for the date given by point.
89 Prefix arg will make the entry nonmarking."
91 (let* ((calendar-date-display-form
92 (if european-calendar-style
93 '(day " " month
" " year
)
94 '(month " " day
" " year
))))
96 (format "%s(diary-anniversary %s)"
97 sexp-diary-entry-symbol
98 (calendar-date-string (calendar-cursor-to-date t
) nil t
))
101 (defun insert-block-diary-entry (arg)
102 "Insert a block diary entry for the days between the point and marked date.
103 Prefix arg will make the entry nonmarking."
105 (let* ((calendar-date-display-form
106 (if european-calendar-style
107 '(day " " month
" " year
)
108 '(month " " day
" " year
)))
109 (cursor (calendar-cursor-to-date t
))
110 (mark (or (car calendar-mark-ring
)
111 (error "No mark set in this buffer")))
114 (if (< (calendar-absolute-from-gregorian mark
)
115 (calendar-absolute-from-gregorian cursor
))
121 (format "%s(diary-block %s %s)"
122 sexp-diary-entry-symbol
123 (calendar-date-string start nil t
)
124 (calendar-date-string end nil t
))
127 (defun insert-cyclic-diary-entry (arg)
128 "Insert a cyclic diary entry starting at the date given by point.
129 Prefix arg will make the entry nonmarking."
131 (let* ((calendar-date-display-form
132 (if european-calendar-style
133 '(day " " month
" " year
)
134 '(month " " day
" " year
))))
136 (format "%s(diary-cyclic %d %s)"
137 sexp-diary-entry-symbol
138 (calendar-read "Repeat every how many days: "
139 '(lambda (x) (> x
0)))
140 (calendar-date-string (calendar-cursor-to-date t
) nil t
))
143 (defun insert-hebrew-diary-entry (arg)
144 "Insert a diary entry.
145 For the Hebrew date corresponding to the date indicated by point.
146 Prefix arg will make the entry nonmarking."
148 (let* ((calendar-month-name-array
149 calendar-hebrew-month-name-array-leap-year
))
152 hebrew-diary-entry-symbol
153 (calendar-date-string
154 (calendar-hebrew-from-absolute
155 (calendar-absolute-from-gregorian
156 (calendar-cursor-to-date t
)))
160 (defun insert-monthly-hebrew-diary-entry (arg)
161 "Insert a monthly diary entry.
162 For the day of the Hebrew month corresponding to the date indicated by point.
163 Prefix arg will make the entry nonmarking."
165 (let* ((calendar-date-display-form
166 (if european-calendar-style
'(day " * ") '("* " day
)))
167 (calendar-month-name-array
168 calendar-hebrew-month-name-array-leap-year
))
171 hebrew-diary-entry-symbol
172 (calendar-date-string
173 (calendar-hebrew-from-absolute
174 (calendar-absolute-from-gregorian
175 (calendar-cursor-to-date t
)))))
178 (defun insert-yearly-hebrew-diary-entry (arg)
179 "Insert an annual diary entry.
180 For the day of the Hebrew year corresponding to the date indicated by point.
181 Prefix arg will make the entry nonmarking."
183 (let* ((calendar-date-display-form
184 (if european-calendar-style
186 '(monthname " " day
)))
187 (calendar-month-name-array
188 calendar-hebrew-month-name-array-leap-year
))
191 hebrew-diary-entry-symbol
192 (calendar-date-string
193 (calendar-hebrew-from-absolute
194 (calendar-absolute-from-gregorian
195 (calendar-cursor-to-date t
)))))
198 (defun insert-islamic-diary-entry (arg)
199 "Insert a diary entry.
200 For the Islamic date corresponding to the date indicated by point.
201 Prefix arg will make the entry nonmarking."
203 (let* ((calendar-month-name-array calendar-islamic-month-name-array
))
206 islamic-diary-entry-symbol
207 (calendar-date-string
208 (calendar-islamic-from-absolute
209 (calendar-absolute-from-gregorian
210 (calendar-cursor-to-date t
)))
214 (defun insert-monthly-islamic-diary-entry (arg)
215 "Insert a monthly diary entry.
216 For the day of the Islamic month corresponding to the date indicated by point.
217 Prefix arg will make the entry nonmarking."
219 (let* ((calendar-date-display-form
220 (if european-calendar-style
'(day " * ") '("* " day
)))
221 (calendar-month-name-array calendar-islamic-month-name-array
))
224 islamic-diary-entry-symbol
225 (calendar-date-string
226 (calendar-islamic-from-absolute
227 (calendar-absolute-from-gregorian
228 (calendar-cursor-to-date t
)))))
231 (defun insert-yearly-islamic-diary-entry (arg)
232 "Insert an annual diary entry.
233 For the day of the Islamic year corresponding to the date indicated by point.
234 Prefix arg will make the entry nonmarking."
236 (let* ((calendar-date-display-form
237 (if european-calendar-style
239 '(monthname " " day
)))
240 (calendar-month-name-array calendar-islamic-month-name-array
))
243 islamic-diary-entry-symbol
244 (calendar-date-string
245 (calendar-islamic-from-absolute
246 (calendar-absolute-from-gregorian
247 (calendar-cursor-to-date t
)))))
252 ;;; diary-ins.el ends here