X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/d804ada24efd28b8574e2d9e5d87c364e4223e84..c8d3a25c0981020e1b8aa3bf96a4a0059be82431:/lisp/calendar/cal-tex.el diff --git a/lisp/calendar/cal-tex.el b/lisp/calendar/cal-tex.el index 1faa71efec..2452f44448 100644 --- a/lisp/calendar/cal-tex.el +++ b/lisp/calendar/cal-tex.el @@ -1,20 +1,20 @@ ;;; cal-tex.el --- calendar functions for printing calendars with LaTeX -;; Copyright (C) 1995, 2001, 2002, 2003, 2004, 2005, 2006, 2007 -;; Free Software Foundation, Inc. +;; Copyright (C) 1995, 2001-2012 Free Software Foundation, Inc. ;; Author: Steve Fisk -;; Edward M. Reingold +;; Edward M. Reingold ;; Maintainer: Glenn Morris ;; Keywords: calendar ;; Human-Keywords: Calendar, LaTeX +;; Package: calendar ;; This file is part of GNU Emacs. -;; GNU Emacs is free software; you can redistribute it and/or modify +;; GNU Emacs is free software: you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by -;; the Free Software Foundation; either version 3, or (at your option) -;; any later version. +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. ;; GNU Emacs is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -22,9 +22,7 @@ ;; GNU General Public License for more details. ;; You should have received a copy of the GNU General Public License -;; along with GNU Emacs; see the file COPYING. If not, write to the -;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, -;; Boston, MA 02110-1301, USA. +;; along with GNU Emacs. If not, see . ;;; Commentary: @@ -60,14 +58,15 @@ (require 'calendar) -(autoload 'diary-list-entries "diary-lib" nil t) -(autoload 'calendar-holiday-list "holidays" nil t) -(autoload 'calendar-iso-from-absolute "cal-iso" nil t) - ;;; ;;; Customizable variables ;;; +(defgroup calendar-tex nil + "Options for printing calendar with LaTeX." + :prefix "cal-tex-" + :group 'calendar) + (defcustom cal-tex-which-days '(0 1 2 3 4 5 6) "The days of the week that are displayed on the portrait monthly calendar. Sunday is 0, Monday is 1, and so on. The default is to print from Sunday to @@ -96,7 +95,7 @@ At present, this only affects the daily filofax calendar." :group 'calendar-tex) (defcustom cal-tex-daily-string - '(let* ((year (extract-calendar-year date)) + '(let* ((year (calendar-extract-year date)) (day (calendar-day-number date)) (days-remaining (- (calendar-day-number (list 12 31 year)) day))) (format "%d/%d" day days-remaining)) @@ -135,7 +134,7 @@ At present, this only affects `cal-tex-cursor-day'." (defcustom cal-tex-daily-end 20 "The last hour of the daily LaTeX calendar page. -At present, this only affects `cal-tex-cursor-day'" +At present, this only affects `cal-tex-cursor-day'." :type 'integer :group 'calendar-tex) @@ -143,13 +142,15 @@ At present, this only affects `cal-tex-cursor-day'" "A string giving extra LaTeX commands to insert in the calendar preamble. For example, to include extra packages: \"\\\\usepackage{foo}\\n\\\\usepackage{bar}\\n\"." - :type 'string + :type '(choice (const nil) + ;; An example to help people format things in custom. + (string :value "\\usepackage{foo}\n\\usepackage{bar}\n")) :group 'calendar-tex :version "22.1") (defcustom cal-tex-hook nil "List of functions called after any LaTeX calendar buffer is generated. -You can use this to do postprocessing on the buffer. For example, to change +You can use this to do post-processing on the buffer. For example, to change characters with diacritical marks to their LaTeX equivalents, use (add-hook 'cal-tex-hook (lambda () (iso-iso2tex (point-min) (point-max))))" @@ -236,37 +237,17 @@ The names are taken from `calendar-day-name-array'.") "LaTeX code to insert one box with date info in calendar. This definition is the heart of the calendar!") -(defun cal-tex-list-holidays (d1 d2) - "Generate a list of all holidays from absolute date D1 to D2." - (let* ((start (calendar-gregorian-from-absolute d1)) - (displayed-month (extract-calendar-month start)) - (displayed-year (extract-calendar-year start)) - (end (calendar-gregorian-from-absolute d2)) - (end-month (extract-calendar-month end)) - (end-year (extract-calendar-year end)) - (number-of-intervals - (1+ (/ (calendar-interval displayed-month displayed-year - end-month end-year) - 3))) - holidays in-range a) - (increment-calendar-month displayed-month displayed-year 1) - (dotimes (idummy number-of-intervals) - (setq holidays (append holidays (calendar-holiday-list))) - (increment-calendar-month displayed-month displayed-year 3)) - (dolist (hol holidays) - (and (car hol) - (setq a (calendar-absolute-from-gregorian (car hol))) - (and (<= d1 a) (<= a d2)) - (setq in-range (append (list hol) in-range)))) - in-range)) +(autoload 'holiday-in-range "holidays") + +(define-obsolete-function-alias 'cal-tex-list-holidays 'holiday-in-range "24.2") + +(autoload 'diary-list-entries "diary-lib") (defun cal-tex-list-diary-entries (d1 d2) "Generate a list of all diary-entries from absolute date D1 to D2." - (let ((diary-list-include-blanks nil) - (diary-display-hook 'ignore)) - (diary-list-entries - (calendar-gregorian-from-absolute d1) - (1+ (- d2 d1))))) + (let (diary-list-include-blanks) + (diary-list-entries (calendar-gregorian-from-absolute d1) + (1+ (- d2 d1)) t))) (defun cal-tex-preamble (&optional args) "Insert the LaTeX calendar preamble into `cal-tex-buffer'. @@ -307,19 +288,25 @@ Optional string ARGS are included as options for the article document class." ;;; Yearly calendars ;;; -(defun cal-tex-cursor-year (&optional arg) +;;;###cal-autoload +(defun cal-tex-cursor-year (&optional n event) "Make a buffer with LaTeX commands for the year cursor is on. -Optional prefix argument ARG specifies number of years." - (interactive "p") - (cal-tex-year (extract-calendar-year (calendar-cursor-to-date t)) - (or arg 1))) - -(defun cal-tex-cursor-year-landscape (&optional arg) +Optional prefix argument N specifies number of years. +Optional EVENT indicates a buffer position to use instead of point." + (interactive (list (prefix-numeric-value current-prefix-arg) + last-nonmenu-event)) + (cal-tex-year (calendar-extract-year (calendar-cursor-to-date t event)) + (or n 1))) + +;;;###cal-autoload +(defun cal-tex-cursor-year-landscape (&optional n event) "Make a buffer with LaTeX commands for the year cursor is on. -Optional prefix argument ARG specifies number of years." - (interactive "p") - (cal-tex-year (extract-calendar-year (calendar-cursor-to-date t)) - (or arg 1) t)) +Optional prefix argument N specifies number of years. +Optional EVENT indicates a buffer position to use instead of point." + (interactive (list (prefix-numeric-value current-prefix-arg) + last-nonmenu-event)) + (cal-tex-year (calendar-extract-year (calendar-cursor-to-date t event)) + (or n 1) t)) (defun cal-tex-year (year n &optional landscape) "Make a one page yearly calendar of YEAR; do this for N years. @@ -357,12 +344,15 @@ landscape mode with three rows of four months each." (run-hooks 'cal-tex-year-hook)) (run-hooks 'cal-tex-hook)) -(defun cal-tex-cursor-filofax-year (&optional arg) +;;;###cal-autoload +(defun cal-tex-cursor-filofax-year (&optional n event) "Make a Filofax one page yearly calendar of year indicated by cursor. -Optional prefix argument ARG specifies number of years." - (interactive "p") - (let ((n (or arg 1)) - (year (extract-calendar-year (calendar-cursor-to-date t)))) +Optional prefix argument N specifies number of years. +Optional EVENT indicates a buffer position to use instead of point." + (interactive (list (prefix-numeric-value current-prefix-arg) + last-nonmenu-event)) + (or n (setq n 1)) + (let ((year (calendar-extract-year (calendar-cursor-to-date t event)))) (cal-tex-preamble "twoside") (cal-tex-cmd "\\textwidth 3.25in") (cal-tex-cmd "\\textheight 6.5in") @@ -409,121 +399,122 @@ Optional prefix argument ARG specifies number of years." ;;; Monthly calendars ;;; -(defun cal-tex-cursor-month-landscape (&optional arg) +;;;###cal-autoload +(defun cal-tex-cursor-month-landscape (&optional n event) "Make a LaTeX calendar buffer for the month the cursor is on. -Optional prefix argument ARG specifies number of months to be +Optional prefix argument N specifies number of months to be produced (default 1). The output is in landscape format, one month to a page. It shows holiday and diary entries if -`cal-tex-holidays' and `cal-tex-diary', respectively, are non-nil." - (interactive "p") - (let* ((n (or arg 1)) - (date (calendar-cursor-to-date t)) - (month (extract-calendar-month date)) - (year (extract-calendar-year date)) +`cal-tex-holidays' and `cal-tex-diary', respectively, are non-nil. +Optional EVENT indicates a buffer position to use instead of point." + (interactive (list (prefix-numeric-value current-prefix-arg) + last-nonmenu-event)) + (or n (setq n 1)) + (let* ((date (calendar-cursor-to-date t event)) + (month (calendar-extract-month date)) + (year (calendar-extract-year date)) (end-month month) (end-year year) (cal-tex-which-days '(0 1 2 3 4 5 6)) (d1 (calendar-absolute-from-gregorian (list month 1 year))) - (d2 (calendar-absolute-from-gregorian - (list end-month - (calendar-last-day-of-month end-month end-year) - end-year)))) - (increment-calendar-month end-month end-year (1- n)) - (let ((diary-list (if cal-tex-diary - (cal-tex-list-diary-entries d1 d2))) - (holidays (if cal-tex-holidays - (cal-tex-list-holidays d1 d2))) - other-month other-year small-months-at-start) - (cal-tex-insert-preamble (cal-tex-number-weeks month year 1) t "12pt") - (cal-tex-cmd cal-tex-cal-one-month) - (dotimes (i n) - (setq other-month month - other-year year) - (increment-calendar-month other-month other-year -1) - (insert (cal-tex-mini-calendar other-month other-year "lastmonth" - "\\cellwidth" "\\cellheight")) - (increment-calendar-month other-month other-year 2) - (insert (cal-tex-mini-calendar other-month other-year "nextmonth" - "\\cellwidth" "\\cellheight")) - (cal-tex-insert-month-header 1 month year month year) - (cal-tex-insert-day-names) - (cal-tex-nl ".2cm") - (if (setq small-months-at-start - (< 1 (mod (- (calendar-day-of-week (list month 1 year)) + (d2 (progn + (calendar-increment-month end-month end-year (1- n)) + (calendar-absolute-from-gregorian + (list end-month + (calendar-last-day-of-month end-month end-year) + end-year)))) + (diary-list (if cal-tex-diary (cal-tex-list-diary-entries d1 d2))) + (holidays (if cal-tex-holidays (holiday-in-range d1 d2))) + other-month other-year small-months-at-start) + (cal-tex-insert-preamble (cal-tex-number-weeks month year 1) t "12pt") + (cal-tex-cmd cal-tex-cal-one-month) + (dotimes (i n) + (setq other-month month + other-year year) + (calendar-increment-month other-month other-year -1) + (insert (cal-tex-mini-calendar other-month other-year "lastmonth" + "\\cellwidth" "\\cellheight")) + (calendar-increment-month other-month other-year 2) + (insert (cal-tex-mini-calendar other-month other-year "nextmonth" + "\\cellwidth" "\\cellheight")) + (cal-tex-insert-month-header 1 month year month year) + (cal-tex-insert-day-names) + (cal-tex-nl ".2cm") + (if (setq small-months-at-start + (< 1 (mod (- (calendar-day-of-week (list month 1 year)) calendar-week-start-day) - 7))) - (insert "\\lastmonth\\nextmonth\\hspace*{-2\\cellwidth}")) - (cal-tex-insert-blank-days month year cal-tex-day-prefix) - (cal-tex-insert-days month year diary-list holidays - cal-tex-day-prefix) - (cal-tex-insert-blank-days-at-end month year cal-tex-day-prefix) - (if (and (not small-months-at-start) - (< 1 (mod (- (1- calendar-week-start-day) - (calendar-day-of-week - (list month - (calendar-last-day-of-month month year) - year))) - 7))) - (insert "\\vspace*{-\\cellwidth}\\hspace*{-2\\cellwidth}" - "\\lastmonth\\nextmonth% + 7))) + (insert "\\lastmonth\\nextmonth\\hspace*{-2\\cellwidth}")) + (cal-tex-insert-blank-days month year cal-tex-day-prefix) + (cal-tex-insert-days month year diary-list holidays + cal-tex-day-prefix) + (cal-tex-insert-blank-days-at-end month year cal-tex-day-prefix) + (if (and (not small-months-at-start) + (< 1 (mod (- (1- calendar-week-start-day) + (calendar-day-of-week + (list month + (calendar-last-day-of-month month year) + year))) + 7))) + (insert "\\vspace*{-\\cellwidth}\\hspace*{-2\\cellwidth}" + "\\lastmonth\\nextmonth% ")) - (unless (= i (1- n)) - (run-hooks 'cal-tex-month-hook) - (cal-tex-newpage) - (increment-calendar-month month year 1) - (cal-tex-vspace "-2cm") - (cal-tex-insert-preamble - (cal-tex-number-weeks month year 1) t "12pt" t))) - (cal-tex-end-document) - (run-hooks 'cal-tex-hook)))) - -(defun cal-tex-cursor-month (arg) + (unless (= i (1- n)) + (run-hooks 'cal-tex-month-hook) + (cal-tex-newpage) + (calendar-increment-month month year 1) + (cal-tex-vspace "-2cm") + (cal-tex-insert-preamble + (cal-tex-number-weeks month year 1) t "12pt" t)))) + (cal-tex-end-document) + (run-hooks 'cal-tex-hook)) + +;;;###cal-autoload +(defun cal-tex-cursor-month (&optional n event) "Make a LaTeX calendar buffer for the month the cursor is on. -Optional prefix argument ARG specifies number of months to be +Optional prefix argument N specifies number of months to be produced (default 1). The calendar is condensed onto one page. It shows holiday and diary entries if `cal-tex-holidays' and -`cal-tex-diary', respectively, are non-nil." - (interactive "p") - (let* ((date (calendar-cursor-to-date t)) - (month (extract-calendar-month date)) - (year (extract-calendar-year date)) +`cal-tex-diary', respectively, are non-nil. Optional EVENT +indicates a buffer position to use instead of point." + (interactive (list (prefix-numeric-value current-prefix-arg) + last-nonmenu-event)) + (or n (setq n 1)) + (let* ((date (calendar-cursor-to-date t event)) + (month (calendar-extract-month date)) + (year (calendar-extract-year date)) (end-month month) (end-year year) - (n (or arg 1)) + ;; FIXME -landscape sets cal-tex-which-days? (d1 (calendar-absolute-from-gregorian (list month 1 year))) - (d2 (calendar-absolute-from-gregorian - (list end-month - (calendar-last-day-of-month end-month end-year) - end-year)))) - (increment-calendar-month end-month end-year (1- n)) - (let ((diary-list (if cal-tex-diary - (cal-tex-list-diary-entries d1 d2))) - (holidays (if cal-tex-holidays - (cal-tex-list-holidays d1 d2))) - other-month other-year) - (cal-tex-insert-preamble (cal-tex-number-weeks month year n) nil"12pt") - (if (> n 1) - (cal-tex-cmd cal-tex-cal-multi-month) - (cal-tex-cmd cal-tex-cal-one-month)) - (cal-tex-insert-month-header n month year end-month end-year) - (cal-tex-insert-day-names) - (cal-tex-nl ".2cm") - (cal-tex-insert-blank-days month year cal-tex-day-prefix) - (dotimes (idummy n) - (setq other-month month - other-year year) - (cal-tex-insert-days month year diary-list holidays cal-tex-day-prefix) - (when (= (mod (calendar-absolute-from-gregorian - (list month - (calendar-last-day-of-month month year) - year)) - 7) - 6) ; last day of month was Saturday - (cal-tex-hfill) - (cal-tex-nl)) - (increment-calendar-month month year 1)) - (cal-tex-insert-blank-days-at-end end-month end-year cal-tex-day-prefix) - (cal-tex-end-document))) + (d2 (progn + (calendar-increment-month end-month end-year (1- n)) + (calendar-absolute-from-gregorian + (list end-month + (calendar-last-day-of-month end-month end-year) + end-year)))) + (diary-list (if cal-tex-diary (cal-tex-list-diary-entries d1 d2))) + (holidays (if cal-tex-holidays (holiday-in-range d1 d2)))) + (cal-tex-insert-preamble (cal-tex-number-weeks month year n) nil "12pt") + (if (> n 1) + (cal-tex-cmd cal-tex-cal-multi-month) + (cal-tex-cmd cal-tex-cal-one-month)) + (cal-tex-insert-month-header n month year end-month end-year) + (cal-tex-insert-day-names) + (cal-tex-nl ".2cm") + (cal-tex-insert-blank-days month year cal-tex-day-prefix) + (dotimes (_idummy n) + (cal-tex-insert-days month year diary-list holidays cal-tex-day-prefix) + (when (= (calendar-week-end-day) + (calendar-day-of-week + (list month + (calendar-last-day-of-month month year) + year))) ; last day of month was last day of week + (cal-tex-hfill) + (cal-tex-nl)) + (calendar-increment-month month year 1)) + (cal-tex-insert-blank-days-at-end end-month end-year cal-tex-day-prefix)) + (cal-tex-end-document) (run-hooks 'cal-tex-hook)) (defun cal-tex-insert-days (month year diary-list holidays day-format) @@ -555,13 +546,14 @@ are included. Each day is formatted using format DAY-FORMAT." (defun cal-tex-insert-day-names () "Insert the names of the days at top of a monthly calendar." - (dotimes (i 7) - (if (memq i cal-tex-which-days) - (insert (format cal-tex-day-name-format - (cal-tex-LaTeXify-string - (aref calendar-day-name-array - (mod (+ calendar-week-start-day i) 7)))))) - (cal-tex-comment))) + (let (j) + (dotimes (i 7) + (if (memq (setq j (mod (+ calendar-week-start-day i) 7)) + cal-tex-which-days) + (insert (format cal-tex-day-name-format + (cal-tex-LaTeXify-string + (aref calendar-day-name-array j))))) + (cal-tex-comment)))) (defun cal-tex-insert-month-header (n month year end-month end-year) "Create a title for a calendar. @@ -588,7 +580,7 @@ blank, no days are inserted." calendar-week-start-day) 7))) (dotimes (i blank-days) - (if (memq i cal-tex-which-days) + (if (memq (mod (+ calendar-week-start-day i) 7) cal-tex-which-days) (insert (format day-format " " " ") "{}{}{}{}%\n")))))) (defun cal-tex-insert-blank-days-at-end (month year day-format) @@ -601,47 +593,48 @@ The entry is formatted using DAY-FORMAT." (mod (- (calendar-day-of-week (list month last-day year)) calendar-week-start-day) - 7))) - (calendar-for-loop i from (1+ blank-days) to 6 do - (if (memq i cal-tex-which-days) - (insert (format day-format "" "") "{}{}{}{}%\n")))))) + 7)) + (i blank-days)) + (while (<= (setq i (1+ i)) 6) + (if (memq (mod (+ calendar-week-start-day i) 7) cal-tex-which-days) + (insert (format day-format "" "") "{}{}{}{}%\n")))))) (defun cal-tex-first-blank-p (month year) "Determine if any days of the first week will be printed. Return t if there will there be any days of the first week printed in the calendar starting in MONTH YEAR." - (let (any-days the-saturday) ; the day of week of 1st Saturday - (dotimes (i 7) - (if (= 6 (calendar-day-of-week (list month (1+ i) year))) - (setq the-saturday (1+ i)))) - (dotimes (i the-saturday) - (if (memq (calendar-day-of-week (list month (1+ i) year)) - cal-tex-which-days) - (setq any-days t))) - any-days)) + ;; Check days 1-7 of the month, until we find the last day of the week. + (catch 'found + (let (dow) + (dotimes (i 7) + (if (memq (setq dow (calendar-day-of-week (list month (1+ i) year))) + cal-tex-which-days) + (throw 'found t) + (if (= dow (calendar-week-end-day)) (throw 'found nil))))))) (defun cal-tex-last-blank-p (month year) "Determine if any days of the last week will be printed. Return t if there will there be any days of the last week printed in the calendar starting in MONTH YEAR." - (let ((last-day (calendar-last-day-of-month month year)) - any-days the-sunday) ; the day of week of last Sunday - (calendar-for-loop i from (- last-day 6) to last-day do - (if (= 0 (calendar-day-of-week (list month i year))) - (setq the-sunday i))) - (calendar-for-loop i from the-sunday to last-day do - (if (memq (calendar-day-of-week (list month i year)) - cal-tex-which-days) - (setq any-days t))) - any-days)) + ;; Check backwards from the last day of the month, until we find the + ;; start of the last week in the month. + (catch 'found + (let ((last-day (calendar-last-day-of-month month year)) + dow) + (dotimes (i 7) + (if (memq (setq dow (calendar-day-of-week + (list month (- last-day i) year))) + cal-tex-which-days) + (throw 'found t) + (if (= dow calendar-week-start-day) (throw 'found nil))))))) (defun cal-tex-number-weeks (month year n) "Determine the number of weeks in a range of dates. -Compute the number of weeks in the calendar starting with MONTH and YEAR, +Compute the number of weeks in the calendar starting with MONTH and YEAR, and lasting N months, including only the days in WHICH-DAYS. As it stands, this is only an upper bound." (let ((d (list month 1 year))) - (increment-calendar-month month year (1- n)) + (calendar-increment-month month year (1- n)) (/ (- (calendar-dayname-on-or-before calendar-week-start-day (+ 7 (calendar-absolute-from-gregorian @@ -662,25 +655,27 @@ this is only an upper bound." ;; TODO cal-tex-diary-support. ;; TODO respect cal-tex-daily-start,end (see cal-tex-week-hours). -(defun cal-tex-cursor-week (&optional arg) +;;;###cal-autoload +(defun cal-tex-cursor-week (&optional n event) "Make a LaTeX calendar buffer for a two-page one-week calendar. It applies to the week that point is in. The optional prefix -argument ARG specifies the number of weeks (default 1). The calendar +argument N specifies number of weeks (default 1). The calendar shows holidays if `cal-tex-holidays' is non-nil (note that diary entries are not shown). The calendar shows the hours 8-12am, 1-5pm." - (interactive "p") - (let* ((n (or arg 1)) - (date (calendar-gregorian-from-absolute + (interactive (list (prefix-numeric-value current-prefix-arg) + last-nonmenu-event)) + (or n (setq n 1)) + (let* ((date (calendar-gregorian-from-absolute (calendar-dayname-on-or-before calendar-week-start-day (calendar-absolute-from-gregorian - (calendar-cursor-to-date t))))) - (month (extract-calendar-month date)) - (year (extract-calendar-year date)) + (calendar-cursor-to-date t event))))) + (month (calendar-extract-month date)) + (year (calendar-extract-year date)) (d1 (calendar-absolute-from-gregorian date)) (d2 (+ (* 7 n) d1)) (holidays (if cal-tex-holidays - (cal-tex-list-holidays d1 d2)))) + (holiday-in-range d1 d2)))) (cal-tex-preamble "11pt") (cal-tex-cmd "\\textwidth 6.5in") (cal-tex-cmd "\\textheight 10.5in") @@ -700,12 +695,12 @@ entries are not shown). The calendar shows the hours 8-12am, 1-5pm." (cal-tex-e-center) (cal-tex-hspace "-.2in") (cal-tex-b-parbox "l" "7in") - (dotimes (jdummy 7) + (dotimes (_jdummy 7) (cal-tex-week-hours date holidays "3.1") (setq date (cal-tex-incr-date date))) (cal-tex-e-parbox) - (setq month (extract-calendar-month date) - year (extract-calendar-year date)) + (setq month (calendar-extract-month date) + year (calendar-extract-year date)) (unless (= i (1- n)) (run-hooks 'cal-tex-week-hook) (cal-tex-newpage))) @@ -714,26 +709,28 @@ entries are not shown). The calendar shows the hours 8-12am, 1-5pm." ;; TODO cal-tex-diary support. ;; TODO respect cal-tex-daily-start,end (see cal-tex-week-hours). -(defun cal-tex-cursor-week2 (&optional arg) +;;;###cal-autoload +(defun cal-tex-cursor-week2 (&optional n event) "Make a LaTeX calendar buffer for a two-page one-week calendar. It applies to the week that point is in. Optional prefix -argument ARG specifies number of weeks (default 1). The calendar +argument N specifies number of weeks (default 1). The calendar shows holidays if `cal-tex-holidays' is non-nil (note that diary -entries are not shown). The calendar shows the hours 8-12am, 1-5pm" - (interactive "p") - (let* ((n (or arg 1)) - (date (calendar-gregorian-from-absolute +entries are not shown). The calendar shows the hours 8-12am, 1-5pm. +Optional EVENT indicates a buffer position to use instead of point." + (interactive (list (prefix-numeric-value current-prefix-arg) + last-nonmenu-event)) + (or n (setq n 1)) + (let* ((date (calendar-gregorian-from-absolute (calendar-dayname-on-or-before calendar-week-start-day (calendar-absolute-from-gregorian - (calendar-cursor-to-date t))))) - (month (extract-calendar-month date)) - (year (extract-calendar-year date)) - (d date) + (calendar-cursor-to-date t event))))) + (month (calendar-extract-month date)) + (year (calendar-extract-year date)) (d1 (calendar-absolute-from-gregorian date)) (d2 (+ (* 7 n) d1)) (holidays (if cal-tex-holidays - (cal-tex-list-holidays d1 d2)))) + (holiday-in-range d1 d2)))) (cal-tex-preamble "12pt") (cal-tex-cmd "\\textwidth 6.5in") (cal-tex-cmd "\\textheight 10.5in") @@ -753,22 +750,22 @@ entries are not shown). The calendar shows the hours 8-12am, 1-5pm" (cal-tex-e-center) (cal-tex-hspace "-.2in") (cal-tex-b-parbox "l" "\\textwidth") - (dotimes (jdummy 3) + (dotimes (_jdummy 3) (cal-tex-week-hours date holidays "5") (setq date (cal-tex-incr-date date))) (cal-tex-e-parbox) (cal-tex-nl) (insert (cal-tex-mini-calendar - (extract-calendar-month (cal-tex-previous-month date)) - (extract-calendar-year (cal-tex-previous-month date)) + (calendar-extract-month (cal-tex-previous-month date)) + (calendar-extract-year (cal-tex-previous-month date)) "lastmonth" "1.1in" "1in")) (insert (cal-tex-mini-calendar - (extract-calendar-month date) - (extract-calendar-year date) + (calendar-extract-month date) + (calendar-extract-year date) "thismonth" "1.1in" "1in")) (insert (cal-tex-mini-calendar - (extract-calendar-month (cal-tex-next-month date)) - (extract-calendar-year (cal-tex-next-month date)) + (calendar-extract-month (cal-tex-next-month date)) + (calendar-extract-year (cal-tex-next-month date)) "nextmonth" "1.1in" "1in")) (insert "\\hbox to \\textwidth{") (cal-tex-hfill) @@ -781,38 +778,43 @@ entries are not shown). The calendar shows the hours 8-12am, 1-5pm" (insert "}") (cal-tex-nl) (cal-tex-b-parbox "l" "\\textwidth") - (dotimes (jdummy 4) + (dotimes (_jdummy 4) (cal-tex-week-hours date holidays "5") (setq date (cal-tex-incr-date date))) (cal-tex-e-parbox) - (setq month (extract-calendar-month date) - year (extract-calendar-year date)) + (setq month (calendar-extract-month date) + year (calendar-extract-year date)) (unless (= i (1- n)) (run-hooks 'cal-tex-week-hook) (cal-tex-newpage))) (cal-tex-end-document) (run-hooks 'cal-tex-hook))) -(defun cal-tex-cursor-week-iso (&optional arg) +(autoload 'calendar-iso-from-absolute "cal-iso") + +;;;###cal-autoload +(defun cal-tex-cursor-week-iso (&optional n event) "Make a LaTeX calendar buffer for a one page ISO-style weekly calendar. -Optional prefix argument ARG specifies number of weeks (default 1). +Optional prefix argument N specifies number of weeks (default 1). The calendar shows holiday and diary entries if `cal-tex-holidays' and `cal-tex-diary', respectively, are non-nil. -It does not show hours of the day." - (interactive "p") - (let* ((n (or arg 1)) - (date (calendar-gregorian-from-absolute +It does not show hours of the day. Optional EVENT indicates a buffer +position to use instead of point." + (interactive (list (prefix-numeric-value current-prefix-arg) + last-nonmenu-event)) + (or n (setq n 1)) + (let* ((date (calendar-gregorian-from-absolute (calendar-dayname-on-or-before 1 (calendar-absolute-from-gregorian - (calendar-cursor-to-date t))))) - (month (extract-calendar-month date)) - (year (extract-calendar-year date)) - (day (extract-calendar-day date)) + (calendar-cursor-to-date t event))))) + (month (calendar-extract-month date)) + (year (calendar-extract-year date)) + (day (calendar-extract-day date)) (d1 (calendar-absolute-from-gregorian date)) (d2 (+ (* 7 n) d1)) (holidays (if cal-tex-holidays - (cal-tex-list-holidays d1 d2))) + (holiday-in-range d1 d2))) (diary-list (if cal-tex-diary (cal-tex-list-diary-entries ;; FIXME d1? @@ -833,12 +835,12 @@ It does not show hours of the day." (let ((d (calendar-iso-from-absolute (calendar-absolute-from-gregorian date)))) (format "Week %d of %d" - (extract-calendar-month d) - (extract-calendar-year d)))) + (calendar-extract-month d) + (calendar-extract-year d)))) (cal-tex-nl ".5cm") (cal-tex-e-center) (cal-tex-b-parbox "l" "\\textwidth") - (dotimes (j 7) + (dotimes (_j 7) (cal-tex-b-parbox "t" "\\textwidth") (cal-tex-b-parbox "t" "\\textwidth") (cal-tex-rule "0pt" "\\textwidth" ".2mm") @@ -867,13 +869,13 @@ It does not show hours of the day." (cal-tex-e-parbox) (cal-tex-nl) (setq date (cal-tex-incr-date date) - month (extract-calendar-month date) - day (extract-calendar-day date)) + month (calendar-extract-month date) + day (calendar-extract-day date)) (cal-tex-e-parbox) (cal-tex-e-parbox "2cm") (cal-tex-nl) - (setq month (extract-calendar-month date) - year (extract-calendar-year date))) + (setq month (calendar-extract-month date) + year (calendar-extract-year date))) (cal-tex-e-parbox) (unless (= i (1- n)) (run-hooks 'cal-tex-week-hook) @@ -887,9 +889,9 @@ It does not show hours of the day." "Insert hourly entries for DATE with HOLIDAYS, with line height HEIGHT. Uses the 24-hour clock if `cal-tex-24' is non-nil. Note that the hours shown are hard-coded to 8-12, 13-17." - (let ((month (extract-calendar-month date)) - (day (extract-calendar-day date)) - (year (extract-calendar-year date)) + (let ((month (calendar-extract-month date)) + (day (calendar-extract-day date)) + (year (calendar-extract-year date)) morning afternoon s) (cal-tex-comment "begin cal-tex-week-hours") (cal-tex-cmd "\\ \\\\[-.2cm]") @@ -924,20 +926,23 @@ shown are hard-coded to 8-12, 13-17." ;; TODO cal-tex-diary support. ;; TODO respect cal-tex-daily-start,end (see cal-tex-weekly4-box). -(defun cal-tex-cursor-week-monday (&optional arg) +;;;###cal-autoload +(defun cal-tex-cursor-week-monday (&optional n event) "Make a LaTeX calendar buffer for a two-page one-week calendar. It applies to the week that point is in, and starts on Monday. -Optional prefix argument ARG specifies number of weeks (default 1). +Optional prefix argument N specifies number of weeks (default 1). The calendar shows holidays if `cal-tex-holidays' is non-nil (note that diary entries are not shown). The calendar shows -the hours 8-12am, 1-5pm." - (interactive "p") - (let ((n (or arg 1)) - (date (calendar-gregorian-from-absolute +the hours 8-12am, 1-5pm. Optional EVENT indicates a buffer position +to use instead of point." + (interactive (list (prefix-numeric-value current-prefix-arg) + last-nonmenu-event)) + (or n (setq n 1)) + (let ((date (calendar-gregorian-from-absolute (calendar-dayname-on-or-before 0 (calendar-absolute-from-gregorian - (calendar-cursor-to-date t)))))) + (calendar-cursor-to-date t event)))))) (cal-tex-preamble "11pt") (cal-tex-cmd "\\textwidth 6.5in") (cal-tex-cmd "\\textheight 10.5in") @@ -968,14 +973,14 @@ the hours 8-12am, 1-5pm." "Make one box for DATE, different if WEEKEND. Uses the 24-hour clock if `cal-tex-24' is non-nil. Note that the hours shown are hard-coded to 8-12, 13-17." - (let* ((day (extract-calendar-day date)) - (month (extract-calendar-month date)) - (year (extract-calendar-year date)) + (let* ((day (calendar-extract-day date)) + (month (calendar-extract-month date)) + (year (calendar-extract-year date)) (dayname (cal-tex-LaTeXify-string (calendar-day-name date))) (date1 (cal-tex-incr-date date)) - (day1 (extract-calendar-day date1)) - (month1 (extract-calendar-month date1)) - (year1 (extract-calendar-year date1)) + (day1 (calendar-extract-day date1)) + (month1 (calendar-extract-month date1)) + (year1 (calendar-extract-year date1)) (dayname1 (cal-tex-LaTeXify-string (calendar-day-name date1)))) (cal-tex-b-framebox "8cm" "l") (cal-tex-b-parbox "b" "7.5cm") @@ -1004,25 +1009,28 @@ shown are hard-coded to 8-12, 13-17." (cal-tex-e-framebox) (cal-tex-hspace "1cm"))) -(defun cal-tex-cursor-filofax-2week (&optional arg) +;;;###cal-autoload +(defun cal-tex-cursor-filofax-2week (&optional n event) "Two-weeks-at-a-glance Filofax style calendar for week cursor is in. -Optional prefix argument ARG specifies number of weeks (default 1). +Optional prefix argument N specifies number of weeks (default 1). The calendar shows holiday and diary entries if -`cal-tex-holidays' and `cal-tex-diary', respectively, are non-nil." - (interactive "p") - (let* ((n (or arg 1)) - (date (calendar-gregorian-from-absolute +`cal-tex-holidays' and `cal-tex-diary', respectively, are non-nil. +Optional EVENT indicates a buffer position to use instead of point." + (interactive (list (prefix-numeric-value current-prefix-arg) + last-nonmenu-event)) + (or n (setq n 1)) + (let* ((date (calendar-gregorian-from-absolute (calendar-dayname-on-or-before calendar-week-start-day (calendar-absolute-from-gregorian - (calendar-cursor-to-date t))))) - (month (extract-calendar-month date)) - (year (extract-calendar-year date)) - (day (extract-calendar-day date)) + (calendar-cursor-to-date t event))))) + (month (calendar-extract-month date)) + (year (calendar-extract-year date)) + (day (calendar-extract-day date)) (d1 (calendar-absolute-from-gregorian date)) (d2 (+ (* 7 n) d1)) (holidays (if cal-tex-holidays - (cal-tex-list-holidays d1 d2))) + (holiday-in-range d1 d2))) (diary-list (if cal-tex-diary (cal-tex-list-diary-entries ;; FIXME d1? @@ -1064,29 +1072,29 @@ The calendar shows holiday and diary entries if (insert "\\lefthead")) (cal-tex-arg (let ((d (cal-tex-incr-date date 6))) - (if (= (extract-calendar-month date) - (extract-calendar-month d)) + (if (= (calendar-extract-month date) + (calendar-extract-month d)) (format "%s %s" - (cal-tex-month-name (extract-calendar-month date)) - (extract-calendar-year date)) - (if (= (extract-calendar-year date) - (extract-calendar-year d)) + (cal-tex-month-name (calendar-extract-month date)) + (calendar-extract-year date)) + (if (= (calendar-extract-year date) + (calendar-extract-year d)) (format "%s---%s %s" - (cal-tex-month-name (extract-calendar-month date)) - (cal-tex-month-name (extract-calendar-month d)) - (extract-calendar-year date)) + (cal-tex-month-name (calendar-extract-month date)) + (cal-tex-month-name (calendar-extract-month d)) + (calendar-extract-year date)) (format "%s %s---%s %s" - (cal-tex-month-name (extract-calendar-month date)) - (extract-calendar-year date) - (cal-tex-month-name (extract-calendar-month d)) - (extract-calendar-year d)))))) + (cal-tex-month-name (calendar-extract-month date)) + (calendar-extract-year date) + (cal-tex-month-name (calendar-extract-month d)) + (calendar-extract-year d)))))) (insert "%\n") - (dotimes (jdummy 7) + (dotimes (_jdummy 7) (if (zerop (mod i 2)) (insert "\\rightday") (insert "\\leftday")) (cal-tex-arg (cal-tex-LaTeXify-string (calendar-day-name date))) - (cal-tex-arg (int-to-string (extract-calendar-day date))) + (cal-tex-arg (number-to-string (calendar-extract-day date))) (cal-tex-arg (cal-tex-latexify-list diary-list date)) (cal-tex-arg (cal-tex-latexify-list holidays date)) (cal-tex-arg (eval cal-tex-daily-string)) @@ -1098,25 +1106,28 @@ The calendar shows holiday and diary entries if (cal-tex-end-document) (run-hooks 'cal-tex-hook))) -(defun cal-tex-cursor-filofax-week (&optional arg) +;;;###cal-autoload +(defun cal-tex-cursor-filofax-week (&optional n event) "One-week-at-a-glance Filofax style calendar for week indicated by cursor. -Optional prefix argument ARG specifies number of weeks (default 1), +Optional prefix argument N specifies number of weeks (default 1), starting on Mondays. The calendar shows holiday and diary entries -if `cal-tex-holidays' and `cal-tex-diary', respectively, are non-nil." - (interactive "p") - (let* ((n (or arg 1)) - (date (calendar-gregorian-from-absolute +if `cal-tex-holidays' and `cal-tex-diary', respectively, are non-nil. +Optional EVENT indicates a buffer position to use instead of point." + (interactive (list (prefix-numeric-value current-prefix-arg) + last-nonmenu-event)) + (or n (setq n 1)) + (let* ((date (calendar-gregorian-from-absolute (calendar-dayname-on-or-before 1 (calendar-absolute-from-gregorian - (calendar-cursor-to-date t))))) - (month (extract-calendar-month date)) - (year (extract-calendar-year date)) - (day (extract-calendar-day date)) + (calendar-cursor-to-date t event))))) + (month (calendar-extract-month date)) + (year (calendar-extract-year date)) + (day (calendar-extract-day date)) (d1 (calendar-absolute-from-gregorian date)) (d2 (+ (* 7 n) d1)) (holidays (if cal-tex-holidays - (cal-tex-list-holidays d1 d2))) + (holiday-in-range d1 d2))) (diary-list (if cal-tex-diary (cal-tex-list-diary-entries ;; FIXME d1? @@ -1165,27 +1176,27 @@ if `cal-tex-holidays' and `cal-tex-diary', respectively, are non-nil." (insert "\\lefthead") (cal-tex-arg (let ((d (cal-tex-incr-date date 2))) - (if (= (extract-calendar-month date) - (extract-calendar-month d)) + (if (= (calendar-extract-month date) + (calendar-extract-month d)) (format "%s %s" - (cal-tex-month-name (extract-calendar-month date)) - (extract-calendar-year date)) - (if (= (extract-calendar-year date) - (extract-calendar-year d)) + (cal-tex-month-name (calendar-extract-month date)) + (calendar-extract-year date)) + (if (= (calendar-extract-year date) + (calendar-extract-year d)) (format "%s---%s %s" - (cal-tex-month-name (extract-calendar-month date)) - (cal-tex-month-name (extract-calendar-month d)) - (extract-calendar-year date)) + (cal-tex-month-name (calendar-extract-month date)) + (cal-tex-month-name (calendar-extract-month d)) + (calendar-extract-year date)) (format "%s %s---%s %s" - (cal-tex-month-name (extract-calendar-month date)) - (extract-calendar-year date) - (cal-tex-month-name (extract-calendar-month d)) - (extract-calendar-year d)))))) + (cal-tex-month-name (calendar-extract-month date)) + (calendar-extract-year date) + (cal-tex-month-name (calendar-extract-month d)) + (calendar-extract-year d)))))) (insert "%\n") - (dotimes (jdummy 3) + (dotimes (_jdummy 3) (insert "\\leftday") (cal-tex-arg (cal-tex-LaTeXify-string (calendar-day-name date))) - (cal-tex-arg (int-to-string (extract-calendar-day date))) + (cal-tex-arg (number-to-string (calendar-extract-day date))) (cal-tex-arg (cal-tex-latexify-list diary-list date)) (cal-tex-arg (cal-tex-latexify-list holidays date)) (cal-tex-arg (eval cal-tex-daily-string)) @@ -1196,36 +1207,36 @@ if `cal-tex-holidays' and `cal-tex-diary', respectively, are non-nil." (insert "\\righthead") (cal-tex-arg (let ((d (cal-tex-incr-date date 3))) - (if (= (extract-calendar-month date) - (extract-calendar-month d)) + (if (= (calendar-extract-month date) + (calendar-extract-month d)) (format "%s %s" - (cal-tex-month-name (extract-calendar-month date)) - (extract-calendar-year date)) - (if (= (extract-calendar-year date) - (extract-calendar-year d)) + (cal-tex-month-name (calendar-extract-month date)) + (calendar-extract-year date)) + (if (= (calendar-extract-year date) + (calendar-extract-year d)) (format "%s---%s %s" - (cal-tex-month-name (extract-calendar-month date)) - (cal-tex-month-name (extract-calendar-month d)) - (extract-calendar-year date)) + (cal-tex-month-name (calendar-extract-month date)) + (cal-tex-month-name (calendar-extract-month d)) + (calendar-extract-year date)) (format "%s %s---%s %s" - (cal-tex-month-name (extract-calendar-month date)) - (extract-calendar-year date) - (cal-tex-month-name (extract-calendar-month d)) - (extract-calendar-year d)))))) + (cal-tex-month-name (calendar-extract-month date)) + (calendar-extract-year date) + (cal-tex-month-name (calendar-extract-month d)) + (calendar-extract-year d)))))) (insert "%\n") - (dotimes (jdummy 2) + (dotimes (_jdummy 2) (insert "\\rightday") (cal-tex-arg (cal-tex-LaTeXify-string (calendar-day-name date))) - (cal-tex-arg (int-to-string (extract-calendar-day date))) + (cal-tex-arg (number-to-string (calendar-extract-day date))) (cal-tex-arg (cal-tex-latexify-list diary-list date)) (cal-tex-arg (cal-tex-latexify-list holidays date)) (cal-tex-arg (eval cal-tex-daily-string)) (insert "%\n") (setq date (cal-tex-incr-date date))) - (dotimes (jdummy 2) + (dotimes (_jdummy 2) (insert "\\weekend") (cal-tex-arg (cal-tex-LaTeXify-string (calendar-day-name date))) - (cal-tex-arg (int-to-string (extract-calendar-day date))) + (cal-tex-arg (number-to-string (calendar-extract-day date))) (cal-tex-arg (cal-tex-latexify-list diary-list date)) (cal-tex-arg (cal-tex-latexify-list holidays date)) (cal-tex-arg (eval cal-tex-daily-string)) @@ -1237,31 +1248,34 @@ if `cal-tex-holidays' and `cal-tex-diary', respectively, are non-nil." (cal-tex-end-document) (run-hooks 'cal-tex-hook))) -(defun cal-tex-cursor-filofax-daily (&optional arg) +;;;###cal-autoload +(defun cal-tex-cursor-filofax-daily (&optional n event) "Day-per-page Filofax style calendar for week indicated by cursor. -Optional prefix argument ARG specifies number of weeks (default 1), +Optional prefix argument N specifies number of weeks (default 1), starting on Mondays. The calendar shows holiday and diary entries if `cal-tex-holidays' and `cal-tex-diary', respectively, -are non-nil. Pages are ruled if `cal-tex-rules' is non-nil." - (interactive "p") - (let* ((n (or arg 1)) - (date (calendar-gregorian-from-absolute +are non-nil. Pages are ruled if `cal-tex-rules' is non-nil. +Optional EVENT indicates a buffer position to use instead of point." + (interactive (list (prefix-numeric-value current-prefix-arg) + last-nonmenu-event)) + (or n (setq n 1)) + (let* ((date (calendar-gregorian-from-absolute (calendar-dayname-on-or-before 1 (calendar-absolute-from-gregorian - (calendar-cursor-to-date t))))) - (month (extract-calendar-month date)) - (year (extract-calendar-year date)) - (day (extract-calendar-day date)) + (calendar-cursor-to-date t event))))) + (month (calendar-extract-month date)) + (year (calendar-extract-year date)) + (day (calendar-extract-day date)) (d1 (calendar-absolute-from-gregorian date)) (d2 (+ (* 7 n) d1)) (holidays (if cal-tex-holidays - (cal-tex-list-holidays d1 d2))) + (holiday-in-range d1 d2))) (diary-list (if cal-tex-diary (cal-tex-list-diary-entries ;; FIXME d1? (calendar-absolute-from-gregorian (list month 1 year)) - d2)))) + d2)))) (cal-tex-preamble "twoside") (cal-tex-cmd "\\textwidth 3.25in") (cal-tex-cmd "\\textheight 6.5in") @@ -1325,7 +1339,7 @@ are non-nil. Pages are ruled if `cal-tex-rules' is non-nil." (cal-tex-newpage) (setq date (cal-tex-incr-date date))) (insert "%\n") - (dotimes (jdummy 2) + (dotimes (_jdummy 2) (insert "\\lefthead") (cal-tex-arg (calendar-date-string date)) (insert "\\weekend") @@ -1350,14 +1364,18 @@ are non-nil. Pages are ruled if `cal-tex-rules' is non-nil." ;;; Daily calendars ;;; -(defun cal-tex-cursor-day (&optional arg) +;;;###cal-autoload +(defun cal-tex-cursor-day (&optional n event) "Make a buffer with LaTeX commands for the day cursor is on. -Optional prefix argument ARG specifies number of days. The calendar shows +Optional prefix argument N specifies number of days. The calendar shows the hours between `cal-tex-daily-start' and `cal-tex-daily-end', using -the 24-hour clock if `cal-tex-24' is non-nil." - (interactive "p") - (let ((n (or arg 1)) - (date (calendar-absolute-from-gregorian (calendar-cursor-to-date t)))) +the 24-hour clock if `cal-tex-24' is non-nil. Optional EVENT indicates +a buffer position to use instead of point." + (interactive (list (prefix-numeric-value current-prefix-arg) + last-nonmenu-event)) + (or n (setq n 1)) + (let ((date (calendar-absolute-from-gregorian + (calendar-cursor-to-date t event)))) (cal-tex-preamble "12pt") (cal-tex-cmd "\\textwidth 6.5in") (cal-tex-cmd "\\textheight 10.5in") @@ -1378,13 +1396,14 @@ the 24-hour clock if `cal-tex-24' is non-nil." Uses the 24-hour clock if `cal-tex-24' is non-nil. Produces hourly sections for the period specified by `cal-tex-daily-start' and `cal-tex-daily-end'." - (let ((month-name (cal-tex-month-name (extract-calendar-month date))) + (let ((month-name (cal-tex-month-name (calendar-extract-month date))) + (i (1- cal-tex-daily-start)) hour) (cal-tex-banner "cal-tex-daily-page") (cal-tex-b-makebox "4cm" "l") (cal-tex-b-parbox "b" "3.8cm") (cal-tex-rule "0mm" "0mm" "2cm") - (cal-tex-Huge (number-to-string (extract-calendar-day date))) + (cal-tex-Huge (number-to-string (calendar-extract-day date))) (cal-tex-nl ".5cm") (cal-tex-bf month-name ) (cal-tex-e-parbox) @@ -1400,34 +1419,34 @@ and `cal-tex-daily-end'." (cal-tex-hspace ".4cm") (cal-tex-rule "0mm" "16.1cm" "1mm") (cal-tex-nl ".1cm") - (calendar-for-loop i from cal-tex-daily-start to cal-tex-daily-end do - (cal-tex-cmd "\\noindent") - (setq hour (if cal-tex-24 - i - (mod i 12))) - (if (zerop hour) (setq hour 12)) - (cal-tex-b-makebox "1cm" "c") - (cal-tex-arg (number-to-string hour)) - (cal-tex-e-makebox) - (cal-tex-rule "0mm" "15.5cm" ".2mm") - (cal-tex-nl ".2cm") - (cal-tex-b-makebox "1cm" "c") - (cal-tex-arg "$\\diamond$" ) - (cal-tex-e-makebox) - (cal-tex-rule "0mm" "15.5cm" ".2mm") - (cal-tex-nl ".2cm")) + (while (<= (setq i (1+ i)) cal-tex-daily-end) + (cal-tex-cmd "\\noindent") + (setq hour (if cal-tex-24 + i + (mod i 12))) + (if (zerop hour) (setq hour 12)) + (cal-tex-b-makebox "1cm" "c") + (cal-tex-arg (number-to-string hour)) + (cal-tex-e-makebox) + (cal-tex-rule "0mm" "15.5cm" ".2mm") + (cal-tex-nl ".2cm") + (cal-tex-b-makebox "1cm" "c") + (cal-tex-arg "$\\diamond$" ) + (cal-tex-e-makebox) + (cal-tex-rule "0mm" "15.5cm" ".2mm") + (cal-tex-nl ".2cm")) (cal-tex-hfill) (insert (cal-tex-mini-calendar - (extract-calendar-month (cal-tex-previous-month date)) - (extract-calendar-year (cal-tex-previous-month date)) + (calendar-extract-month (cal-tex-previous-month date)) + (calendar-extract-year (cal-tex-previous-month date)) "lastmonth" "1.1in" "1in")) (insert (cal-tex-mini-calendar - (extract-calendar-month date) - (extract-calendar-year date) + (calendar-extract-month date) + (calendar-extract-year date) "thismonth" "1.1in" "1in")) (insert (cal-tex-mini-calendar - (extract-calendar-month (cal-tex-next-month date)) - (extract-calendar-year (cal-tex-next-month date)) + (calendar-extract-month (cal-tex-next-month date)) + (calendar-extract-year (cal-tex-next-month date)) "nextmonth" "1.1in" "1in")) (insert "\\hbox to \\textwidth{") (cal-tex-hfill) @@ -1455,7 +1474,7 @@ Optional string COLSEP gives the column separation (default \"1mm\")." (- (calendar-day-of-week (list month 1 year)) calendar-week-start-day) 7)) - (last (calendar-last-day-of-month month year)) + (last( calendar-last-day-of-month month year)) (str (concat "\\def\\" name "{\\hbox to" width "{%\n" "\\vbox to" height "{%\n" "\\vfil \\hbox to" width "{%\n" @@ -1468,7 +1487,7 @@ Optional string COLSEP gives the column separation (default \"1mm\")." "\\multicolumn{7}{c}{" (cal-tex-month-name month) " " - (int-to-string year) + (number-to-string year) "}\\\\[1mm]\n"))) (dotimes (i 7) (setq str @@ -1481,10 +1500,10 @@ Optional string COLSEP gives the column separation (default \"1mm\")." (if (= i 6) "\\\\[0.7mm]\n" " & ")))) - (dotimes (idummy blank-days) + (dotimes (_idummy blank-days) (setq str (concat str " & "))) (dotimes (i last) - (setq str (concat str (int-to-string (1+ i))) + (setq str (concat str (number-to-string (1+ i))) str (concat str (if (zerop (mod (+ i 1 blank-days) 7)) (if (= i (1- last)) "" @@ -1524,16 +1543,16 @@ FINAL-SEPARATOR is non-nil." (defun cal-tex-previous-month (date) "Return the date of the first day in the month previous to DATE." - (let ((month (extract-calendar-month date)) - (year (extract-calendar-year date))) - (increment-calendar-month month year -1) + (let ((month (calendar-extract-month date)) + (year (calendar-extract-year date))) + (calendar-increment-month month year -1) (list month 1 year))) (defun cal-tex-next-month (date) "Return the date of the first day in the month following DATE." - (let ((month (extract-calendar-month date)) - (year (extract-calendar-year date))) - (increment-calendar-month month year 1) + (let ((month (calendar-extract-month date)) + (year (calendar-extract-year date))) + (calendar-increment-month month year 1) (list month 1 year))) ;;; @@ -1545,6 +1564,15 @@ FINAL-SEPARATOR is non-nil." Insert the trailer to LaTeX document, pop to LaTeX buffer, add informative header, and run HOOK." (cal-tex-e-document) + (or (and cal-tex-preamble-extra + (string-match "inputenc" cal-tex-preamble-extra)) + (when (re-search-backward "[^[:ascii:]]" nil 'move) + (goto-char (point-min)) + (when (search-forward "documentclass" nil t) + (forward-line 1) + ;; Eg for some Bahai holidays. + ;; FIXME latin1 might not always be right. + (insert "\\usepackage[latin1]{inputenc}\n")))) (latex-mode) (pop-to-buffer cal-tex-buffer) (goto-char (point-min)) @@ -1559,7 +1587,7 @@ informative header, and run HOOK." "Initialize the output LaTeX calendar buffer, `cal-tex-buffer'. Select the output buffer, and insert the preamble for a calendar of WEEKS weeks. Insert code for landscape mode if LANDSCAPE is -non-nil. Use pointsize SIZE. Optional argument APPEND, if +non-nil. Use point-size SIZE. Optional argument APPEND, if non-nil, means add to end of buffer without erasing current contents." (let ((width "18cm") (height "24cm")) @@ -1614,18 +1642,19 @@ non-nil, means add to end of buffer without erasing current contents." "" (let ((head "") (tail string) - (list cal-tex-LaTeX-subst-list)) + (list cal-tex-LaTeX-subst-list) + ch pair) (while (not (string-equal tail "")) - (let* ((ch (substring-no-properties tail 0 1)) - (pair (assoc ch list))) - (if (and pair (string-equal ch "\"")) - (setq list (reverse list))) ; quote changes meaning each time - (setq tail (substring-no-properties tail 1) - head (concat head (if pair (cdr pair) ch))))) + (setq ch (substring-no-properties tail 0 1) + pair (assoc ch list)) + (if (and pair (string-equal ch "\"")) + (setq list (reverse list))) ; quote changes meaning each time + (setq tail (substring-no-properties tail 1) + head (concat head (if pair (cdr pair) ch)))) head))) (defun cal-tex-month-name (month) - "The name of MONTH, LaTeXified." + "The name of MONTH, LaTeX-ified." (cal-tex-LaTeXify-string (calendar-month-name month))) (defun cal-tex-hfill () @@ -1733,7 +1762,7 @@ Add trailing COMMENT if present." (cal-tex-comment "end framebox")) -(defun cal-tex-b-makebox ( width position ) +(defun cal-tex-b-makebox (width position) "Insert makebox with parameters WIDTH and POSITION (clr)." (insert "\\makebox[" width "][" position "]{" ) (cal-tex-comment)) @@ -1788,5 +1817,4 @@ Add trailing COMMENT if present." (provide 'cal-tex) -;;; arch-tag: ca8168a4-5a00-4508-a565-17e3bccce6d0 ;;; cal-tex.el ends here