emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [PATCH] integration with bbdb 3.0
@ 2011-12-28 19:06 Ivan Kanis
  2011-12-31  8:13 ` Carsten Dominik
  2011-12-31 16:04 ` Carsten Dominik
  0 siblings, 2 replies; 5+ messages in thread
From: Ivan Kanis @ 2011-12-28 19:06 UTC (permalink / raw)
  To: Bastien Guerry; +Cc: org mode, bbdb mailing list

[-- Attachment #1: Type: text/plain, Size: 134 bytes --]

Hi Bastien,

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

Take care,

Ivan Kanis


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: org-bbdb.patch --]
[-- Type: text/x-diff, Size: 3903 bytes --]

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 YYYY-MM-DD to (month date year).

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] integration with bbdb 3.0
  2011-12-28 19:06 [PATCH] integration with bbdb 3.0 Ivan Kanis
@ 2011-12-31  8:13 ` Carsten Dominik
  2011-12-31 15:11   ` Ivan Kanis
  2011-12-31 16:04 ` Carsten Dominik
  1 sibling, 1 reply; 5+ messages in thread
From: Carsten Dominik @ 2011-12-31  8:13 UTC (permalink / raw)
  To: Ivan Kanis; +Cc: Bastien Guerry, org mode, bbdb mailing list


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>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] integration with bbdb 3.0
  2011-12-31  8:13 ` Carsten Dominik
@ 2011-12-31 15:11   ` Ivan Kanis
  2011-12-31 16:14     ` Bastien
  0 siblings, 1 reply; 5+ messages in thread
From: Ivan Kanis @ 2011-12-31 15:11 UTC (permalink / raw)
  To: Carsten Dominik; +Cc: Bastien Guerry, org mode, bbdb mailing list

Carsten Dominik <carsten.dominik@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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] integration with bbdb 3.0
  2011-12-28 19:06 [PATCH] integration with bbdb 3.0 Ivan Kanis
  2011-12-31  8:13 ` Carsten Dominik
@ 2011-12-31 16:04 ` Carsten Dominik
  1 sibling, 0 replies; 5+ messages in thread
From: Carsten Dominik @ 2011-12-31 16:04 UTC (permalink / raw)
  To: Ivan Kanis; +Cc: Bastien Guerry, org mode, bbdb mailing list

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>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] integration with bbdb 3.0
  2011-12-31 15:11   ` Ivan Kanis
@ 2011-12-31 16:14     ` Bastien
  0 siblings, 0 replies; 5+ messages in thread
From: Bastien @ 2011-12-31 16:14 UTC (permalink / raw)
  To: Ivan Kanis; +Cc: org mode, bbdb mailing list, Carsten Dominik

Hi Ivan,

Ivan Kanis <ivan.kanis@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

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2011-12-31 16:13 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-12-28 19:06 [PATCH] integration with bbdb 3.0 Ivan Kanis
2011-12-31  8:13 ` Carsten Dominik
2011-12-31 15:11   ` Ivan Kanis
2011-12-31 16:14     ` Bastien
2011-12-31 16:04 ` Carsten Dominik

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).