Howdy!

When inserting BBDB (Big Brother’s Insidious Database) links into Org
documents, one has to manually fill in the link description, typically
the full name.  With the attached patch, Org suggests the full name by
default, which makes inserting BBDB links lighting fast, at last.

Rudy
>From 3c2917096f14da004ba8eb8a77013b9119e7e352 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Rudolf=20Adamkovi=C4=8D?= <[email protected]>
Date: Mon, 10 Nov 2025 21:18:43 +0100
Subject: [PATCH] ol-bbdb: Pre-populate the description for BBDB links

* etc/ORG-NEWS (Add completion for ID links): Announce the feature in
the Miscellaneous section.
* lisp/ol-bbdb.el ("bbdb"): Plug the new `org-bbdb-describe-link'
function into the Org Link machinery.
(org-bbdb-complete-link): Re-capitalize "BBDB" per the Boy Scout Rule.
(org-bbdb-describe-link): Add a function that computes the default
description for BBDB links.
* testing/lisp/test-ol-bbdb.el (test-org-bbdb-describe-link): Test the
newly added function.
---
 etc/ORG-NEWS                 | 5 +++++
 lisp/ol-bbdb.el              | 9 ++++++++-
 testing/lisp/test-ol-bbdb.el | 7 +++++++
 3 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index 3cfc2b011..9113e68ea 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -818,6 +818,11 @@ known to contain headlines with IDs.  You can use new option
 ~org-id-completion-targets~ to change where the candidates are
 searched.
 
+*** Pre-populate the description for BBDB links
+
+When inserting BBDB links, use the full name as the default link
+description, instead of nothing.
+
 * Version 9.7
 
 ** Important announcements and breaking changes
diff --git a/lisp/ol-bbdb.el b/lisp/ol-bbdb.el
index b01c6d701..30fef2be3 100644
--- a/lisp/ol-bbdb.el
+++ b/lisp/ol-bbdb.el
@@ -221,6 +221,7 @@ (org-link-set-parameters "bbdb"
 			 :follow #'org-bbdb-open
 			 :export #'org-bbdb-export
 			 :complete #'org-bbdb-complete-link
+                         :insert-description #'org-bbdb-describe-link
 			 :store #'org-bbdb-store-link)
 
 ;;; Implementation
@@ -498,7 +499,7 @@ (defun org-bbdb-anniversaries-future (&optional n)
 	      dates)))))
 
 (defun org-bbdb-complete-link ()
-  "Read a bbdb link with name completion."
+  "Read a BBDB link with name completion."
   (org-require-package 'bbdb-com "bbdb")
   (let ((rec (bbdb-completing-read-record "Name: ")))
     (concat "bbdb:"
@@ -506,6 +507,12 @@ (defun org-bbdb-complete-link ()
 				  (car rec)
 				rec)))))
 
+(defun org-bbdb-describe-link (link desc)
+  "Return a description for a BBDB link."
+  (or (org-string-nw-p desc)
+      (if (string-prefix-p "bbdb:" link)
+          (string-remove-prefix "bbdb:" link))))
+
 (defun org-bbdb-anniv-export-ical ()
   "Extract anniversaries from BBDB and convert them to icalendar format."
   (org-require-package 'bbdb)
diff --git a/testing/lisp/test-ol-bbdb.el b/testing/lisp/test-ol-bbdb.el
index 25f6c22e0..5a7c50d32 100644
--- a/testing/lisp/test-ol-bbdb.el
+++ b/testing/lisp/test-ol-bbdb.el
@@ -31,6 +31,13 @@ (ert-deftest test-org-bbdb-anniv-extract-date ()
   (should (equal '(9 22 2018) (org-bbdb-anniv-extract-date "2018-09-22")))
   (should (equal '(9 22 nil) (org-bbdb-anniv-extract-date "09-22"))))
 
+(ert-deftest test-org-bbdb-describe-link ()
+  (should (equal (org-bbdb-describe-link "bbdb:Richard Stallman" "RMS")
+                 "RMS"))
+  (should (equal (org-bbdb-describe-link "bbdb:Richard Stallman" "")
+                 "Richard Stallman"))
+  (should-not (org-bbdb-describe-link "https://example.com"; "")))
+
 (provide 'test-ol-bbdb)
 
 ;;; test-org-bbdb.el ends here
-- 
2.39.5 (Apple Git-154)

-- 
"Programming reliably -- must be an activity of an undeniably
mathematical nature […] You see, mathematics is about thinking, and
doing mathematics is always trying to think as well as possible."

--- Edsger W. Dijkstra, 1981

Rudolf Adamkovič <[email protected]> [he/him]
http://adamkovic.org

Reply via email to