[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/ebdb a81769c 272/350: Allow custom hash predicates
From: |
Eric Abrahamsen |
Subject: |
[elpa] externals/ebdb a81769c 272/350: Allow custom hash predicates |
Date: |
Mon, 14 Aug 2017 11:46:52 -0400 (EDT) |
branch: externals/ebdb
commit a81769c3bf4a9a78834b02aca72727eceb600fdc
Author: Eric Abrahamsen <address@hidden>
Commit: Eric Abrahamsen <address@hidden>
Allow custom hash predicates
* ebdb.el (ebdb-hash-extra-predicates): New option allowing users to
create their own hash predicates. This allows them to add arbitrary
hash entries to the ebdb-hashtable, and filter hash lookup results
with their own predicates.
(ebdb-hash-p): Check new option.
---
ebdb.el | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/ebdb.el b/ebdb.el
index eee4419..34682c9 100644
--- a/ebdb.el
+++ b/ebdb.el
@@ -4417,6 +4417,21 @@ This strips garbage from the user full NAME string."
;; `ebdb-hash-record' for each record. This function is also called
;; when new records are added to the database.
+(defcustom ebdb-hash-extra-predicates nil
+ "Extra predicates when looking up entries in the EBDB hashtable.
+
+Predicates are used to filter results from the hashtable,
+ensuring that string lookups only return the results they're
+meant to.
+
+This option should be a list of conses, where the car is a
+symbol, and the cdr is a lambda form which accepts the string key
+and a record, and returns t if the key is acceptable for
+returning that record."
+ :group 'ebdb-search
+ :package-version "0.2"
+ :type '(repeat (cons symbol functionp)))
+
(defun ebdb-puthash (key record)
"Associate RECORD with KEY in `ebdb-hashtable'.
KEY must be a string or nil. Empty strings and nil are ignored."
@@ -4472,6 +4487,10 @@ PREDICATE may take the same values as the elements of
`ebdb-completion-list'."
(mapc (lambda (mail) (if (ebdb-string= key mail)
(throw 'ebdb-hash-ok 'mail)))
(ebdb-record-mail-canon record)))
+ (dolist (elt ebdb-hash-extra-predicates)
+ (when (and (memq (car elt) predicate)
+ (funcall (cdr elt) key record))
+ (throw 'ebdb-hash-ok (car elt))))
nil)
(defun ebdb-remhash (key record)
- [elpa] externals/ebdb 96b113d 251/350: New functions for folding/unfolding long vCard lines, (continued)
- [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
- [elpa] externals/ebdb cc83f62 197/350: Add protection around ebdb-record-uuid, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 4f3db7f 195/350: Save match data around ebdb-parse-i18n, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb fcf0702 275/350: Mark EBDB buffers as unmodified after save, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 88f5e12 261/350: Fill out functionality of gnorb messages field, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb a81769c 272/350: Allow custom hash predicates,
Eric Abrahamsen <=
- [elpa] externals/ebdb e80753a 264/350: Change ebdb-record-change-name to accept strings, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb d3e1485 283/350: Reinstate the notice record hook, and move notice-record method, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb d8bc159 290/350: Fairly embarrassing oversight in setting ebdb buffers modified, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb afe5495 279/350: Adjust indentation of multi-line field values, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb bbe407e 257/350: Code tweaks and re-arrangments, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 727eddb 262/350: Change databases' buffer-char slot into actual character, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 5362b12 291/350: require pyim, for chinese-pyim has been renamed to pyim (#45), Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb f62f15f 282/350: Pop up empty *EBDB* buffer for users with no records, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb f3f9f37 292/350: Move, rename and bind ebdb-mail-yank, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 89467fc 258/350: Don't wrap cl-print-object in eval-when-compile, Eric Abrahamsen, 2017/08/14