diff options
| author | Glenn Morris | 2008-03-16 01:23:55 +0000 |
|---|---|---|
| committer | Glenn Morris | 2008-03-16 01:23:55 +0000 |
| commit | d07a05c2fbe3e0fbf41daa88bf3aae450c0906a8 (patch) | |
| tree | 9c2548f912ae8c141b03f3c8eb87d6910836b7bb | |
| parent | c97663f6bc5154ae3eb3c959c40af21ce9578a7a (diff) | |
| download | emacs-d07a05c2fbe3e0fbf41daa88bf3aae450c0906a8.tar.gz emacs-d07a05c2fbe3e0fbf41daa88bf3aae450c0906a8.zip | |
(calendar-mark-1): Autoload it.
(calendar-bahai-mark-date-pattern): Add optional argument `color'.
Use calendar-mark-1.
(calendar-bahai-date-string): Use a single let.
(diary-bahai-insert-entry, diary-bahai-insert-monthly-entry)
(diary-bahai-insert-yearly-entry): Use let rather than let*.
Move obsolete aliases after the functions that replaced them.
| -rw-r--r-- | lisp/calendar/cal-bahai.el | 172 |
1 files changed, 64 insertions, 108 deletions
diff --git a/lisp/calendar/cal-bahai.el b/lisp/calendar/cal-bahai.el index 11ed17ec1e7..d92cab52c1e 100644 --- a/lisp/calendar/cal-bahai.el +++ b/lisp/calendar/cal-bahai.el | |||
| @@ -105,10 +105,10 @@ Gregorian date Sunday, December 31, 1 BC." | |||
| 105 | 1 0))) | 105 | 1 0))) |
| 106 | (month ; search forward from Baha | 106 | (month ; search forward from Baha |
| 107 | (1+ (calendar-sum m 1 | 107 | (1+ (calendar-sum m 1 |
| 108 | (> date | 108 | (> date |
| 109 | (calendar-absolute-from-bahai | 109 | (calendar-absolute-from-bahai |
| 110 | (list m 19 year))) | 110 | (list m 19 year))) |
| 111 | 1))) | 111 | 1))) |
| 112 | (day ; calculate the day by subtraction | 112 | (day ; calculate the day by subtraction |
| 113 | (- date | 113 | (- date |
| 114 | (1- (calendar-absolute-from-bahai (list month 1 year)))))) | 114 | (1- (calendar-absolute-from-bahai (list month 1 year)))))) |
| @@ -123,22 +123,21 @@ Defaults to today's date if DATE is not given." | |||
| 123 | (or date (calendar-current-date))))) | 123 | (or date (calendar-current-date))))) |
| 124 | (y (extract-calendar-year bahai-date)) | 124 | (y (extract-calendar-year bahai-date)) |
| 125 | (m (extract-calendar-month bahai-date)) | 125 | (m (extract-calendar-month bahai-date)) |
| 126 | (d (extract-calendar-day bahai-date))) | 126 | (d (extract-calendar-day bahai-date)) |
| 127 | (let ((monthname | 127 | (monthname (if (and (= m 19) |
| 128 | (if (and (= m 19) | 128 | (<= d 0)) |
| 129 | (<= d 0)) | 129 | "Ayyám-i-Há" |
| 130 | "Ayyám-i-Há" | 130 | (aref calendar-bahai-month-name-array (1- m)))) |
| 131 | (aref calendar-bahai-month-name-array (1- m)))) | 131 | (day (int-to-string |
| 132 | (day (int-to-string | 132 | (if (<= d 0) |
| 133 | (if (<= d 0) | 133 | (if (calendar-bahai-leap-year-p y) |
| 134 | (if (calendar-bahai-leap-year-p y) | 134 | (+ d 5) |
| 135 | (+ d 5) | 135 | (+ d 4)) |
| 136 | (+ d 4)) | 136 | d))) |
| 137 | d))) | 137 | (year (int-to-string y)) |
| 138 | (dayname nil) | 138 | (month (int-to-string m)) |
| 139 | (month (int-to-string m)) | 139 | dayname) |
| 140 | (year (int-to-string y))) | 140 | (mapconcat 'eval calendar-date-display-form ""))) |
| 141 | (mapconcat 'eval calendar-date-display-form "")))) | ||
| 142 | 141 | ||
| 143 | ;;;###cal-autoload | 142 | ;;;###cal-autoload |
| 144 | (defun calendar-bahai-print-date () | 143 | (defun calendar-bahai-print-date () |
| @@ -147,6 +146,9 @@ Defaults to today's date if DATE is not given." | |||
| 147 | (message "Bahá'í date: %s" | 146 | (message "Bahá'í date: %s" |
| 148 | (calendar-bahai-date-string (calendar-cursor-to-date t)))) | 147 | (calendar-bahai-date-string (calendar-cursor-to-date t)))) |
| 149 | 148 | ||
| 149 | (define-obsolete-function-alias | ||
| 150 | 'calendar-print-bahai-date 'calendar-bahai-print-date "23.1") | ||
| 151 | |||
| 150 | (defun calendar-bahai-prompt-for-date () | 152 | (defun calendar-bahai-prompt-for-date () |
| 151 | "Ask for a Bahá'í date." | 153 | "Ask for a Bahá'í date." |
| 152 | (let* ((today (calendar-current-date)) | 154 | (let* ((today (calendar-current-date)) |
| @@ -172,13 +174,15 @@ Defaults to today's date if DATE is not given." | |||
| 172 | 174 | ||
| 173 | ;;;###cal-autoload | 175 | ;;;###cal-autoload |
| 174 | (defun calendar-bahai-goto-date (date &optional noecho) | 176 | (defun calendar-bahai-goto-date (date &optional noecho) |
| 175 | "Move cursor to Bahá'í date DATE. | 177 | "Move cursor to Bahá'í date DATE; echo Bahá'í date unless NOECHO is non-nil." |
| 176 | Echo Bahá'í date unless NOECHO is non-nil." | ||
| 177 | (interactive (calendar-bahai-prompt-for-date)) | 178 | (interactive (calendar-bahai-prompt-for-date)) |
| 178 | (calendar-goto-date (calendar-gregorian-from-absolute | 179 | (calendar-goto-date (calendar-gregorian-from-absolute |
| 179 | (calendar-absolute-from-bahai date))) | 180 | (calendar-absolute-from-bahai date))) |
| 180 | (or noecho (calendar-bahai-print-date))) | 181 | (or noecho (calendar-bahai-print-date))) |
| 181 | 182 | ||
| 183 | (define-obsolete-function-alias | ||
| 184 | 'calendar-goto-bahai-date 'calendar-bahai-goto-date "23.1") | ||
| 185 | |||
| 182 | (defvar displayed-month) | 186 | (defvar displayed-month) |
| 183 | (defvar displayed-year) | 187 | (defvar displayed-year) |
| 184 | 188 | ||
| @@ -216,68 +220,26 @@ numerically. The Bahá'í months are numbered from 1 to 19 with Bahá being | |||
| 216 | `diary-nonmarking-symbol', the entry will appear in the diary listing, but | 220 | `diary-nonmarking-symbol', the entry will appear in the diary listing, but |
| 217 | will not be marked in the calendar. This function is provided for use with | 221 | will not be marked in the calendar. This function is provided for use with |
| 218 | `nongregorian-diary-listing-hook'." | 222 | `nongregorian-diary-listing-hook'." |
| 219 | (diary-list-entries-1 calendar-bahai-month-name-array | 223 | (diary-list-entries-1 calendar-bahai-month-name-array |
| 220 | bahai-diary-entry-symbol | 224 | bahai-diary-entry-symbol |
| 221 | 'calendar-bahai-from-absolute)) | 225 | 'calendar-bahai-from-absolute)) |
| 226 | (define-obsolete-function-alias | ||
| 227 | 'list-bahai-diary-entries 'diary-bahai-list-entries "23.1") | ||
| 228 | |||
| 229 | |||
| 230 | (autoload 'calendar-mark-1 "diary-lib") | ||
| 222 | 231 | ||
| 223 | ;;;###diary-autoload | 232 | ;;;###diary-autoload |
| 224 | (defun calendar-bahai-mark-date-pattern (month day year) | 233 | (defun calendar-bahai-mark-date-pattern (month day year &optional color) |
| 225 | "Mark dates in calendar window that conform to Bahá'í date MONTH/DAY/YEAR. | 234 | "Mark dates in calendar window that conform to Bahá'í date MONTH/DAY/YEAR. |
| 226 | A value of 0 in any position is a wildcard." | 235 | A value of 0 in any position is a wildcard. Optional argument COLOR is |
| 227 | (save-excursion | 236 | passed to `mark-visible-calendar-date' as MARK." |
| 228 | (set-buffer calendar-buffer) | 237 | (calendar-mark-1 month day year 'calendar-bahai-from-absolute |
| 229 | (if (and (not (zerop month)) (not (zerop day))) | 238 | 'calendar-absolute-from-bahai color)) |
| 230 | (if (not (zerop year)) | 239 | |
| 231 | ;; Fully specified Bahá'í date. | 240 | (define-obsolete-function-alias |
| 232 | (let ((date (calendar-gregorian-from-absolute | 241 | 'mark-bahai-calendar-date-pattern 'calendar-bahai-mark-date-pattern "23.1") |
| 233 | (calendar-absolute-from-bahai | 242 | |
| 234 | (list month day year))))) | ||
| 235 | (if (calendar-date-is-visible-p date) | ||
| 236 | (mark-visible-calendar-date date))) | ||
| 237 | ;; Month and day in any year--this taken from the holiday stuff. | ||
| 238 | (let* ((bahai-date (calendar-bahai-from-absolute | ||
| 239 | (calendar-absolute-from-gregorian | ||
| 240 | (list displayed-month 15 displayed-year)))) | ||
| 241 | (m (extract-calendar-month bahai-date)) | ||
| 242 | (y (extract-calendar-year bahai-date)) | ||
| 243 | (date)) | ||
| 244 | (unless (< m 1) ; Bahá'í calendar doesn't apply | ||
| 245 | (increment-calendar-month m y (- 10 month)) | ||
| 246 | (if (> m 7) ; Bahá'í date might be visible | ||
| 247 | (let ((date (calendar-gregorian-from-absolute | ||
| 248 | (calendar-absolute-from-bahai | ||
| 249 | (list month day y))))) | ||
| 250 | (if (calendar-date-is-visible-p date) | ||
| 251 | (mark-visible-calendar-date date))))))) | ||
| 252 | ;; Not one of the simple cases--check all visible dates for match. | ||
| 253 | ;; Actually, the following code takes care of ALL of the cases, but | ||
| 254 | ;; it's much too slow to be used for the simple (common) cases. | ||
| 255 | (let ((m displayed-month) | ||
| 256 | (y displayed-year) | ||
| 257 | (first-date) | ||
| 258 | (last-date)) | ||
| 259 | (increment-calendar-month m y -1) | ||
| 260 | (setq first-date | ||
| 261 | (calendar-absolute-from-gregorian | ||
| 262 | (list m 1 y))) | ||
| 263 | (increment-calendar-month m y 2) | ||
| 264 | (setq last-date | ||
| 265 | (calendar-absolute-from-gregorian | ||
| 266 | (list m (calendar-last-day-of-month m y) y))) | ||
| 267 | (calendar-for-loop date from first-date to last-date do | ||
| 268 | (let* ((b-date (calendar-bahai-from-absolute date)) | ||
| 269 | (i-month (extract-calendar-month b-date)) | ||
| 270 | (i-day (extract-calendar-day b-date)) | ||
| 271 | (i-year (extract-calendar-year b-date))) | ||
| 272 | (and (or (zerop month) | ||
| 273 | (= month i-month)) | ||
| 274 | (or (zerop day) | ||
| 275 | (= day i-day)) | ||
| 276 | (or (zerop year) | ||
| 277 | (= year i-year)) | ||
| 278 | (mark-visible-calendar-date | ||
| 279 | (calendar-gregorian-from-absolute | ||
| 280 | date))))))))) | ||
| 281 | 243 | ||
| 282 | (autoload 'diary-mark-entries-1 "diary-lib") | 244 | (autoload 'diary-mark-entries-1 "diary-lib") |
| 283 | 245 | ||
| @@ -291,13 +253,16 @@ window. See `diary-bahai-list-entries' for more information." | |||
| 291 | 'calendar-bahai-from-absolute | 253 | 'calendar-bahai-from-absolute |
| 292 | 'calendar-bahai-mark-date-pattern)) | 254 | 'calendar-bahai-mark-date-pattern)) |
| 293 | 255 | ||
| 256 | (define-obsolete-function-alias | ||
| 257 | 'mark-bahai-diary-entries 'diary-bahai-mark-entries "23.1") | ||
| 258 | |||
| 294 | ;;;###cal-autoload | 259 | ;;;###cal-autoload |
| 295 | (defun diary-bahai-insert-entry (arg) | 260 | (defun diary-bahai-insert-entry (arg) |
| 296 | "Insert a diary entry. | 261 | "Insert a diary entry. |
| 297 | For the Bahá'í date corresponding to the date indicated by point. | 262 | For the Bahá'í date corresponding to the date indicated by point. |
| 298 | Prefix argument ARG makes the entry nonmarking." | 263 | Prefix argument ARG makes the entry nonmarking." |
| 299 | (interactive "P") | 264 | (interactive "P") |
| 300 | (let* ((calendar-month-name-array calendar-bahai-month-name-array)) | 265 | (let ((calendar-month-name-array calendar-bahai-month-name-array)) |
| 301 | (make-diary-entry | 266 | (make-diary-entry |
| 302 | (concat bahai-diary-entry-symbol | 267 | (concat bahai-diary-entry-symbol |
| 303 | (calendar-date-string | 268 | (calendar-date-string |
| @@ -306,16 +271,19 @@ Prefix argument ARG makes the entry nonmarking." | |||
| 306 | nil t)) | 271 | nil t)) |
| 307 | arg))) | 272 | arg))) |
| 308 | 273 | ||
| 274 | (define-obsolete-function-alias | ||
| 275 | 'insert-bahai-diary-entry 'diary-bahai-insert-entry "23.1") | ||
| 276 | |||
| 309 | ;;;###cal-autoload | 277 | ;;;###cal-autoload |
| 310 | (defun diary-bahai-insert-monthly-entry (arg) | 278 | (defun diary-bahai-insert-monthly-entry (arg) |
| 311 | "Insert a monthly diary entry. | 279 | "Insert a monthly diary entry. |
| 312 | For the day of the Bahá'í month corresponding to the date indicated by point. | 280 | For the day of the Bahá'í month corresponding to the date indicated by point. |
| 313 | Prefix argument ARG makes the entry nonmarking." | 281 | Prefix argument ARG makes the entry nonmarking." |
| 314 | (interactive "P") | 282 | (interactive "P") |
| 315 | (let* ((calendar-date-display-form (if european-calendar-style | 283 | (let ((calendar-date-display-form (if european-calendar-style |
| 316 | '(day " * ") | 284 | '(day " * ") |
| 317 | '("* " day ))) | 285 | '("* " day ))) |
| 318 | (calendar-month-name-array calendar-bahai-month-name-array)) | 286 | (calendar-month-name-array calendar-bahai-month-name-array)) |
| 319 | (make-diary-entry | 287 | (make-diary-entry |
| 320 | (concat bahai-diary-entry-symbol | 288 | (concat bahai-diary-entry-symbol |
| 321 | (calendar-date-string | 289 | (calendar-date-string |
| @@ -323,16 +291,19 @@ Prefix argument ARG makes the entry nonmarking." | |||
| 323 | (calendar-absolute-from-gregorian (calendar-cursor-to-date t))))) | 291 | (calendar-absolute-from-gregorian (calendar-cursor-to-date t))))) |
| 324 | arg))) | 292 | arg))) |
| 325 | 293 | ||
| 294 | (define-obsolete-function-alias | ||
| 295 | 'insert-monthly-bahai-diary-entry 'diary-bahai-insert-monthly-entry "23.1") | ||
| 296 | |||
| 326 | ;;;###cal-autoload | 297 | ;;;###cal-autoload |
| 327 | (defun diary-bahai-insert-yearly-entry (arg) | 298 | (defun diary-bahai-insert-yearly-entry (arg) |
| 328 | "Insert an annual diary entry. | 299 | "Insert an annual diary entry. |
| 329 | For the day of the Bahá'í year corresponding to the date indicated by point. | 300 | For the day of the Bahá'í year corresponding to the date indicated by point. |
| 330 | Prefix argument ARG will make the entry nonmarking." | 301 | Prefix argument ARG will make the entry nonmarking." |
| 331 | (interactive "P") | 302 | (interactive "P") |
| 332 | (let* ((calendar-date-display-form (if european-calendar-style | 303 | (let ((calendar-date-display-form (if european-calendar-style |
| 333 | '(day " " monthname) | 304 | '(day " " monthname) |
| 334 | '(monthname " " day))) | 305 | '(monthname " " day))) |
| 335 | (calendar-month-name-array calendar-bahai-month-name-array)) | 306 | (calendar-month-name-array calendar-bahai-month-name-array)) |
| 336 | (make-diary-entry | 307 | (make-diary-entry |
| 337 | (concat bahai-diary-entry-symbol | 308 | (concat bahai-diary-entry-symbol |
| 338 | (calendar-date-string | 309 | (calendar-date-string |
| @@ -340,6 +311,9 @@ Prefix argument ARG will make the entry nonmarking." | |||
| 340 | (calendar-absolute-from-gregorian (calendar-cursor-to-date t))))) | 311 | (calendar-absolute-from-gregorian (calendar-cursor-to-date t))))) |
| 341 | arg))) | 312 | arg))) |
| 342 | 313 | ||
| 314 | (define-obsolete-function-alias | ||
| 315 | 'insert-yearly-bahai-diary-entry 'diary-bahai-insert-yearly-entry "23.1") | ||
| 316 | |||
| 343 | (defvar date) | 317 | (defvar date) |
| 344 | 318 | ||
| 345 | ;; To be called from list-sexp-diary-entries, where DATE is bound. | 319 | ;; To be called from list-sexp-diary-entries, where DATE is bound. |
| @@ -349,24 +323,6 @@ Prefix argument ARG will make the entry nonmarking." | |||
| 349 | (format "Bahá'í date: %s" (calendar-bahai-date-string date))) | 323 | (format "Bahá'í date: %s" (calendar-bahai-date-string date))) |
| 350 | 324 | ||
| 351 | 325 | ||
| 352 | ;; Backward compatibility. | ||
| 353 | (define-obsolete-function-alias | ||
| 354 | 'list-bahai-diary-entries 'diary-bahai-list-entries "23.1") | ||
| 355 | (define-obsolete-function-alias | ||
| 356 | 'mark-bahai-diary-entries 'diary-bahai-mark-entries "23.1") | ||
| 357 | (define-obsolete-function-alias | ||
| 358 | 'insert-bahai-diary-entry 'diary-bahai-insert-entry "23.1") | ||
| 359 | (define-obsolete-function-alias | ||
| 360 | 'insert-monthly-bahai-diary-entry 'diary-bahai-insert-monthly-entry "23.1") | ||
| 361 | (define-obsolete-function-alias | ||
| 362 | 'insert-yearly-bahai-diary-entry 'diary-bahai-insert-yearly-entry "23.1") | ||
| 363 | (define-obsolete-function-alias | ||
| 364 | 'mark-bahai-calendar-date-pattern 'calendar-bahai-mark-date-pattern "23.1") | ||
| 365 | (define-obsolete-function-alias | ||
| 366 | 'calendar-goto-bahai-date 'calendar-bahai-goto-date "23.1") | ||
| 367 | (define-obsolete-function-alias | ||
| 368 | 'calendar-print-bahai-date 'calendar-bahai-print-date "23.1") | ||
| 369 | |||
| 370 | (provide 'cal-bahai) | 326 | (provide 'cal-bahai) |
| 371 | 327 | ||
| 372 | ;; Local Variables: | 328 | ;; Local Variables: |