aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGlenn Morris2012-05-05 14:31:41 -0700
committerGlenn Morris2012-05-05 14:31:41 -0700
commit48176e8bacea7a462e28c472b6dd7a052355b33e (patch)
tree88f5730c7e4d63f8423da6e4835c2c286ae48a4f
parenta43f98b3959cf9435de7ea5a5bb44e3fbd061085 (diff)
downloademacs-48176e8bacea7a462e28c472b6dd7a052355b33e.tar.gz
emacs-48176e8bacea7a462e28c472b6dd7a052355b33e.zip
Optionally include holidays in cal-html output
* lisp/calendar/cal-html.el: (cal-html-holidays): New option. (cal-html-css-default): Add holiday entry. (holiday-in-range): Autoload it. (cal-html-htmlify-entry): Add optional class argument. (cal-html-htmlify-list): Add optional holidays argument. (cal-html-insert-agenda-days): Include holidays in the output. (cal-html-one-month): Maybe include holidays.
-rw-r--r--etc/NEWS4
-rw-r--r--lisp/ChangeLog10
-rw-r--r--lisp/calendar/cal-html.el43
3 files changed, 44 insertions, 13 deletions
diff --git a/etc/NEWS b/etc/NEWS
index c47fd166215..57c492ffa4c 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -94,6 +94,10 @@ see the `apropos' Custom group for details.
94**** The old options whose values specified faces to use were removed 94**** The old options whose values specified faces to use were removed
95(i.e. `apropos-symbol-face', `apropos-keybinding-face', etc.). 95(i.e. `apropos-symbol-face', `apropos-keybinding-face', etc.).
96 96
97** Calendar
98
99*** The calendars produced by cal-html can optionally include holidays.
100
97** Customize 101** Customize
98 102
99*** `custom-reset-button-menu' now defaults to t. 103*** `custom-reset-button-menu' now defaults to t.
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index f66cd887adc..43045fbbbd2 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,5 +1,15 @@
12012-05-05 Glenn Morris <rgm@gnu.org> 12012-05-05 Glenn Morris <rgm@gnu.org>
2 2
3 * calendar/cal-html.el: Optionally include holidays in the output.
4 Suggested by Ed Reingold <reingold@emr.cs.iit.edu>.
5 (cal-html-holidays): New option.
6 (cal-html-css-default): Add holiday entry.
7 (holiday-in-range): Autoload it.
8 (cal-html-htmlify-entry): Add optional class argument.
9 (cal-html-htmlify-list): Add optional holidays argument.
10 (cal-html-insert-agenda-days): Include holidays in the output.
11 (cal-html-one-month): Maybe include holidays.
12
3 * calendar/holidays.el (holiday-in-range): 13 * calendar/holidays.el (holiday-in-range):
4 Move here from cal-tex-list-holidays. 14 Move here from cal-tex-list-holidays.
5 * calendar/cal-tex.el (cal-tex-list-holidays): 15 * calendar/cal-tex.el (cal-tex-list-holidays):
diff --git a/lisp/calendar/cal-html.el b/lisp/calendar/cal-html.el
index 8073295a412..679fae98bc8 100644
--- a/lisp/calendar/cal-html.el
+++ b/lisp/calendar/cal-html.el
@@ -66,6 +66,12 @@
66 (string :tag "Sat")) 66 (string :tag "Sat"))
67 :group 'calendar-html) 67 :group 'calendar-html)
68 68
69(defcustom cal-html-holidays t
70 "If non-nil, include holidays as well as diary entries."
71 :version "24.2"
72 :type 'boolean
73 :group 'calendar-html)
74
69(defcustom cal-html-css-default 75(defcustom cal-html-css-default
70 (concat 76 (concat
71 "<STYLE TYPE=\"text/css\">\n" 77 "<STYLE TYPE=\"text/css\">\n"
@@ -82,9 +88,11 @@
82 " SPAN.NO-YEAR { color: #0b3; font-weight: bold; }\n" 88 " SPAN.NO-YEAR { color: #0b3; font-weight: bold; }\n"
83 " SPAN.ANN { color: #0bb; font-weight: bold; }\n" 89 " SPAN.ANN { color: #0bb; font-weight: bold; }\n"
84 " SPAN.BLOCK { color: #048; font-style: italic; }\n" 90 " SPAN.BLOCK { color: #048; font-style: italic; }\n"
91 " SPAN.HOLIDAY { color: #f00; font-weight: bold; }\n"
85 "</STYLE>\n\n") 92 "</STYLE>\n\n")
86 "Default cal-html css style. You can override this with a \"cal.css\" file." 93 "Default cal-html css style. You can override this with a \"cal.css\" file."
87 :type 'string 94 :type 'string
95 :version "24.2" ; added SPAN.HOLIDAY
88 :group 'calendar-html) 96 :group 'calendar-html)
89 97
90;;; End customizable variables. 98;;; End customizable variables.
@@ -227,6 +235,8 @@ Contains links to previous and next month and year, and current minical."
227;;------------------------------------------------------------ 235;;------------------------------------------------------------
228;; minical: a small month calendar with links 236;; minical: a small month calendar with links
229;;------------------------------------------------------------ 237;;------------------------------------------------------------
238(autoload 'holiday-in-range "holidays")
239
230(defun cal-html-insert-minical (month year) 240(defun cal-html-insert-minical (month year)
231 "Insert a minical for numeric MONTH of YEAR." 241 "Insert a minical for numeric MONTH of YEAR."
232 (let* ((blank-days ; at start of month 242 (let* ((blank-days ; at start of month
@@ -313,10 +323,12 @@ Characters are replaced according to `cal-html-html-subst-list'."
313 "")) 323 ""))
314 324
315 325
316(defun cal-html-htmlify-entry (entry) 326(defun cal-html-htmlify-entry (entry &optional class)
317 "Convert a diary entry ENTRY to html with the appropriate class specifier." 327 "Convert a diary entry ENTRY to html with the appropriate class specifier.
328Optional argument CLASS is the class specifier to use."
318 (let ((start 329 (let ((start
319 (cond 330 (cond
331 (class)
320 ((string-match "block" (nth 2 entry)) "BLOCK") 332 ((string-match "block" (nth 2 entry)) "BLOCK")
321 ((string-match "anniversary" (nth 2 entry)) "ANN") 333 ((string-match "anniversary" (nth 2 entry)) "ANN")
322 ((not (string-match 334 ((not (string-match
@@ -328,10 +340,12 @@ Characters are replaced according to `cal-html-html-subst-list'."
328 (cal-html-htmlify-string (cadr entry))))) 340 (cal-html-htmlify-string (cadr entry)))))
329 341
330 342
331(defun cal-html-htmlify-list (date-list date) 343(defun cal-html-htmlify-list (date-list date &optional holidays)
332 "Return a string of concatenated, HTML-ified diary entries. 344 "Return a string of concatenated, HTML-ified diary entries.
333DATE-LIST is a list of diary entries. Return only those matching DATE." 345DATE-LIST is a list of diary entries. Return only those matching DATE.
334 (mapconcat (lambda (x) (cal-html-htmlify-entry x)) 346Optional argument HOLIDAYS non-nil means the input is actually a list
347of holidays, rather than diary entries."
348 (mapconcat (lambda (x) (cal-html-htmlify-entry x (if holidays "HOLIDAY")))
335 (let (result) 349 (let (result)
336 (dolist (p date-list (reverse result)) 350 (dolist (p date-list (reverse result))
337 (and (car p) 351 (and (car p)
@@ -351,11 +365,11 @@ DATE-LIST is a list of diary entries. Return only those matching DATE."
351 (diary-list-entries (calendar-gregorian-from-absolute d1) 365 (diary-list-entries (calendar-gregorian-from-absolute d1)
352 (1+ (- d2 d1)) t)) 366 (1+ (- d2 d1)) t))
353 367
354 368(defun cal-html-insert-agenda-days (month year diary-list holiday-list)
355(defun cal-html-insert-agenda-days (month year diary-list)
356 "Insert HTML commands for a range of days in monthly calendars. 369 "Insert HTML commands for a range of days in monthly calendars.
357HTML commands are inserted for the days of the numeric MONTH in 370HTML commands are inserted for the days of the numeric MONTH in
358four-digit YEAR. Diary entries in DIARY-LIST are included." 371four-digit YEAR. Includes diary entries in DIARY-LIST, and
372holidays in HOLIDAY-LIST."
359 (let ((blank-days ; at start of month 373 (let ((blank-days ; at start of month
360 (mod (- (calendar-day-of-week (list month 1 year)) 374 (mod (- (calendar-day-of-week (list month 1 year))
361 calendar-week-start-day) 375 calendar-week-start-day)
@@ -381,6 +395,8 @@ four-digit YEAR. Diary entries in DIARY-LIST are included."
381 cal-html-e-tableheader-string 395 cal-html-e-tableheader-string
382 ;; Diary entries. 396 ;; Diary entries.
383 cal-html-b-tabledata-string 397 cal-html-b-tabledata-string
398 (cal-html-htmlify-list holiday-list date t)
399 (and holiday-list diary-list "<BR>\n")
384 (cal-html-htmlify-list diary-list date) 400 (cal-html-htmlify-list diary-list date)
385 cal-html-e-tabledata-string 401 cal-html-e-tabledata-string
386 cal-html-e-tablerow-string) 402 cal-html-e-tablerow-string)
@@ -395,16 +411,17 @@ four-digit YEAR. Diary entries in DIARY-LIST are included."
395 411
396(defun cal-html-one-month (month year dir) 412(defun cal-html-one-month (month year dir)
397 "Write an HTML calendar file for numeric MONTH of YEAR in directory DIR." 413 "Write an HTML calendar file for numeric MONTH of YEAR in directory DIR."
398 (let ((diary-list (cal-html-list-diary-entries 414 (let* ((d1 (calendar-absolute-from-gregorian (list month 1 year)))
399 (calendar-absolute-from-gregorian (list month 1 year)) 415 (d2 (calendar-absolute-from-gregorian
400 (calendar-absolute-from-gregorian
401 (list month 416 (list month
402 (calendar-last-day-of-month month year) 417 (calendar-last-day-of-month month year)
403 year))))) 418 year)))
419 (diary-list (cal-html-list-diary-entries d1 d2))
420 (holiday-list (if cal-html-holidays (holiday-in-range d1 d2))))
404 (with-temp-buffer 421 (with-temp-buffer
405 (insert cal-html-b-document-string) 422 (insert cal-html-b-document-string)
406 (cal-html-insert-month-header month year) 423 (cal-html-insert-month-header month year)
407 (cal-html-insert-agenda-days month year diary-list) 424 (cal-html-insert-agenda-days month year diary-list holiday-list)
408 (insert cal-html-e-document-string) 425 (insert cal-html-e-document-string)
409 (write-file (expand-file-name 426 (write-file (expand-file-name
410 (cal-html-monthpage-name month year) dir))))) 427 (cal-html-monthpage-name month year) dir)))))