[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/ebdb ef673e2 094/350: Improve organization searching
From: |
Eric Abrahamsen |
Subject: |
[elpa] externals/ebdb ef673e2 094/350: Improve organization searching |
Date: |
Mon, 14 Aug 2017 11:46:14 -0400 (EDT) |
branch: externals/ebdb
commit ef673e227216a7efcf8640993040a8b095a02f3b
Author: Eric Abrahamsen <address@hidden>
Commit: Eric Abrahamsen <address@hidden>
Improve organization searching
* ebdb.el (ebdb-record-search): New methods that specialize on the
'organization symbol. Implement for person and organization records.
While we're at it, add a record-search implementation for
organizations and mails -- it should also check the domain slot.
* ebdb-com.el (ebdb-search-organization): Alter this accordingly.
---
ebdb-com.el | 6 ++++--
ebdb.el | 35 ++++++++++++++++++++++++-----------
2 files changed, 28 insertions(+), 13 deletions(-)
diff --git a/ebdb-com.el b/ebdb-com.el
index bea3a7a..14b1df2 100644
--- a/ebdb-com.el
+++ b/ebdb-com.el
@@ -1954,8 +1954,10 @@ in either the name(s), organization, address, phone,
mail, or xfields."
"Display all records in the EBDB matching REGEXP in the organization field."
(interactive (list (ebdb-search-read "organization")
(ebdb-formatter-prefix)))
(ebdb-display-records
- (ebdb-search (ebdb-records 'ebdb-record-organization t)
- regexp)
+ (seq-filter
+ (lambda (r)
+ (ebdb-record-search r 'organization regexp))
+ (ebdb-records))
fmt))
;;;###autoload
diff --git a/ebdb.el b/ebdb.el
index 89b3dae..ce8d723 100644
--- a/ebdb.el
+++ b/ebdb.el
@@ -2420,6 +2420,14 @@ Currently only works for mail fields."
"Return a list of organization string names from RECORD's cache."
(slot-value (ebdb-record-cache record) 'organizations))
+(cl-defmethod ebdb-record-search ((record ebdb-record-person)
+ (_type (eql organization))
+ (regex string))
+ (or (seq-find (lambda (org)
+ (string-match-p regex org))
+ (ebdb-record-organizations record))
+ (string-match-p regex "")))
+
;;; This needs some more thought.
;; (cl-defmethod ebdb-mail-set-priority ((mail ebdb-field-mail)
;; (record ebdb-record-person)
@@ -2572,7 +2580,21 @@ Currently only works for mail fields."
(cl-defmethod ebdb-record-search ((record ebdb-record-organization)
(_type (eql name))
(regex string))
- (string-match-p regex (ebdb-string (slot-value record 'name))))
+ (string-match-p regex (ebdb-record-name record)))
+
+(cl-defmethod ebdb-record-search ((record ebdb-record-organization)
+ (_type (eql organization))
+ (regex string))
+ (or (string-match-p regex (ebdb-record-name record))
+ (and (slot-value record 'domain)
+ (string-match-p regex (ebdb-string (slot-value record 'domain))))))
+
+(cl-defmethod ebdb-record-search ((record ebdb-record-organization)
+ (_type (eql mail))
+ (regexp string))
+ (let ((domain (slot-value record 'domain)))
+ (or (and domain (string-match-p regexp (ebdb-string domain)))
+ (cl-call-next-method))))
(cl-defmethod ebdb-record-insert-field :after ((org ebdb-record-organization)
_slot
@@ -4619,16 +4641,7 @@ but not allowing for regexps."
(when name-re
(push `(ebdb-record-search record 'name ,name-re) clauses))
(when org-re
- (push `(let ((organizations (when (slot-exists-p record 'organizations)
- (slot-value record 'organizations)))
- org done)
- (if organizations
- (while (and (setq org (pop organizations)) (not done))
- (setq done (string-match ,org-re (ebdb-string org))))
- ;; so that "^$" can be used to find records that
- ;; have no organization
- (setq done (string-match ,org-re "")))
- done)
+ (push `(ebdb-record-search record 'organization ,org-re)
clauses))
(when phone-re
- [elpa] externals/ebdb f0b0a32 093/350: Fix organization name matching in migration, (continued)
- [elpa] externals/ebdb f0b0a32 093/350: Fix organization name matching in migration, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 1fe77aa 152/350: Tiny tweak to snarfing, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 189314d 151/350: Fix up Org link following, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 52d3d54 113/350: Remove all pop-up-window-size type options, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 4cd4a0c 123/350: Simplify searching, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 5b24d54 126/350: Special-case mail symbol in ebdb-record-field, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 5613bc2 137/350: Fix bug in ebdb-record-field-slot-query, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 86b386d 141/350: Compiler-inspired fixes, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 05f67d6 081/350: Fix merging procedure, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 1ded570 086/350: Note new database-related commands in manual, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb ef673e2 094/350: Improve organization searching,
Eric Abrahamsen <=
- [elpa] externals/ebdb bc71bda 099/350: Many fixes to migration routine, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 548e05d 106/350: Tweaks to MUA interactive commands, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb dd83c7e 115/350: Short-circuit ebdb-info, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb a0eada8 128/350: Change some of the EBDB buffer formatting defaults, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 20906ae 131/350: ebdb-prompt-for-record should load if necessary, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 1bc78ab 133/350: Add helm-ebdb file, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb ed3e270 119/350: Reverse order of args in return value of ebdb-popup-window, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb ed6e228 136/350: Make ebdb-annotate-message more class agnostic, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb aa2d973 147/350: Allow optional records argument to ebdb-initialize, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 42f6dce 130/350: Add "Hacking EBDB" section to manual, Eric Abrahamsen, 2017/08/14