branch: externals/ebdb
commit 0904c1441e002828bb2bee9df5204631cad3c6b5
Author: Eric Abrahamsen <[email protected]>
Commit: Eric Abrahamsen <[email protected]>
Split ebdb-org-open into two functions
* ebdb-org.el (ebdb-org-retrieve): New function only parses an Org
link and retrieves the matching records (doesn't display them).
(ebdb-org-open): This function now only calls `ebdb-org-retrieve'
and displays the results.
---
ebdb-org.el | 28 +++++++++++++++-------------
1 file changed, 15 insertions(+), 13 deletions(-)
diff --git a/ebdb-org.el b/ebdb-org.el
index ea7697a..9489196 100644
--- a/ebdb-org.el
+++ b/ebdb-org.el
@@ -3,7 +3,7 @@
;; Copyright (C) 2016-2017 Free Software Foundation, Inc.
;; Author: Eric Abrahamsen <[email protected]>
-;; Keywords:
+;; Keywords:
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
@@ -84,22 +84,24 @@
(defun ebdb-org-open (link)
"Follow a EBDB link."
- (let ((records
- (pcase (split-string link "/" t)
- (`("uuid" ,key) (list (ebdb-gethash key 'uuid)))
- (`(,key) (ebdb-search (ebdb-records) `((ebdb-field-name ,key))))
- (`("mail" ,key) (ebdb-search (ebdb-records) `((ebdb-field-mail
,key))))
- (`("phone" ,key) (ebdb-search (ebdb-records) `((ebdb-field-phone
,key))))
- (`("address" ,key) (ebdb-search (ebdb-records) `((ebdb-field-address
,key))))
- (`("notes" ,key) (ebdb-search (ebdb-records) `((ebdb-field-notes
,key))))
- (`("tags" ,key) (ebdb-search (ebdb-records) `((ebdb-org-field-tags
,key))))
- (`(,(and field (guard (child-of-class-p (intern-soft field)
'ebdb-field))) ,key)
- (ebdb-search (ebdb-records) `((,(intern-soft field) ,key))))
- (`(,other _) (error "Unknown field search prefix: %s" other)))))
+ (let ((records (ebdb-org-retrieve link)))
(if records
(ebdb-display-records records nil nil nil (ebdb-popup-window))
(message "No records found"))))
+(defun ebdb-org-retrieve (link)
+ (pcase (split-string link "/" t)
+ (`("uuid" ,key) (list (ebdb-gethash key 'uuid)))
+ (`(,key) (ebdb-search (ebdb-records) `((ebdb-field-name ,key))))
+ (`("mail" ,key) (ebdb-search (ebdb-records) `((ebdb-field-mail ,key))))
+ (`("phone" ,key) (ebdb-search (ebdb-records) `((ebdb-field-phone ,key))))
+ (`("address" ,key) (ebdb-search (ebdb-records) `((ebdb-field-address
,key))))
+ (`("notes" ,key) (ebdb-search (ebdb-records) `((ebdb-field-notes ,key))))
+ (`("tags" ,key) (ebdb-search (ebdb-records) `((ebdb-org-field-tags ,key))))
+ (`(,(and field (guard (child-of-class-p (intern-soft field) 'ebdb-field)))
,key)
+ (ebdb-search (ebdb-records) `((,(intern-soft field) ,key))))
+ (`(,other _) (error "Unknown field search prefix: %s" other))))
+
(defun ebdb-org-export (path desc format)
"Create the export version of a EBDB link specified by PATH or DESC.
If exporting to either HTML or LaTeX FORMAT the link will be