如何定义出现在Org议程中的希伯来周年纪念日?

时间:2016-06-28 20:30:48

标签: emacs calendar org-mode hebrew

如何定义出现在Org议程中的希伯来周年纪念日(如生日)?最好的方法是通过BBDB来实现。到目前为止,我设法为BBDB添加纪念日/生日,并将其显示在组织议程中。现在我需要进入下一步并将这些日期作为希伯来日期提供。在日记模式中,日期似乎看起来像HSivan 17,5776。但是,如果我将其插入BBDB,如anniversary: HSivan 17, 5776 birthday - 我在尝试生成议程视图时遇到错误:bad-sexp at line 5 /path/to/agenda.org (org-bbdb-anniversaries)。也许有其他方法(没有BBDB),也许我可以直接在.org文件中列出它们?

2 个答案:

答案 0 :(得分:1)

一般情况下,组织模式与基于ISO的西方日历之外的日历不能很好地(或根本不能)处理。

如果要在bbdb中存储格式不同的日期,则可以 自定义org-bbdb-extract-date-fun。您必须编写自己的函数来解析希伯来语日期并返回(月份日)。

这将允许您使用希伯来日期使用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.

答案 1 :(得分:0)

我相信你可以通过将它放在.emacs

中来修复你的bbdb问题
(require 'org-bbdb)