From f7f1a7f08513d11eea7be2a771d3d900c1bb0054 Mon Sep 17 00:00:00 2001 From: Carsten Dominik Date: Thu, 12 Jun 2008 16:30:35 +0200 Subject: [PATCH] BBDB anniversaries are now links. Feature request from Rares Vernica, implementation by Thomas Baumann. --- lisp/org-agenda.el | 20 +++++++------------- lisp/org-bbdb.el | 34 ++++++++++------------------------ 2 files changed, 17 insertions(+), 37 deletions(-) diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el index da2359ec8..2f97f30d6 100644 --- a/lisp/org-agenda.el +++ b/lisp/org-agenda.el @@ -4502,20 +4502,14 @@ If this information is not given, the function uses the tree at point." (delete-region (point-at-bol) (1+ (point-at-eol))))) (beginning-of-line 0)))))) -(declare-function org-bbdb-follow-anniversary-link "org-bbdb" (&optional arg)) - -(defun org-agenda-open-link (&optional arg) +(defun org-agenda-open-link () "Follow the link in the current line, if any." - (interactive "P") - (if (and (fboundp 'org-bbdb-follow-anniversary-link) - (org-bbdb-follow-anniversary-link arg)) - nil ; ok, there was a link, we followed it - ;; There was no link - (org-agenda-copy-local-variable 'org-link-abbrev-alist-local) - (save-excursion - (save-restriction - (narrow-to-region (point-at-bol) (point-at-eol)) - (org-open-at-point))))) + (interactive) + (org-agenda-copy-local-variable 'org-link-abbrev-alist-local) + (save-excursion + (save-restriction + (narrow-to-region (point-at-bol) (point-at-eol)) + (org-open-at-point)))) (defun org-agenda-copy-local-variable (var) "Get a variable from a referenced buffer and install it here." diff --git a/lisp/org-bbdb.el b/lisp/org-bbdb.el index b39feb517..0fd1085f2 100644 --- a/lisp/org-bbdb.el +++ b/lisp/org-bbdb.el @@ -117,8 +117,16 @@ :require 'bbdb) (defcustom org-bbdb-anniversary-format-alist - '( ("birthday" . "Birthday: %s (%d%s)") - ("wedding" . "%s's %d%s wedding anniversary") ) + '(("birthday" lambda + (name years suffix) + (concat "Birthday: [[bbdb:" name "][" name " (" + (number-to-string years) + suffix ")]]")) + ("wedding" lambda + (name years suffix) + (concat "[[bbdb:" name "][" name "'s " + (number-to-string years) + suffix " wedding anniversary]]"))) "How different types of anniversaries should be formatted. An alist of elements (STRING . FORMAT) where STRING is the name of an anniversary class and format is either: @@ -312,28 +320,6 @@ This is used by Org to re-create the anniversary hash table." (when text (mapconcat 'identity text "; ")))) -(defun org-bbdb-follow-anniversary-link (arg) - "Check if there is a BBDB anniversary link in current line and follow it." - (let ((n (prefix-numeric-value arg)) - end name names last) - (setq name (get-text-property (point) 'org-bbdb-name)) - (save-excursion - (beginning-of-line 1) - (setq end (1- (point-at-eol))) - (setq last (1- (point))) - (while (and (setq next (next-single-property-change - (point) 'org-bbdb-name nil end)) - (> next last)) - (goto-char next) - (setq last next) - (setq names (cons (get-text-property (point) 'org-bbdb-name) names)))) - (setq names (nreverse (delq nil names))) - (if (setq name (or (and arg (nth (1- n) names)) - name - (car names))) - (progn (bbdb-name name nil) t) - nil))) - (provide 'org-bbdb) ;; arch-tag: 9e4f275d-d080-48c1-b040-62247f66b5c2 -- 2.11.4.GIT