Re: [O] [PATCH] integration with bbdb 3.0

2011-12-31 Thread Carsten Dominik

On 28.12.2011, at 20:06, Ivan Kanis wrote:

 Hi Bastien,
 
 The following patch fixes linking bbdb 3.0 records. Let me know if the
 patch needs improvement.

The patch looks OK to me.

Have you signed FSF papers?

- Carsten

 
 Take care,
 
 Ivan Kanis
 
 org-bbdb.patch




Re: [O] [PATCH] integration with bbdb 3.0

2011-12-31 Thread Ivan Kanis
Carsten Dominik carsten.domi...@gmail.com wrote:

 On 28.12.2011, at 20:06, Ivan Kanis wrote:

 Hi Bastien,
 
 The following patch fixes linking bbdb 3.0 records. Let me know if the
 patch needs improvement.

 Have you signed FSF papers?


Hi Carsten,

Yes I have.
-- 
Ivan Kanis
http://kanis.fr

I shall never make a new friend in my life, though perhaps a few
after I die.
-- Oscar Wilde



Re: [O] [PATCH] integration with bbdb 3.0

2011-12-31 Thread Carsten Dominik
Applied, thanks.

- Carsten

On 28.12.2011, at 20:06, Ivan Kanis wrote:

 Hi Bastien,
 
 The following patch fixes linking bbdb 3.0 records. Let me know if the
 patch needs improvement.
 
 Take care,
 
 Ivan Kanis
 
 org-bbdb.patch




Re: [O] [PATCH] integration with bbdb 3.0

2011-12-31 Thread Bastien
Hi Ivan,

Ivan Kanis ivan.ka...@googlemail.com writes:

 Have you signed FSF papers?

 Hi Carsten,

 Yes I have.

Great -- I added you to the list of contributors on
http://orgmode.org/worg/org-contribute.html

Thanks for this patch!

-- 
 Bastien



[O] [PATCH] integration with bbdb 3.0

2011-12-28 Thread Ivan Kanis
Hi Bastien,

The following patch fixes linking bbdb 3.0 records. Let me know if the
patch needs improvement.

Take care,

Ivan Kanis

diff --git a/emacs/org/org-bbdb.el b/emacs/org/org-bbdb.el
index 61f8258..ddb7e4a 100644
--- a/emacs/org/org-bbdb.el
+++ b/emacs/org/org-bbdb.el
@@ -118,6 +118,9 @@
 
 (defvar date)   ;; dynamically scoped from Org
 
+;; Support for version 2.35
+(defvar org-bbdb-old (fboundp 'bbdb-record-get-field-internal))
+
 ;; Customization
 
 (defgroup org-bbdb-anniversaries nil
@@ -195,8 +198,11 @@ date year).
   Store a link to a BBDB database entry.
   (when (eq major-mode 'bbdb-mode)
 ;; This is BBDB, we make this link!
-(let* ((name (bbdb-record-name (bbdb-current-record)))
-	   (company (bbdb-record-getprop (bbdb-current-record) 'company))
+(let* ((rec (bbdb-current-record))
+   (name (bbdb-record-name rec))
+	   (company (if org-bbdb-old
+(bbdb-record-getprop rec 'company)
+  (car (bbdb-record-get-field rec 'organization
 	   (link (org-make-link bbdb: name)))
   (org-store-link-props :type bbdb :name name :company company
 			:link link :description name)
@@ -218,24 +224,49 @@ italicized, in all other cases it is left unchanged.
   (require 'bbdb)
   (let ((inhibit-redisplay (not debug-on-error))
 	(bbdb-electric-p nil))
-(catch 'exit
-  ;; Exact match on name
-  (bbdb-name (concat \\` name \\') nil)
-  (if ( 0 (buffer-size (get-buffer *BBDB*))) (throw 'exit nil))
-  ;; Exact match on name
-  (bbdb-company (concat \\` name \\') nil)
-  (if ( 0 (buffer-size (get-buffer *BBDB*))) (throw 'exit nil))
-  ;; Partial match on name
-  (bbdb-name name nil)
-  (if ( 0 (buffer-size (get-buffer *BBDB*))) (throw 'exit nil))
-  ;; Partial match on company
-  (bbdb-company name nil)
-  (if ( 0 (buffer-size (get-buffer *BBDB*))) (throw 'exit nil))
-  ;; General match including network address and notes
-  (bbdb name nil)
-  (when (= 0 (buffer-size (get-buffer *BBDB*)))
-	(delete-window (get-buffer-window *BBDB*))
-	(error No matching BBDB record)
+(if org-bbdb-old
+(org-bbdb-open-old)
+  (org-bbdb-open-new
+
+(defun org-bbdb-open-old ()
+  (catch 'exit
+;; Exact match on name
+(bbdb-name (concat \\` name \\') nil)
+(if ( 0 (buffer-size (get-buffer *BBDB*))) (throw 'exit nil))
+;; Exact match on name
+(bbdb-company (concat \\` name \\') nil)
+(if ( 0 (buffer-size (get-buffer *BBDB*))) (throw 'exit nil))
+;; Partial match on name
+(bbdb-name name nil)
+(if ( 0 (buffer-size (get-buffer *BBDB*))) (throw 'exit nil))
+;; Partial match on company
+(bbdb-company name nil)
+(if ( 0 (buffer-size (get-buffer *BBDB*))) (throw 'exit nil))
+;; General match including network address and notes
+(bbdb name nil)
+(when (= 0 (buffer-size (get-buffer *BBDB*)))
+  (delete-window (get-buffer-window *BBDB*))
+  (error No matching BBDB record
+
+(defun org-bbdb-open-new ()
+  (catch 'exit
+;; Exact match on name
+(bbdb-search-name (concat \\` name \\') nil)
+(if ( 0 (buffer-size (get-buffer *BBDB*))) (throw 'exit nil))
+;; Exact match on name
+(bbdb-search-organization (concat \\` name \\') nil)
+(if ( 0 (buffer-size (get-buffer *BBDB*))) (throw 'exit nil))
+;; Partial match on name
+(bbdb-search-name name nil)
+(if ( 0 (buffer-size (get-buffer *BBDB*))) (throw 'exit nil))
+;; Partial match on company
+(bbdb-search-organization name nil)
+(if ( 0 (buffer-size (get-buffer *BBDB*))) (throw 'exit nil))
+;; General match including network address and notes
+(bbdb name nil)
+(when (= 0 (buffer-size (get-buffer *BBDB*)))
+  (delete-window (get-buffer-window *BBDB*))
+  (error No matching BBDB record
 
 (defun org-bbdb-anniv-extract-date (time-str)
   Convert -MM-DD to (month date year).