org-bbdb.el 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541
  1. ;;; org-bbdb.el --- Support for links to BBDB entries -*- lexical-binding: t; -*-
  2. ;; Copyright (C) 2004-2018 Free Software Foundation, Inc.
  3. ;; Authors: Carsten Dominik <carsten at orgmode dot org>
  4. ;; Thomas Baumann <thomas dot baumann at ch dot tum dot de>
  5. ;; Keywords: outlines, hypermedia, calendar, wp
  6. ;; Homepage: http://orgmode.org
  7. ;;
  8. ;; This file is part of GNU Emacs.
  9. ;;
  10. ;; GNU Emacs is free software: you can redistribute it and/or modify
  11. ;; it under the terms of the GNU General Public License as published by
  12. ;; the Free Software Foundation, either version 3 of the License, or
  13. ;; (at your option) any later version.
  14. ;; GNU Emacs is distributed in the hope that it will be useful,
  15. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. ;; GNU General Public License for more details.
  18. ;; You should have received a copy of the GNU General Public License
  19. ;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
  20. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  21. ;;
  22. ;;; Commentary:
  23. ;; This file implements links to BBDB database entries from within Org.
  24. ;; Org mode loads this module by default - if this is not what you want,
  25. ;; configure the variable `org-modules'.
  26. ;; It also implements an interface (based on Ivar Rummelhoff's
  27. ;; bbdb-anniv.el) for those Org users, who do not use the diary
  28. ;; but who do want to include the anniversaries stored in the BBDB
  29. ;; into the org-agenda. If you already include the `diary' into the
  30. ;; agenda, you might want to prefer to include the anniversaries in
  31. ;; the diary using bbdb-anniv.el.
  32. ;;
  33. ;; Put the following in /somewhere/at/home/diary.org and make sure
  34. ;; that this file is in `org-agenda-files'.
  35. ;;
  36. ;; %%(org-bbdb-anniversaries)
  37. ;;
  38. ;; For example my diary.org looks like:
  39. ;; * Anniversaries
  40. ;; #+CATEGORY: Anniv
  41. ;; %%(org-bbdb-anniversaries)
  42. ;;
  43. ;;
  44. ;; To add an anniversary to a BBDB record, press `C-o' in the record.
  45. ;; You will be prompted for the field name, in this case it must be
  46. ;; "anniversary". If this is the first time you are using this field,
  47. ;; you need to confirm that it should be created.
  48. ;;
  49. ;; The format of an anniversary field stored in BBDB is the following
  50. ;; (items in {} are optional):
  51. ;;
  52. ;; YYYY-MM-DD{ CLASS-OR-FORMAT-STRING}
  53. ;; {\nYYYY-MM-DD CLASS-OR-FORMAT-STRING}...
  54. ;;
  55. ;; CLASS-OR-FORMAT-STRING is one of two things:
  56. ;;
  57. ;; - an identifier for a class of anniversaries (eg. birthday or
  58. ;; wedding) from `org-bbdb-anniversary-format-alist' which then
  59. ;; defines the format string for this class
  60. ;; - the (format) string displayed in the diary.
  61. ;;
  62. ;; You can enter multiple anniversaries for a single BBDB record by
  63. ;; separating them with a newline character. At the BBDB prompt for
  64. ;; the field value, type `C-q C-j' to enter a newline between two
  65. ;; anniversaries.
  66. ;;
  67. ;; If you omit the CLASS-OR-FORMAT-STRING entirely, it defaults to the
  68. ;; value of `org-bbdb-default-anniversary-format' ("birthday" by
  69. ;; default).
  70. ;;
  71. ;; The substitutions in the format string are (in order):
  72. ;; - the name of the record containing this anniversary
  73. ;; - the number of years
  74. ;; - an ordinal suffix (st, nd, rd, th) for the year
  75. ;;
  76. ;; See the documentation of `org-bbdb-anniversary-format-alist' for
  77. ;; further options.
  78. ;;
  79. ;; Example
  80. ;;
  81. ;; 1973-06-22
  82. ;; 20??-??-?? wedding
  83. ;; 1998-03-12 %s created bbdb-anniv.el %d years ago
  84. ;;
  85. ;; From Org's agenda, you can use `C-c C-o' to jump to the BBDB
  86. ;; link from which the entry at point originates.
  87. ;;
  88. ;;; Code:
  89. (require 'org)
  90. (require 'cl-lib)
  91. ;; Declare external functions and variables
  92. (declare-function bbdb "ext:bbdb-com" (string elidep))
  93. (declare-function bbdb-company "ext:bbdb-com" (string elidep))
  94. (declare-function bbdb-current-record "ext:bbdb-com"
  95. (&optional planning-on-modifying))
  96. (declare-function bbdb-name "ext:bbdb-com" (string elidep))
  97. (declare-function bbdb-completing-read-record "ext:bbdb-com"
  98. (prompt &optional omit-records))
  99. (declare-function bbdb-record-field "ext:bbdb" (record field))
  100. (declare-function bbdb-record-getprop "ext:bbdb" (record property))
  101. (declare-function bbdb-record-name "ext:bbdb" (record))
  102. (declare-function bbdb-records "ext:bbdb"
  103. (&optional dont-check-disk already-in-db-buffer))
  104. (declare-function bbdb-split "ext:bbdb" (string separators))
  105. (declare-function bbdb-string-trim "ext:bbdb" (string))
  106. (declare-function bbdb-record-get-field "ext:bbdb" (record field))
  107. (declare-function bbdb-search-name "ext:bbdb-com" (regexp &optional layout))
  108. (declare-function bbdb-search-organization "ext:bbdb-com" (regexp &optional layout))
  109. ;; `bbdb-record-note' was part of BBDB v3.x
  110. (declare-function bbdb-record-note "ext:bbdb" (record label))
  111. ;; `bbdb-record-xfield' replaces it in recent BBDB v3.x+
  112. (declare-function bbdb-record-xfield "ext:bbdb" (record label))
  113. (declare-function calendar-leap-year-p "calendar" (year))
  114. (declare-function diary-ordinal-suffix "diary-lib" (n))
  115. (with-no-warnings (defvar date)) ;; unprefixed, from calendar.el
  116. ;; Customization
  117. (defgroup org-bbdb-anniversaries nil
  118. "Customizations for including anniversaries from BBDB into Agenda."
  119. :group 'org-bbdb)
  120. (defcustom org-bbdb-default-anniversary-format "birthday"
  121. "Default anniversary class."
  122. :type 'string
  123. :group 'org-bbdb-anniversaries
  124. :require 'bbdb)
  125. (defcustom org-bbdb-general-anniversary-description-after 7
  126. "When to switch anniversary descriptions to a more general format.
  127. Anniversary descriptions include the point in time, when the
  128. anniversary appears. This is, in its most general form, just the
  129. date of the anniversary. Or more specific terms, like \"today\",
  130. \"tomorrow\" or \"in n days\" are used to describe the time span.
  131. If the anniversary happens in less than that number of days, the
  132. specific description is used. Otherwise, the general one is
  133. used."
  134. :group 'org-bbdb-anniversaries
  135. :version "26.1"
  136. :package-version '(Org . "9.1")
  137. :type 'integer
  138. :require 'bbdb
  139. :safe #'integerp)
  140. (defcustom org-bbdb-anniversary-format-alist
  141. '(("birthday" .
  142. (lambda (name years suffix)
  143. (concat "Birthday: [[bbdb:" name "][" name " ("
  144. (format "%s" years) ; handles numbers as well as strings
  145. suffix ")]]")))
  146. ("wedding" .
  147. (lambda (name years suffix)
  148. (concat "[[bbdb:" name "][" name "'s "
  149. (format "%s" years)
  150. suffix " wedding anniversary]]"))))
  151. "How different types of anniversaries should be formatted.
  152. An alist of elements (STRING . FORMAT) where STRING is the name of an
  153. anniversary class and format is either:
  154. 1) A format string with the following substitutions (in order):
  155. - the name of the record containing this anniversary
  156. - the number of years
  157. - an ordinal suffix (st, nd, rd, th) for the year
  158. 2) A function to be called with three arguments: NAME YEARS SUFFIX
  159. (string int string) returning a string for the diary or nil.
  160. 3) An Emacs Lisp form that should evaluate to a string (or nil) in the
  161. scope of variables NAME, YEARS and SUFFIX (among others)."
  162. :type '(alist :key-type (string :tag "Class")
  163. :value-type (function :tag "Function"))
  164. :group 'org-bbdb-anniversaries
  165. :require 'bbdb)
  166. (defcustom org-bbdb-anniversary-field 'anniversary
  167. "The BBDB field which contains anniversaries.
  168. The anniversaries are stored in the following format
  169. YYYY-MM-DD Class-or-Format-String
  170. where class is one of the customized classes for anniversaries;
  171. birthday and wedding are predefined. Format-String can take three
  172. substitutions 1) the name of the record containing this
  173. anniversary, 2) the number of years, and 3) an ordinal suffix for
  174. the year.
  175. Multiple anniversaries can be separated by \\n."
  176. :type 'symbol
  177. :group 'org-bbdb-anniversaries
  178. :require 'bbdb)
  179. (defcustom org-bbdb-extract-date-fun 'org-bbdb-anniv-extract-date
  180. "How to retrieve `month date year' from the anniversary field.
  181. Customize if you have already filled your BBDB with dates
  182. different from YYYY-MM-DD. The function must return a list (month
  183. date year)."
  184. :type 'function
  185. :group 'org-bbdb-anniversaries
  186. :require 'bbdb)
  187. ;; Install the link type
  188. (org-link-set-parameters "bbdb"
  189. :follow #'org-bbdb-open
  190. :export #'org-bbdb-export
  191. :complete #'org-bbdb-complete-link
  192. :store #'org-bbdb-store-link)
  193. ;; Implementation
  194. (defun org-bbdb-store-link ()
  195. "Store a link to a BBDB database entry."
  196. (when (eq major-mode 'bbdb-mode)
  197. ;; This is BBDB, we make this link!
  198. (let* ((rec (bbdb-current-record))
  199. (name (bbdb-record-name rec))
  200. (company (if (fboundp 'bbdb-record-getprop)
  201. (bbdb-record-getprop rec 'company)
  202. (car (bbdb-record-field rec 'organization))))
  203. (link (concat "bbdb:" name)))
  204. (org-store-link-props :type "bbdb" :name name :company company
  205. :link link :description name)
  206. link)))
  207. (defun org-bbdb-export (path desc format)
  208. "Create the export version of a BBDB link specified by PATH or DESC.
  209. If exporting to either HTML or LaTeX FORMAT the link will be
  210. italicized, in all other cases it is left unchanged."
  211. (when (string= desc (format "bbdb:%s" path))
  212. (setq desc path))
  213. (cond
  214. ((eq format 'html) (format "<i>%s</i>" desc))
  215. ((eq format 'latex) (format "\\textit{%s}" desc))
  216. ((eq format 'odt)
  217. (format "<text:span text:style-name=\"Emphasis\">%s</text:span>" desc))
  218. (t desc)))
  219. (defun org-bbdb-open (name)
  220. "Follow a BBDB link to NAME."
  221. (require 'bbdb-com)
  222. (let ((inhibit-redisplay (not debug-on-error)))
  223. (if (fboundp 'bbdb-name)
  224. (org-bbdb-open-old name)
  225. (org-bbdb-open-new name))))
  226. (defun org-bbdb-open-old (name)
  227. (catch 'exit
  228. ;; Exact match on name
  229. (bbdb-name (concat "\\`" name "\\'") nil)
  230. (if (< 0 (buffer-size (get-buffer "*BBDB*"))) (throw 'exit nil))
  231. ;; Exact match on name
  232. (bbdb-company (concat "\\`" name "\\'") nil)
  233. (if (< 0 (buffer-size (get-buffer "*BBDB*"))) (throw 'exit nil))
  234. ;; Partial match on name
  235. (bbdb-name name nil)
  236. (if (< 0 (buffer-size (get-buffer "*BBDB*"))) (throw 'exit nil))
  237. ;; Partial match on company
  238. (bbdb-company name nil)
  239. (if (< 0 (buffer-size (get-buffer "*BBDB*"))) (throw 'exit nil))
  240. ;; General match including network address and notes
  241. (bbdb name nil)
  242. (when (= 0 (buffer-size (get-buffer "*BBDB*")))
  243. (delete-window (get-buffer-window "*BBDB*"))
  244. (error "No matching BBDB record"))))
  245. (defun org-bbdb-open-new (name)
  246. (catch 'exit
  247. ;; Exact match on name
  248. (bbdb-search-name (concat "\\`" name "\\'") nil)
  249. (if (< 0 (buffer-size (get-buffer "*BBDB*"))) (throw 'exit nil))
  250. ;; Exact match on name
  251. (bbdb-search-organization (concat "\\`" name "\\'") nil)
  252. (if (< 0 (buffer-size (get-buffer "*BBDB*"))) (throw 'exit nil))
  253. ;; Partial match on name
  254. (bbdb-search-name name nil)
  255. (if (< 0 (buffer-size (get-buffer "*BBDB*"))) (throw 'exit nil))
  256. ;; Partial match on company
  257. (bbdb-search-organization name nil)
  258. (if (< 0 (buffer-size (get-buffer "*BBDB*"))) (throw 'exit nil))
  259. ;; General match including network address and notes
  260. (bbdb name nil)
  261. (when (= 0 (buffer-size (get-buffer "*BBDB*")))
  262. (delete-window (get-buffer-window "*BBDB*"))
  263. (error "No matching BBDB record"))))
  264. (defun org-bbdb-anniv-extract-date (time-str)
  265. "Convert YYYY-MM-DD to (month date year).
  266. Argument TIME-STR is the value retrieved from BBDB. If YYYY- is omitted
  267. it will be considered unknown."
  268. (pcase (org-split-string time-str "-")
  269. (`(,a ,b nil) (list (string-to-number a) (string-to-number b) nil))
  270. (`(,a ,b ,c) (list (string-to-number b)
  271. (string-to-number c)
  272. (string-to-number a)))))
  273. (defun org-bbdb-anniv-split (str)
  274. "Split multiple entries in the BBDB anniversary field.
  275. Argument STR is the anniversary field in BBDB."
  276. (let ((pos (string-match "[ \t]" str)))
  277. (if pos (list (substring str 0 pos)
  278. (bbdb-string-trim (substring str pos)))
  279. (list str nil))))
  280. (defvar org-bbdb-anniv-hash nil
  281. "A hash holding anniversaries extracted from BBDB.
  282. The hash table is created on first use.")
  283. (defvar org-bbdb-updated-p t
  284. "This is non-nil if BBDB has been updated since we last built the hash.")
  285. (defun org-bbdb-make-anniv-hash ()
  286. "Create a hash with anniversaries extracted from BBDB, for fast access.
  287. The anniversaries are assumed to be stored `org-bbdb-anniversary-field'."
  288. (let ((old-bbdb (fboundp 'bbdb-record-getprop))
  289. (record-func (if (fboundp 'bbdb-record-xfield)
  290. 'bbdb-record-xfield
  291. 'bbdb-record-note))
  292. split tmp annivs)
  293. (clrhash org-bbdb-anniv-hash)
  294. (dolist (rec (bbdb-records))
  295. (when (setq annivs (if old-bbdb
  296. (bbdb-record-getprop
  297. rec org-bbdb-anniversary-field)
  298. (funcall record-func
  299. rec org-bbdb-anniversary-field)))
  300. (setq annivs (if old-bbdb
  301. (bbdb-split annivs "\n")
  302. ;; parameter order is reversed in new bbdb
  303. (bbdb-split "\n" annivs)))
  304. (while annivs
  305. (setq split (org-bbdb-anniv-split (pop annivs)))
  306. (pcase-let ((`(,m ,d ,y) (funcall org-bbdb-extract-date-fun
  307. (car split))))
  308. (setq tmp (gethash (list m d) org-bbdb-anniv-hash))
  309. (puthash (list m d) (cons (list y
  310. (bbdb-record-name rec)
  311. (cadr split))
  312. tmp)
  313. org-bbdb-anniv-hash))))))
  314. (setq org-bbdb-updated-p nil))
  315. (defun org-bbdb-updated (_rec)
  316. "Record the fact that BBDB has been updated.
  317. This is used by Org to re-create the anniversary hash table."
  318. (setq org-bbdb-updated-p t))
  319. (add-hook 'bbdb-after-change-hook 'org-bbdb-updated)
  320. ;;;###autoload
  321. (defun org-bbdb-anniversaries ()
  322. "Extract anniversaries from BBDB for display in the agenda."
  323. (require 'bbdb)
  324. (require 'diary-lib)
  325. (unless (hash-table-p org-bbdb-anniv-hash)
  326. (setq org-bbdb-anniv-hash
  327. (make-hash-table :test 'equal :size 366)))
  328. (when (or org-bbdb-updated-p
  329. (= 0 (hash-table-count org-bbdb-anniv-hash)))
  330. (org-bbdb-make-anniv-hash))
  331. (let* ((m (car date)) ; month
  332. (d (nth 1 date)) ; day
  333. (y (nth 2 date)) ; year
  334. (annivs (gethash (list m d) org-bbdb-anniv-hash))
  335. (text ())
  336. rec recs)
  337. ;; we don't want to miss people born on Feb. 29th
  338. (when (and (= m 3) (= d 1)
  339. (not (null (gethash (list 2 29) org-bbdb-anniv-hash)))
  340. (not (calendar-leap-year-p y)))
  341. (setq recs (gethash (list 2 29) org-bbdb-anniv-hash))
  342. (while (setq rec (pop recs))
  343. (push rec annivs)))
  344. (when annivs
  345. (while (setq rec (pop annivs))
  346. (when rec
  347. (let* ((class (or (nth 2 rec)
  348. org-bbdb-default-anniversary-format))
  349. (form (or (cdr (assoc-string
  350. class org-bbdb-anniversary-format-alist t))
  351. class)) ; (as format string)
  352. (name (nth 1 rec))
  353. (years (if (eq (car rec) nil)
  354. "unknown"
  355. (- y (car rec))))
  356. (suffix (if (eq (car rec) nil)
  357. ""
  358. (diary-ordinal-suffix years)))
  359. (tmp (cond
  360. ((functionp form)
  361. (funcall form name years suffix))
  362. ((listp form) (eval form))
  363. (t (format form name years suffix)))))
  364. (org-add-props tmp nil 'org-bbdb-name name)
  365. (if text
  366. (setq text (append text (list tmp)))
  367. (setq text (list tmp)))))
  368. ))
  369. text))
  370. ;;; Return list of anniversaries for today and the next n-1 (default: n=7) days.
  371. ;;; This is meant to be used in an org file instead of org-bbdb-anniversaries:
  372. ;;;
  373. ;;; %%(org-bbdb-anniversaries-future)
  374. ;;;
  375. ;;; or
  376. ;;;
  377. ;;; %%(org-bbdb-anniversaries-future 3)
  378. ;;;
  379. ;;; to override the 7-day default.
  380. (defun org-bbdb-date-list (d n)
  381. "Return a list of dates in (m d y) format from the given date D to n-1 days hence."
  382. (let ((abs (calendar-absolute-from-gregorian d)))
  383. (mapcar (lambda (i) (calendar-gregorian-from-absolute (+ abs i)))
  384. (number-sequence 0 (1- n)))))
  385. (defun org-bbdb-anniversary-description (agenda-date anniv-date)
  386. "Return a string used to incorporate into an agenda anniversary entry.
  387. The calculation of the anniversary description string is based on
  388. the difference between the anniversary date, given as ANNIV-DATE,
  389. and the date on which the entry appears in the agenda, given as
  390. AGENDA-DATE. This makes it possible to have different entries
  391. for the same event depending on if it occurs in the next few days
  392. or far away in the future."
  393. (let ((delta (- (calendar-absolute-from-gregorian anniv-date)
  394. (calendar-absolute-from-gregorian agenda-date))))
  395. (cond
  396. ((= delta 0) " -- today\\&")
  397. ((= delta 1) " -- tomorrow\\&")
  398. ((< delta org-bbdb-general-anniversary-description-after) (format " -- in %d days\\&" delta))
  399. ((pcase-let ((`(,month ,day ,year) anniv-date))
  400. (format " -- %d-%02d-%02d\\&" year month day))))))
  401. (defun org-bbdb-anniversaries-future (&optional n)
  402. "Return list of anniversaries for today and the next n-1 days (default n=7)."
  403. (let ((n (or n 7)))
  404. (when (<= n 0)
  405. (error "The (optional) argument of `org-bbdb-anniversaries-future' \
  406. must be positive"))
  407. (let (
  408. ;; List of relevant dates.
  409. (dates (org-bbdb-date-list date n))
  410. ;; Function to annotate text of each element of l with the
  411. ;; anniversary date d.
  412. (annotate-descriptions
  413. (lambda (agenda-date d l)
  414. (mapcar (lambda (x)
  415. ;; The assumption here is that x is a bbdb link
  416. ;; of the form [[bbdb:name][description]].
  417. ;; This function rather arbitrarily modifies
  418. ;; the description by adding the date to it in
  419. ;; a fixed format.
  420. (let ((desc (org-bbdb-anniversary-description
  421. agenda-date d)))
  422. (string-match "]]" x)
  423. (replace-match desc nil nil x)))
  424. l))))
  425. ;; Map a function that generates anniversaries for each date
  426. ;; over the dates and nconc the results into a single list. When
  427. ;; it is no longer necessary to support older versions of Emacs,
  428. ;; this can be done with a cl-mapcan; for now, we use the (apply
  429. ;; #'nconc ...) method for compatibility.
  430. (apply #'nconc
  431. (mapcar
  432. (lambda (d)
  433. (let ((agenda-date date)
  434. (date d))
  435. ;; Rebind 'date' so that org-bbdb-anniversaries will
  436. ;; be fooled into giving us the list for the given
  437. ;; date and then annotate the descriptions for that
  438. ;; date.
  439. (funcall annotate-descriptions agenda-date d (org-bbdb-anniversaries))))
  440. dates)))))
  441. (defun org-bbdb-complete-link ()
  442. "Read a bbdb link with name completion."
  443. (require 'bbdb-com)
  444. (let ((rec (bbdb-completing-read-record "Name: ")))
  445. (concat "bbdb:"
  446. (bbdb-record-name (if (listp rec)
  447. (car rec)
  448. rec)))))
  449. (defun org-bbdb-anniv-export-ical ()
  450. "Extract anniversaries from BBDB and convert them to icalendar format."
  451. (require 'bbdb)
  452. (require 'diary-lib)
  453. (unless (hash-table-p org-bbdb-anniv-hash)
  454. (setq org-bbdb-anniv-hash
  455. (make-hash-table :test 'equal :size 366)))
  456. (when (or org-bbdb-updated-p
  457. (= 0 (hash-table-count org-bbdb-anniv-hash)))
  458. (org-bbdb-make-anniv-hash))
  459. (maphash 'org-bbdb-format-vevent org-bbdb-anniv-hash))
  460. (defun org-bbdb-format-vevent (key recs)
  461. (let (rec categ)
  462. (while (setq rec (pop recs))
  463. (setq categ (or (nth 2 rec) org-bbdb-default-anniversary-format))
  464. (princ (format "BEGIN:VEVENT
  465. UID: ANNIV-%4i%02i%02i-%s
  466. DTSTART:%4i%02i%02i
  467. SUMMARY:%s
  468. DESCRIPTION:%s
  469. CATEGORIES:%s
  470. RRULE:FREQ=YEARLY
  471. END:VEVENT\n"
  472. (nth 0 rec) (nth 0 key) (nth 1 key)
  473. (mapconcat 'identity
  474. (org-split-string (nth 1 rec) "[^a-zA-Z0-90]+")
  475. "-")
  476. (nth 0 rec) (nth 0 key) (nth 1 key)
  477. (nth 1 rec)
  478. (concat (capitalize categ) " " (nth 1 rec))
  479. categ)))))
  480. (provide 'org-bbdb)
  481. ;; Local variables:
  482. ;; generated-autoload-file: "org-loaddefs.el"
  483. ;; End:
  484. ;;; org-bbdb.el ends here