如何定义希伯来纪念日以显示在组织议程中?
How to define Hebrew anniversaries to show up in Org agenda?
如何定义希伯来语纪念日(如生日)以显示在组织议程中?最好的办法是通过 BBDB 来完成。到目前为止,我设法将 anniversaries/birthdays 添加到 BBDB 并将它们显示在 org-agenda 中。现在我需要进入下一步并提供这些日期作为希伯来语日期。在日记模式下,日期看起来像 HSivan 17, 5776 。但是,如果我将它插入到 BBDB,如 anniversary: HSivan 17, 5776 birthday
- 我在尝试生成议程视图时遇到错误:bad-sexp at line 5 /path/to/agenda.org (org-bbdb-anniversaries)
。也许还有其他方法(没有 BBDB),也许我可以直接将它们列在 .org 文件中?
我相信您可以通过将其放入 .emacs
:
来解决您的 bbdb 问题
(require 'org-bbdb)
一般来说,除了基于 ISO 的西方日历之外,org-mode 不能很好地(或根本)处理日历。
如果你想在 bbdb 中存储不同格式的日期,你可以
自定义 org-bbdb-extract-date-fun
。您必须编写自己的函数来解析希伯来语日期和 return(月日年)。
这将允许您使用使用希伯来日期的 bbdb 数据库,但它不会显示例如使用希伯来日期的议程输出。这是一个更难的问题,特别是因为 ISO 日历假设渗透到组织模式代码库中。
编辑:这是一个函数,它接受像 "Heshvan 17, 5776" 这样的字符串作为参数,并生成组织可以使用的(月、日、年)元组:
;;; This function uses functions and variables defined in calendar.el
;;; and cal-hebrew.el
(require 'calendar)
(require 'cal-hebrew)
(defun org-bbdb-anniv-extract-hebrew-date (date-string)
"Parse the string, assumed to be in the form \"MONTHNAME day,
year\", using Hebrew month names. Day is an integer, roughly
between 1 and 30 (the range depends on the month and the
year), and year is an integer representing a Hebrew calendar
year (roughly 5776 ~= 2015)."
(let* ((date-list (split-string date-string))
(month-name (nth 0 date-list))
(day (string-to-number (nth 1 date-list)))
(year (string-to-number (nth 2 date-list)))
(month-array (if (calendar-hebrew-leap-year-p year)
calendar-hebrew-month-name-array-leap-year
calendar-hebrew-month-name-array-common-year))
(month (cdr (assoc-string
month-name
(calendar-make-alist month-array 1)))))
(calendar-gregorian-from-absolute
(calendar-hebrew-to-absolute (list month day year)))))
;; test: (org-bbdb-anniv-extract-hebrew-date "Heshvan 17, 5776") ==> (10 30 2015)
;; test: (org-bbdb-anniv-extract-hebrew-date "Heshvan 17, 3762") ==> (10 22 1)
;; I hope these are right.
;; To get org-bbdb to use this function to read dates from the BBDB
;; database, instead of the standard org-bbdb-anniv-extract-date, do
;; this:
;; (setq org-bbdb-extract-date-fun #'org-bbdb-anniv-extract-hebrew-date)
;; N.B. *ALL* dates in the BBDB database will be read using this
;; function, so *ALL* of them must be Hebrew calendar dates. There is
;; no provision for dates in different formats. To do that, one would
;; need to write a function that can recognize dates in different
;; formats (probably using heuristics) and then call the right
;; conversion function. That's beyond the scope of this answer.
;; Also, calendrical calculations are notoriously difficult to get
;; right: this is no exception. In particular, the month calculation
;; is probably valid only for dates in the Common Era, i.e. for years
;; >= 3762. cal-hebrew.el has more details. But in any case, no
;; guarantees: if it breaks, you get to keep the pieces.
如何定义希伯来语纪念日(如生日)以显示在组织议程中?最好的办法是通过 BBDB 来完成。到目前为止,我设法将 anniversaries/birthdays 添加到 BBDB 并将它们显示在 org-agenda 中。现在我需要进入下一步并提供这些日期作为希伯来语日期。在日记模式下,日期看起来像 HSivan 17, 5776 。但是,如果我将它插入到 BBDB,如 anniversary: HSivan 17, 5776 birthday
- 我在尝试生成议程视图时遇到错误:bad-sexp at line 5 /path/to/agenda.org (org-bbdb-anniversaries)
。也许还有其他方法(没有 BBDB),也许我可以直接将它们列在 .org 文件中?
我相信您可以通过将其放入 .emacs
:
(require 'org-bbdb)
一般来说,除了基于 ISO 的西方日历之外,org-mode 不能很好地(或根本)处理日历。
如果你想在 bbdb 中存储不同格式的日期,你可以
自定义 org-bbdb-extract-date-fun
。您必须编写自己的函数来解析希伯来语日期和 return(月日年)。
这将允许您使用使用希伯来日期的 bbdb 数据库,但它不会显示例如使用希伯来日期的议程输出。这是一个更难的问题,特别是因为 ISO 日历假设渗透到组织模式代码库中。
编辑:这是一个函数,它接受像 "Heshvan 17, 5776" 这样的字符串作为参数,并生成组织可以使用的(月、日、年)元组:
;;; This function uses functions and variables defined in calendar.el
;;; and cal-hebrew.el
(require 'calendar)
(require 'cal-hebrew)
(defun org-bbdb-anniv-extract-hebrew-date (date-string)
"Parse the string, assumed to be in the form \"MONTHNAME day,
year\", using Hebrew month names. Day is an integer, roughly
between 1 and 30 (the range depends on the month and the
year), and year is an integer representing a Hebrew calendar
year (roughly 5776 ~= 2015)."
(let* ((date-list (split-string date-string))
(month-name (nth 0 date-list))
(day (string-to-number (nth 1 date-list)))
(year (string-to-number (nth 2 date-list)))
(month-array (if (calendar-hebrew-leap-year-p year)
calendar-hebrew-month-name-array-leap-year
calendar-hebrew-month-name-array-common-year))
(month (cdr (assoc-string
month-name
(calendar-make-alist month-array 1)))))
(calendar-gregorian-from-absolute
(calendar-hebrew-to-absolute (list month day year)))))
;; test: (org-bbdb-anniv-extract-hebrew-date "Heshvan 17, 5776") ==> (10 30 2015)
;; test: (org-bbdb-anniv-extract-hebrew-date "Heshvan 17, 3762") ==> (10 22 1)
;; I hope these are right.
;; To get org-bbdb to use this function to read dates from the BBDB
;; database, instead of the standard org-bbdb-anniv-extract-date, do
;; this:
;; (setq org-bbdb-extract-date-fun #'org-bbdb-anniv-extract-hebrew-date)
;; N.B. *ALL* dates in the BBDB database will be read using this
;; function, so *ALL* of them must be Hebrew calendar dates. There is
;; no provision for dates in different formats. To do that, one would
;; need to write a function that can recognize dates in different
;; formats (probably using heuristics) and then call the right
;; conversion function. That's beyond the scope of this answer.
;; Also, calendrical calculations are notoriously difficult to get
;; right: this is no exception. In particular, the month calculation
;; is probably valid only for dates in the Common Era, i.e. for years
;; >= 3762. cal-hebrew.el has more details. But in any case, no
;; guarantees: if it breaks, you get to keep the pieces.