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 free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to
22 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
26 ;; This collection of functions implements the diary insertion features as
27 ;; described in calendar.el.
29 ;; Comments, corrections, and improvements should be sent to
30 ;; Edward M. Reingold Department of Computer Science
31 ;; (217) 333-6733 University of Illinois at Urbana-Champaign
32 ;; reingold@cs.uiuc.edu 1304 West Springfield Avenue
33 ;; Urbana, Illinois 61801
39 (defun make-diary-entry (string &optional nonmarking file
)
40 "Insert a diary entry STRING which may be NONMARKING in FILE.
41 If omitted, NONMARKING defaults to nil and FILE defaults to diary-file."
42 (find-file-other-window
43 (substitute-in-file-name (if file file diary-file
)))
44 (goto-char (point-max))
47 (if nonmarking diary-nonmarking-symbol
"")
50 (defun insert-diary-entry (arg)
51 "Insert a diary entry for the date indicated by point.
52 Prefix arg will make the entry nonmarking."
54 (make-diary-entry (calendar-date-string (calendar-cursor-to-date t
) t t
)
57 (defun insert-weekly-diary-entry (arg)
58 "Insert a weekly diary entry for the day of the week indicated by point.
59 Prefix arg will make the entry nonmarking."
61 (make-diary-entry (calendar-day-name (calendar-cursor-to-date t
))
64 (defun insert-monthly-diary-entry (arg)
65 "Insert a monthly diary entry for the day of the month indicated by point.
66 Prefix arg will make the entry nonmarking."
68 (let* ((calendar-date-display-form
69 (if european-calendar-style
72 (make-diary-entry (calendar-date-string (calendar-cursor-to-date t
) t
)
75 (defun insert-yearly-diary-entry (arg)
76 "Insert an annual diary entry for the day of the year indicated by point.
77 Prefix arg will make the entry nonmarking."
79 (let* ((calendar-date-display-form
80 (if european-calendar-style
82 '(monthname " " day
))))
83 (make-diary-entry (calendar-date-string (calendar-cursor-to-date t
) t
)
86 (defun insert-anniversary-diary-entry (arg)
87 "Insert an anniversary diary entry for the date given by point.
88 Prefix arg will make the entry nonmarking."
90 (let* ((calendar-date-display-form
91 (if european-calendar-style
92 '(day " " month
" " year
)
93 '(month " " day
" " year
))))
95 (format "%s(diary-anniversary %s)"
96 sexp-diary-entry-symbol
97 (calendar-date-string (calendar-cursor-to-date t
) nil t
))
100 (defun insert-block-diary-entry (arg)
101 "Insert a block diary entry for the days between the point and marked date.
102 Prefix arg will make the entry nonmarking."
104 (let* ((calendar-date-display-form
105 (if european-calendar-style
106 '(day " " month
" " year
)
107 '(month " " day
" " year
)))
108 (cursor (calendar-cursor-to-date t
))
109 (mark (or (car calendar-mark-ring
)
110 (error "No mark set in this buffer")))
113 (if (< (calendar-absolute-from-gregorian mark
)
114 (calendar-absolute-from-gregorian cursor
))
120 (format "%s(diary-block %s %s)"
121 sexp-diary-entry-symbol
122 (calendar-date-string start nil t
)
123 (calendar-date-string end nil t
))
126 (defun insert-cyclic-diary-entry (arg)
127 "Insert a cyclic diary entry starting at the date given by point.
128 Prefix arg will make the entry nonmarking."
130 (let* ((calendar-date-display-form
131 (if european-calendar-style
132 '(day " " month
" " year
)
133 '(month " " day
" " year
))))
135 (format "%s(diary-cyclic %d %s)"
136 sexp-diary-entry-symbol
137 (calendar-read "Repeat every how many days: "
138 '(lambda (x) (> x
0)))
139 (calendar-date-string (calendar-cursor-to-date t
) nil t
))
142 (defun insert-hebrew-diary-entry (arg)
143 "Insert a diary entry.
144 For the Hebrew date corresponding to the date indicated by point.
145 Prefix arg will make the entry nonmarking."
147 (let* ((calendar-month-name-array
148 calendar-hebrew-month-name-array-leap-year
))
151 hebrew-diary-entry-symbol
152 (calendar-date-string
153 (calendar-hebrew-from-absolute
154 (calendar-absolute-from-gregorian
155 (calendar-cursor-to-date t
)))
159 (defun insert-monthly-hebrew-diary-entry (arg)
160 "Insert a monthly diary entry.
161 For the day of the Hebrew month corresponding to the date indicated by point.
162 Prefix arg will make the entry nonmarking."
164 (let* ((calendar-date-display-form
165 (if european-calendar-style
'(day " * ") '("* " day
)))
166 (calendar-month-name-array
167 calendar-hebrew-month-name-array-leap-year
))
170 hebrew-diary-entry-symbol
171 (calendar-date-string
172 (calendar-hebrew-from-absolute
173 (calendar-absolute-from-gregorian
174 (calendar-cursor-to-date t
)))))
177 (defun insert-yearly-hebrew-diary-entry (arg)
178 "Insert an annual diary entry.
179 For the day of the Hebrew year corresponding to the date indicated by point.
180 Prefix arg will make the entry nonmarking."
182 (let* ((calendar-date-display-form
183 (if european-calendar-style
185 '(monthname " " day
)))
186 (calendar-month-name-array
187 calendar-hebrew-month-name-array-leap-year
))
190 hebrew-diary-entry-symbol
191 (calendar-date-string
192 (calendar-hebrew-from-absolute
193 (calendar-absolute-from-gregorian
194 (calendar-cursor-to-date t
)))))
197 (defun insert-islamic-diary-entry (arg)
198 "Insert a diary entry.
199 For the Islamic date corresponding to the date indicated by point.
200 Prefix arg will make the entry nonmarking."
202 (let* ((calendar-month-name-array calendar-islamic-month-name-array
))
205 islamic-diary-entry-symbol
206 (calendar-date-string
207 (calendar-islamic-from-absolute
208 (calendar-absolute-from-gregorian
209 (calendar-cursor-to-date t
)))
213 (defun insert-monthly-islamic-diary-entry (arg)
214 "Insert a monthly diary entry.
215 For the day of the Islamic month corresponding to the date indicated by point.
216 Prefix arg will make the entry nonmarking."
218 (let* ((calendar-date-display-form
219 (if european-calendar-style
'(day " * ") '("* " day
)))
220 (calendar-month-name-array calendar-islamic-month-name-array
))
223 islamic-diary-entry-symbol
224 (calendar-date-string
225 (calendar-islamic-from-absolute
226 (calendar-absolute-from-gregorian
227 (calendar-cursor-to-date t
)))))
230 (defun insert-yearly-islamic-diary-entry (arg)
231 "Insert an annual diary entry.
232 For the day of the Islamic year corresponding to the date indicated by point.
233 Prefix arg will make the entry nonmarking."
235 (let* ((calendar-date-display-form
236 (if european-calendar-style
238 '(monthname " " day
)))
239 (calendar-month-name-array calendar-islamic-month-name-array
))
242 islamic-diary-entry-symbol
243 (calendar-date-string
244 (calendar-islamic-from-absolute
245 (calendar-absolute-from-gregorian
246 (calendar-cursor-to-date t
)))))
251 ;;; diary-ins.el ends here