[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/ebdb 4ce353e 237/350: Migrate more search routines to t
From: |
Eric Abrahamsen |
Subject: |
[elpa] externals/ebdb 4ce353e 237/350: Migrate more search routines to the ebdb-search-display thing |
Date: |
Mon, 14 Aug 2017 11:46:45 -0400 (EDT) |
branch: externals/ebdb
commit 4ce353e78468adfbdcec7ffd522844ecd3666825
Author: Eric Abrahamsen <address@hidden>
Commit: Eric Abrahamsen <address@hidden>
Migrate more search routines to the ebdb-search-display thing
* ebdb-com.el (ebdb-search-database, ebdb-search-record-class,
ebdb-search-modified): These three commands now use the internal
searching routine. Also, rename `ebdb-search-changed' to
`ebdb-search-modified'.
* ebdb.el (ebdb-record-search): New symbol-keyed methods for searching
using the above commands.
These search options are now actually *less* efficient than they were
before, but this allows you to use them with the filter/append
prefixes.
---
ebdb-com.el | 46 +++++++++++++++++++++++-----------------------
ebdb.el | 33 +++++++++++++++++++++++++--------
2 files changed, 48 insertions(+), 31 deletions(-)
diff --git a/ebdb-com.el b/ebdb-com.el
index 8b93b76..abbf05b 100644
--- a/ebdb-com.el
+++ b/ebdb-com.el
@@ -317,10 +317,16 @@ display information."
(define-key km (kbd "/ x") 'ebdb-search-user-fields)
(define-key km (kbd "| x") 'ebdb-search-user-fields)
(define-key km (kbd "+ x") 'ebdb-search-user-fields)
- (define-key km (kbd "/ c") 'ebdb-search-changed)
+ (define-key km (kbd "/ c") 'ebdb-search-modified)
+ (define-key km (kbd "| c") 'ebdb-search-modified)
+ (define-key km (kbd "+ c") 'ebdb-search-modified)
(define-key km (kbd "/ C") 'ebdb-search-record-class)
- (define-key km (kbd "/ d") 'ebdb-search-duplicates)
+ (define-key km (kbd "/ C") 'ebdb-search-record-class)
+ (define-key km (kbd "| C") 'ebdb-search-record-class)
+ (define-key km (kbd "+ d") 'ebdb-search-duplicates)
(define-key km (kbd "/ D") 'ebdb-search-database)
+ (define-key km (kbd "| D") 'ebdb-search-database)
+ (define-key km (kbd "+ D") 'ebdb-search-database)
(define-key km (kbd "C-x n w") 'ebdb-display-all-records)
(define-key km (kbd "C-x n d") 'ebdb-display-current-record)
(define-key km (kbd "^") 'ebdb-search-pop)
@@ -928,7 +934,7 @@ displayed records."
["Search address" ebdb-search-address t]
["Search mail" ebdb-search-mail t]
["Search user fields" ebdb-search-user-fields t]
- ["Search changed records" ebdb-search-changed t]
+ ["Search modified records" ebdb-search-modified t]
["Search duplicates" ebdb-search-duplicates t]
"--"
["Old time stamps" ebdb-timestamp-older t]
@@ -1989,19 +1995,11 @@ in any field."
fmt))
;;;###autoload
-(defun ebdb-search-changed (&optional fmt)
- ;; FIXME: "changes" in EBDB lingo are often called "modifications"
- ;; in Emacs lingo
- "Display records which have been changed since EBDB was last saved."
- (interactive (list (ebdb-formatter-prefix)))
- (let ((dirty (ebdb-dirty-records)))
- (if (ebdb-search-invert-p)
- (let (unchanged-records)
- (dolist (record (ebdb-records))
- (unless (memq record dirty)
- (push record unchanged-records)))
- (ebdb-display-records unchanged-records fmt))
- (ebdb-display-records dirty fmt))))
+(defun ebdb-search-modified (style &optional fmt)
+ "Display records with unsaved modifications."
+ (interactive (list (ebdb-search-style)
+ (ebdb-formatter-prefix)))
+ (ebdb-search-display style `((dirty t)) fmt))
;;;###autoload
(defun ebdb-search-duplicates (&optional fields fmt)
@@ -2053,20 +2051,22 @@ The search results are displayed in the EBDB buffer."
fmt)))
;;;###autoload
-(defun ebdb-search-database (db &optional fmt)
+(defun ebdb-search-database (style db &optional fmt)
"Select a database and show all records from that database."
(interactive
- (list (ebdb-prompt-for-db)
+ (list (ebdb-search-style)
+ (ebdb-prompt-for-db)
(ebdb-formatter-prefix)))
- (ebdb-display-records (slot-value db 'records) fmt))
+ (ebdb-search-display style `((database ,db)) fmt))
;;;###autoload
-(defun ebdb-search-record-class (class &optional fmt)
+(defun ebdb-search-record-class (style class &optional fmt)
"Prompt for a record class and display all records of that class."
- (interactive (list (eieio-read-subclass "Use which record class? "
'ebdb-record nil t)
+ (interactive (list (ebdb-search-style)
+ (eieio-read-subclass
+ "Use which record class? " 'ebdb-record nil t)
(ebdb-formatter-prefix)))
- (let ((recs (ebdb-records class t)))
- (ebdb-display-records recs fmt)))
+ (ebdb-search-display style `((record-class ,class)) fmt))
;;;###autoload
(defun ebdb-search-single-record (record &optional fmt)
diff --git a/ebdb.el b/ebdb.el
index 9ba3cdd..3324b92 100644
--- a/ebdb.el
+++ b/ebdb.el
@@ -2423,14 +2423,6 @@ priority."
"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)
@@ -4995,6 +4987,31 @@ values, by default the search is not handed to the name
field itself."
(ebdb-field-search f criterion))
(throw 'found t)))))
+(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 "")))
+
+(cl-defmethod ebdb-record-search ((record ebdb-record)
+ (_type (eql dirty))
+ _criterion)
+ (slot-value record 'dirty))
+
+(cl-defmethod ebdb-record-search ((record ebdb-record)
+ (_type (eql database))
+ (db ebdb-db))
+ (member (slot-value (ebdb-record-cache record) 'database)
+ db))
+
+(cl-defmethod ebdb-record-search ((record ebdb-record)
+ (_type (eql record-class))
+ (class symbol))
+ (object-of-class-p record class))
+
+
(cl-defgeneric ebdb-search-read (field-class)
"Prompt the user for a search string to match against instances
of FIELD-CLASS.
- [elpa] externals/ebdb 3106b45 256/350: Require ebdb-format in ebdb-vcard, (continued)
- [elpa] externals/ebdb 3106b45 256/350: Require ebdb-format in ebdb-vcard, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 7549366 259/350: New method: ebdb-db-load-records, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb b37356a 270/350: Fix docstring of ebdb-create-record, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 5135645 260/350: Split out ebdb-notice-record and ebdb-notice-field methods, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 71a93f5 268/350: Put a load protection in ebdb-mua-update-records, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb cacb97b 271/350: Fix bug in MUA record creation, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb e5bdee2 278/350: Rework ebdb-mail-yank, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 8dd1600 273/350: Change type of anniversary field dates, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 57b2514 276/350: Use ebdb-with-record-edits in more places, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb f44a797 286/350: New function ebdb-mua-in-ebdb-buffer, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 4ce353e 237/350: Migrate more search routines to the ebdb-search-display thing,
Eric Abrahamsen <=
- [elpa] externals/ebdb 7040cad 247/350: Expand ebdb-helm to complete on mails as well, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb a6bc423 249/350: Remove unused customization groups, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 4ded53d 250/350: All vCard lines should be delimited with CRLF, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb a776d37 248/350: Don't use copy-sequence plus add-text-properties on strings, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 96b113d 251/350: New functions for folding/unfolding long vCard lines, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb b52cdc0 265/350: Record-insert|delete-field methods can find their own slots, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb fcee6ab 267/350: Protect against no current record when redisplaying, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb f3b9525 269/350: Temporarily abandon having record-change-name accept strings, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 1a31515 274/350: Fixes to record loading, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 01262e3 277/350: Mark EBDB buffers as modified after edits, Eric Abrahamsen, 2017/08/14