branch: externals/ebdb
commit c07babf1b3055554722ff8e8dcae9186f9f22f05
Author: Eric Abrahamsen <[email protected]>
Commit: Eric Abrahamsen <[email protected]>
If alt-names search fails, fall back on actual name field search
Relevant to #23
* ebdb.el (ebdb-record-search): Name searches now try the cache first,
but fall back to actual `ebdb-field-search' on the name instances.
This is to allow overrides of `ebdb-field-search' to take effect. It
may slow search down too much.
---
ebdb.el | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/ebdb.el b/ebdb.el
index 18994c7..227f16c 100644
--- a/ebdb.el
+++ b/ebdb.el
@@ -4664,6 +4664,20 @@ values, by default the search is not handed to the name
field itself."
(ebdb-record-alt-names record))
(ebdb-field-search (slot-value record 'name) regexp)))
+(cl-defmethod ebdb-record-search ((record ebdb-record-person)
+ (_type (subclass ebdb-field-name))
+ (regexp string))
+ ;; First pass the search to the more general method, and only really
+ ;; search the names if we don't find anything.
+
+ ;; This is done to allow overrides of `ebdb-field-search' for names
+ ;; to kick in. It makes the exhaustive search slower, though.
+ (or (cl-call-next-method)
+ (cl-some
+ (lambda (name)
+ (ebdb-field-search name regexp))
+ (slot-value record 'aka))))
+
(cl-defmethod ebdb-record-search ((record ebdb-record)
(_type (subclass ebdb-field-notes))
(regexp string))