123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 |
- (require 'org)
- (declare-function bbdb "ext:bbdb-com" (string elidep))
- (declare-function bbdb-company "ext:bbdb-com" (string elidep))
- (declare-function bbdb-current-record "ext:bbdb-com"
- (&optional planning-on-modifying))
- (declare-function bbdb-name "ext:bbdb-com" (string elidep))
- (declare-function bbdb-record-getprop "ext:bbdb" (record property))
- (declare-function bbdb-record-name "ext:bbdb" (record))
- (org-add-link-type "bbdb" 'org-bbdb-open 'org-bbdb-export)
- (add-hook 'org-store-link-functions 'org-bbdb-store-link)
- (defun org-bbdb-store-link ()
- "Store a link to a BBDB database entry."
- (when (eq major-mode 'bbdb-mode)
-
- (let* ((name (bbdb-record-name (bbdb-current-record)))
- (company (bbdb-record-getprop (bbdb-current-record) 'company))
- (link (org-make-link "bbdb:" name)))
- (org-store-link-props :type "bbdb" :name name :company company
- :link link :description name)
- link)))
- (defun org-bbdb-export (path desc format)
- "Create the export version of a BBDB link specified by PATH or DESC.
- If exporting to either HTML or LaTeX FORMAT the link will be
- italicised, in all other cases it is left unchanged."
- "Create the exprt verison of a bbdb link."
- (cond
- ((eq format 'html) (format "<i>%s</i>" (or desc path)))
- ((eq format 'latex) (format "\\textit{%s}" (or desc path)))
- (t (or desc path))))
- (defun org-bbdb-open (name)
- "Follow a BBDB link to NAME."
- (require 'bbdb)
- (let ((inhibit-redisplay (not debug-on-error))
- (bbdb-electric-p nil))
- (catch 'exit
-
- (bbdb-name (concat "\\`" name "\\'") nil)
- (if (< 0 (buffer-size (get-buffer "*BBDB*"))) (throw 'exit nil))
-
- (bbdb-company (concat "\\`" name "\\'") nil)
- (if (< 0 (buffer-size (get-buffer "*BBDB*"))) (throw 'exit nil))
-
- (bbdb-name name nil)
- (if (< 0 (buffer-size (get-buffer "*BBDB*"))) (throw 'exit nil))
-
- (bbdb-company name nil)
- (if (< 0 (buffer-size (get-buffer "*BBDB*"))) (throw 'exit nil))
-
- (bbdb name nil)
- (when (= 0 (buffer-size (get-buffer "*BBDB*")))
- (delete-window (get-buffer-window "*BBDB*"))
- (error "No matching BBDB record")))))
- (provide 'org-bbdb)
|