Support Chinese diary entries in calendar and diary
* doc/emacs/cal-xtra.texi (Non-Gregorian Diary): Document new features for Chinese calendar and diary. * etc/NEWS: Mention support for Chinese dates in calendar and diary. * lisp/calendar/cal-china.el (calendar-chinese-month-name-array): New var. (calendar-chinese-from-absolute-for-diary) (calendar-chinese-to-absolute-for-diary) (calendar-chinese-mark-date-pattern, diary-chinese-mark-entries) (diary-chinese-list-entries): New functions to list and mark Chinese diary entries in the calendar window. (diary-chinese-anniversary) (diary-chinese-insert-anniversary-entry) (diary-chinese-insert-entry, diary-chinese-insert-monthly-entry) (diary-chinese-insert-yearly-entry): New commands to insert Chinese diary entries. * lisp/calendar/cal-menu.el (cal-menu-diary-menu): Add entries for inserting Chinese diary entries. * lisp/calendar/calendar.el (diary-chinese-entry-symbol): New customizable variable. (calendar-mode-map): Add bindings for inserting Chinese diary entries. * lisp/calendar/diary-lib.el (diary-font-lock-keywords): Support font-locking Chinese dates. Fixes: debbugs:17393
This commit is contained in:
parent
c3a435fedd
commit
bbdcf64f49
9 changed files with 211 additions and 7 deletions
|
@ -1,3 +1,8 @@
|
|||
2014-05-04 Leo Liu <sdl.web@gmail.com>
|
||||
|
||||
* cal-xtra.texi (Non-Gregorian Diary): Document new features for
|
||||
Chinese calendar and diary.
|
||||
|
||||
2014-04-30 Eli Zaretskii <eliz@gnu.org>
|
||||
|
||||
* trouble.texi (Quitting, DEL Does Not Delete, Emergency Escape)
|
||||
|
|
|
@ -517,7 +517,7 @@ the fourth pattern.
|
|||
@subsection Diary Entries Using non-Gregorian Calendars
|
||||
|
||||
As well as entries based on the standard Gregorian calendar, your
|
||||
diary can have entries based on Bahá'í, Hebrew, or Islamic dates.
|
||||
diary can have entries based on Bahá'í, Chinese, Hebrew, or Islamic dates.
|
||||
Recognition of such entries can be time-consuming, however, and since
|
||||
most people don't use them, you must explicitly enable their use. If
|
||||
you want the diary to recognize Hebrew-date diary entries, for example,
|
||||
|
@ -531,22 +531,27 @@ you must do this:
|
|||
@findex diary-islamic-mark-entries
|
||||
@findex diary-bahai-list-entries
|
||||
@findex diary-bahai-mark-entries
|
||||
@findex diary-chinese-list-entries
|
||||
@findex diary-chinese-mark-entries
|
||||
@smallexample
|
||||
(add-hook 'diary-nongregorian-listing-hook 'diary-hebrew-list-entries)
|
||||
(add-hook 'diary-nongregorian-marking-hook 'diary-hebrew-mark-entries)
|
||||
@end smallexample
|
||||
|
||||
@noindent
|
||||
Similarly, for Islamic and Bahá'í entries, add
|
||||
@code{diary-islamic-list-entries} and @code{diary-islamic-mark-entries}, or
|
||||
@code{diary-bahai-list-entries} and @code{diary-bahai-mark-entries}.
|
||||
Similarly, for Islamic, Bahá'í and Chinese entries, add
|
||||
@code{diary-islamic-list-entries} and @code{diary-islamic-mark-entries},
|
||||
@code{diary-bahai-list-entries} and @code{diary-bahai-mark-entries},
|
||||
or @code{diary-chinese-list-entries} and @code{diary-chinese-mark-entries}.
|
||||
|
||||
@vindex diary-bahai-entry-symbol
|
||||
@vindex diary-chinese-entry-symbol
|
||||
@vindex diary-hebrew-entry-symbol
|
||||
@vindex diary-islamic-entry-symbol
|
||||
These diary entries have the same formats as Gregorian-date diary
|
||||
entries; except that @code{diary-bahai-entry-symbol} (default @samp{B})
|
||||
must precede a Bahá'í date, @code{diary-hebrew-entry-symbol} (default
|
||||
must precede a Bahá'í date, @code{diary-chinese-entry-symbol} (default
|
||||
@samp{C}) a Chinese date, @code{diary-hebrew-entry-symbol} (default
|
||||
@samp{H}) a Hebrew date, and @code{diary-islamic-entry-symbol} (default
|
||||
@samp{I}) an Islamic date. Moreover, non-Gregorian month names may not
|
||||
be abbreviated (because the first three letters are often not unique).
|
||||
|
@ -573,7 +578,7 @@ nonmarking if preceded by @code{diary-nonmarking-symbol} (default
|
|||
|
||||
Here is a table of commands used in the calendar to create diary
|
||||
entries that match the selected date and other dates that are similar in
|
||||
the Bahá'í, Hebrew, or Islamic calendars:
|
||||
the Bahá'í, Chinese, Hebrew, or Islamic calendars:
|
||||
|
||||
@table @kbd
|
||||
@item i h d
|
||||
|
@ -594,6 +599,14 @@ the Bahá'í, Hebrew, or Islamic calendars:
|
|||
@code{diary-bahai-insert-monthly-entry}
|
||||
@item i B y
|
||||
@code{diary-bahai-insert-yearly-entry}
|
||||
@item i C d
|
||||
@code{diary-chinese-insert-entry}
|
||||
@item i C m
|
||||
@code{diary-chinese-insert-monthly-entry}
|
||||
@item i C y
|
||||
@code{diary-chinese-insert-yearly-entry}
|
||||
@item i C a
|
||||
@code{diary-chinese-insert-anniversary-entry}
|
||||
@end table
|
||||
|
||||
@findex diary-hebrew-insert-entry
|
||||
|
@ -605,6 +618,11 @@ the Bahá'í, Hebrew, or Islamic calendars:
|
|||
@findex diary-bahai-insert-entry
|
||||
@findex diary-bahai-insert-monthly-entry
|
||||
@findex diary-bahai-insert-yearly-entry
|
||||
@findex diary-chinese-insert-entry
|
||||
@findex diary-chinese-insert-monthly-entry
|
||||
@findex diary-chinese-insert-yearly-entry
|
||||
@findex diary-chinese-insert-anniversary-entry
|
||||
|
||||
These commands work much like the corresponding commands for ordinary
|
||||
diary entries: they apply to the date that point is on in the calendar
|
||||
window, and what they do is insert just the date portion of a diary
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
2014-05-04 Leo Liu <sdl.web@gmail.com>
|
||||
|
||||
* NEWS: Mention support for Chinese dates in calendar and diary.
|
||||
|
||||
2014-04-20 Daniel Colascione <dancol@dancol.org>
|
||||
|
||||
* NEWS: Mention new struct functions and changes to `cl-the'.
|
||||
|
|
12
etc/NEWS
12
etc/NEWS
|
@ -74,6 +74,18 @@ performance improvements when pasting large amounts of text.
|
|||
** The Rmail commands d, C-d and u now handle repeat counts
|
||||
to delete or undelete multiple messages.
|
||||
|
||||
** Calendar and diary
|
||||
|
||||
+++
|
||||
*** New commands to insert diary entries with Chinese dates:
|
||||
`diary-chinese-insert-anniversary-entry' `diary-chinese-insert-entry'
|
||||
`diary-chinese-insert-monthly-entry'
|
||||
`diary-chinese-insert-yearly-entry'
|
||||
|
||||
+++
|
||||
*** Calendar can list and mark diary entires with Chinese dates:
|
||||
`diary-chinese-list-entries' and `diary-chinese-mark-entries'.
|
||||
|
||||
** The URL package accepts now the protocols "ssh", "scp" and "rsync".
|
||||
When `url-handler-mode' is enabled, file operations for these
|
||||
protocols as well as for "telnet" and "ftp" are passed to Tramp.
|
||||
|
|
|
@ -1,3 +1,29 @@
|
|||
2014-05-04 Leo Liu <sdl.web@gmail.com>
|
||||
|
||||
Support Chinese diary entries in calendar and diary. (Bug#17393)
|
||||
* calendar/cal-china.el (calendar-chinese-month-name-array): New var.
|
||||
(calendar-chinese-from-absolute-for-diary)
|
||||
(calendar-chinese-to-absolute-for-diary)
|
||||
(calendar-chinese-mark-date-pattern, diary-chinese-mark-entries)
|
||||
(diary-chinese-list-entries): New functions to list and mark
|
||||
Chinese diary entries in the calendar window.
|
||||
(diary-chinese-anniversary)
|
||||
(diary-chinese-insert-anniversary-entry)
|
||||
(diary-chinese-insert-entry, diary-chinese-insert-monthly-entry)
|
||||
(diary-chinese-insert-yearly-entry): New commands to insert
|
||||
Chinese diary entries.
|
||||
|
||||
* calendar/diary-lib.el (diary-font-lock-keywords): Support
|
||||
font-locking Chinese dates.
|
||||
|
||||
* calendar/cal-menu.el (cal-menu-diary-menu): Add entries for
|
||||
inserting Chinese diary entries.
|
||||
|
||||
* calendar/calendar.el (diary-chinese-entry-symbol): New
|
||||
customizable variable.
|
||||
(calendar-mode-map): Add bindings for inserting Chinese diary
|
||||
entries.
|
||||
|
||||
2014-05-03 Juri Linkov <juri@jurta.org>
|
||||
|
||||
* dired.el (dired-check-switches, dired-switches-recursive-p):
|
||||
|
|
|
@ -682,6 +682,124 @@ Echo Chinese date unless NOECHO is non-nil."
|
|||
"Chinese calendar equivalent of date diary entry."
|
||||
(format "Chinese date: %s" (calendar-chinese-date-string date)))
|
||||
|
||||
;;;; diary support
|
||||
|
||||
(autoload 'calendar-mark-1 "diary-lib")
|
||||
(autoload 'diary-mark-entries-1 "diary-lib")
|
||||
(autoload 'diary-list-entries-1 "diary-lib")
|
||||
(autoload 'diary-insert-entry-1 "diary-lib")
|
||||
(autoload 'diary-date-display-form "diary-lib")
|
||||
(autoload 'diary-make-date "diary-lib")
|
||||
(autoload 'diary-ordinal-suffix "diary-lib")
|
||||
(defvar diary-sexp-entry-symbol)
|
||||
(defvar entry) ;used by `diary-chinese-anniversary'
|
||||
|
||||
(defvar calendar-chinese-month-name-array
|
||||
["正月" "二月" "三月" "四月" "五月" "六月"
|
||||
"七月" "八月" "九月" "十月" "冬月" "臘月"])
|
||||
|
||||
;;; NOTE: In the diary the cycle and year of a Chinese date is
|
||||
;;; combined using this formula: (+ (* cycle 100) year).
|
||||
;;;
|
||||
;;; These two functions convert to and back from this representation.
|
||||
(defun calendar-chinese-from-absolute-for-diary (date)
|
||||
(pcase-let ((`(,c ,y ,m ,d) (calendar-chinese-from-absolute date)))
|
||||
(list m d (+ (* c 100) y))))
|
||||
|
||||
(defun calendar-chinese-to-absolute-for-diary (date)
|
||||
(pcase-let ((`(,m ,d ,y) date))
|
||||
(calendar-chinese-to-absolute
|
||||
(list (floor y 100) (mod y 100) m d))))
|
||||
|
||||
(defun calendar-chinese-mark-date-pattern (month day year &optional color)
|
||||
(calendar-mark-1 month day year
|
||||
#'calendar-chinese-from-absolute-for-diary
|
||||
#'calendar-chinese-to-absolute-for-diary
|
||||
color))
|
||||
|
||||
;;;###cal-autoload
|
||||
(defun diary-chinese-mark-entries ()
|
||||
"Mark days in the calendar window that have Chinese date diary entries.
|
||||
Marks each entry in `diary-file' (or included files) visible in the calendar
|
||||
window. See `diary-chinese-list-entries' for more information.
|
||||
|
||||
This function is provided for use with `diary-nongregorian-marking-hook'."
|
||||
(diary-mark-entries-1 #'calendar-chinese-mark-date-pattern
|
||||
calendar-chinese-month-name-array
|
||||
diary-chinese-entry-symbol
|
||||
#'calendar-chinese-from-absolute-for-diary))
|
||||
|
||||
;;;###cal-autoload
|
||||
(defun diary-chinese-list-entries ()
|
||||
"Add any Chinese date entries from the diary file to `diary-entries-list'.
|
||||
Chinese date diary entries must be prefixed by `diary-chinese-entry-symbol'
|
||||
\(normally a `C'). The same `diary-date-forms' govern the style
|
||||
of the Chinese calendar entries. If a Chinese date diary entry begins with
|
||||
`diary-nonmarking-symbol', the entry will appear in the diary listing,
|
||||
but will not be marked in the calendar.
|
||||
|
||||
This function is provided for use with `diary-nongregorian-listing-hook'."
|
||||
(diary-list-entries-1 calendar-chinese-month-name-array
|
||||
diary-chinese-entry-symbol
|
||||
#'calendar-chinese-from-absolute-for-diary))
|
||||
|
||||
;;;###cal-autoload
|
||||
(defun diary-chinese-anniversary (month day &optional year mark)
|
||||
"Like `diary-anniversary' (which see) but accepts Chinese date."
|
||||
(pcase-let* ((ddate (diary-make-date month day year))
|
||||
(`(,dc ,dy ,dm ,dd) ;diary chinese date
|
||||
(if year
|
||||
(calendar-chinese-from-absolute
|
||||
(calendar-chinese-to-absolute-for-diary ddate))
|
||||
(list nil nil (calendar-extract-month ddate)
|
||||
(calendar-extract-day ddate))))
|
||||
(`(,cc ,cy ,cm ,cd) ;current chinese date
|
||||
(calendar-chinese-from-absolute
|
||||
(calendar-absolute-from-gregorian date)))
|
||||
(diff (if (and dc dy)
|
||||
(+ (* 60 (- cc dc)) (- cy dy))
|
||||
100)))
|
||||
(and (> diff 0) (= dm cm) (= dd cd)
|
||||
(cons mark (format entry diff (diary-ordinal-suffix diff))))))
|
||||
|
||||
;;;###cal-autoload
|
||||
(defun diary-chinese-insert-anniversary-entry (&optional arg)
|
||||
"Insert an anniversary diary entry for the Chinese date at point.
|
||||
Prefix argument ARG makes the entry nonmarking."
|
||||
(interactive "P")
|
||||
(let ((calendar-date-display-form (diary-date-display-form)))
|
||||
(diary-make-entry
|
||||
(format "%s(diary-chinese-anniversary %s)"
|
||||
diary-sexp-entry-symbol
|
||||
(calendar-date-string
|
||||
(calendar-chinese-from-absolute-for-diary
|
||||
(calendar-absolute-from-gregorian (calendar-cursor-to-date t)))))
|
||||
arg)))
|
||||
|
||||
;;;###cal-autoload
|
||||
(defun diary-chinese-insert-entry (&optional arg)
|
||||
"Insert a diary entry for the Chinese date at point."
|
||||
(interactive "P")
|
||||
(diary-insert-entry-1 nil arg calendar-chinese-month-name-array
|
||||
diary-chinese-entry-symbol
|
||||
#'calendar-chinese-from-absolute-for-diary))
|
||||
|
||||
;;;###cal-autoload
|
||||
(defun diary-chinese-insert-monthly-entry (&optional arg)
|
||||
"Insert a monthly diary entry for the Chinese date at point."
|
||||
(interactive "P")
|
||||
(diary-insert-entry-1 'monthly arg calendar-chinese-month-name-array
|
||||
diary-chinese-entry-symbol
|
||||
#'calendar-chinese-from-absolute-for-diary))
|
||||
|
||||
;;;###cal-autoload
|
||||
(defun diary-chinese-insert-yearly-entry (&optional arg)
|
||||
"Insert a yearly diary entry for the Chinese date at point."
|
||||
(interactive "P")
|
||||
(diary-insert-entry-1 'yearly arg calendar-chinese-month-name-array
|
||||
diary-chinese-entry-symbol
|
||||
#'calendar-chinese-from-absolute-for-diary))
|
||||
|
||||
(provide 'cal-china)
|
||||
|
||||
;;; cal-china.el ends here
|
||||
|
|
|
@ -56,6 +56,11 @@
|
|||
["One time" diary-bahai-insert-entry]
|
||||
["Monthly" diary-bahai-insert-monthly-entry]
|
||||
["Yearly" diary-bahai-insert-yearly-entry])
|
||||
("Insert Chinese"
|
||||
["One time" diary-chinese-insert-entry]
|
||||
["Monthly" diary-chinese-insert-monthly-entry]
|
||||
["Yearly" diary-chinese-insert-yearly-entry]
|
||||
["Anniversary" diary-chinese-insert-anniversary-entry])
|
||||
("Insert Islamic"
|
||||
["One time" diary-islamic-insert-entry]
|
||||
["Monthly" diary-islamic-insert-monthly-entry]
|
||||
|
|
|
@ -689,6 +689,12 @@ details, see the documentation for the variable `diary-list-entries-hook'."
|
|||
:type 'string
|
||||
:group 'diary)
|
||||
|
||||
(defcustom diary-chinese-entry-symbol "C"
|
||||
"Symbol indicating a diary entry according to the Chinese calendar."
|
||||
:type 'string
|
||||
:group 'diary
|
||||
:version "24.5")
|
||||
|
||||
(define-obsolete-variable-alias 'hebrew-diary-entry-symbol
|
||||
'diary-hebrew-entry-symbol "23.1")
|
||||
|
||||
|
@ -1709,6 +1715,10 @@ line."
|
|||
(define-key map "iBd" 'diary-bahai-insert-entry)
|
||||
(define-key map "iBm" 'diary-bahai-insert-monthly-entry)
|
||||
(define-key map "iBy" 'diary-bahai-insert-yearly-entry)
|
||||
(define-key map "iCd" 'diary-chinese-insert-entry)
|
||||
(define-key map "iCm" 'diary-chinese-insert-monthly-entry)
|
||||
(define-key map "iCy" 'diary-chinese-insert-yearly-entry)
|
||||
(define-key map "iCa" 'diary-chinese-insert-anniversary-entry)
|
||||
(define-key map "?" 'calendar-goto-info-node)
|
||||
(define-key map "Hm" 'cal-html-cursor-month)
|
||||
(define-key map "Hy" 'cal-html-cursor-year)
|
||||
|
|
|
@ -2396,6 +2396,11 @@ return a font-lock pattern matching array of MONTHS and marking SYMBOL."
|
|||
cal-bahai
|
||||
calendar-bahai-month-name-array
|
||||
diary-bahai-entry-symbol)
|
||||
(diary-font-lock-keywords-1 diary-chinese-mark-entries
|
||||
diary-chinese-list-entries
|
||||
cal-china
|
||||
calendar-chinese-month-name-array
|
||||
diary-chinese-entry-symbol)
|
||||
(list
|
||||
(cons
|
||||
(format "^%s.*$" (regexp-quote diary-include-string))
|
||||
|
@ -2412,7 +2417,8 @@ return a font-lock pattern matching array of MONTHS and marking SYMBOL."
|
|||
(regexp-opt (mapcar 'regexp-quote
|
||||
(list diary-hebrew-entry-symbol
|
||||
diary-islamic-entry-symbol
|
||||
diary-bahai-entry-symbol))
|
||||
diary-bahai-entry-symbol
|
||||
diary-chinese-entry-symbol))
|
||||
t))
|
||||
'(1 font-lock-constant-face))
|
||||
'(diary-font-lock-sexps . font-lock-keyword-face)
|
||||
|
|
Loading…
Add table
Reference in a new issue