[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/ebdb 498a580 214/350: Allow user transformation of sear
From: |
Eric Abrahamsen |
Subject: |
[elpa] externals/ebdb 498a580 214/350: Allow user transformation of search strings |
Date: |
Mon, 14 Aug 2017 11:46:39 -0400 (EDT) |
branch: externals/ebdb
commit 498a5803d6525f24a40c7bcc95b1debce1e38831
Author: Eric Abrahamsen <address@hidden>
Commit: Eric Abrahamsen <address@hidden>
Allow user transformation of search strings
Addresses #23
* ebdb.el (ebdb-search-transform-functions): New custom option -- a
list of functions used to transform search strings.
(ebdb-search-read): Add an :around method that runs search strings
through the functions in the above method.
---
ebdb.el | 28 ++++++++++++++++++++++++++++
1 file changed, 28 insertions(+)
diff --git a/ebdb.el b/ebdb.el
index a7b69ae..2acd3f8 100644
--- a/ebdb.el
+++ b/ebdb.el
@@ -383,6 +383,24 @@ Lisp Hackers: See also `ebdb-silent-internal'."
:type '(choice (const :tag "Run silently" t)
(const :tag "Disable silent running" nil)))
+(defcustom ebdb-search-transform-functions nil
+ "A list of functions used to transform strings during
+ searching.
+
+Each time the user enters a search search string during
+interactive search, that string will be passed through each of
+the functions in this list, which have a chance to modify the
+string somehow before it is actually matched against field
+values.
+
+Each function should accept a single argument, a string, and
+return the transformed string. If the criteria for any given
+search is not a string, it will not be passed through these
+functions."
+
+ :group 'ebdb
+ :type 'list)
+
(defcustom ebdb-info-file nil
"Location of the ebdb info file, if it's not in the standard place."
:group 'ebdb
@@ -4750,6 +4768,16 @@ values, by default the search is not handed to the name
field itself."
In most cases this is a simple regexp, but field classes can
prompt users for more complex search criteria, if necessary.")
+(cl-defmethod ebdb-search-read :around ((cls (subclass ebdb-field)))
+ "Give the functions in `ebdb-search-transform-functions' a
+chance to transform the search string."
+ (let ((criterion (cl-call-next-method)))
+ (if (and ebdb-search-transform-functions
+ (stringp criterion))
+ (dolist (f ebdb-search-transform-functions criterion)
+ (setq criterion (funcall f criterion)))
+ criterion)))
+
(cl-defmethod ebdb-search-read ((cls (subclass ebdb-field)))
(read-string (format "Search records with %s %smatching regexp: "
(ebdb-field-readable-name cls)
- [elpa] externals/ebdb 05cf7ec 184/350: New ebdb-message-buffer-name subst, (continued)
- [elpa] externals/ebdb 05cf7ec 184/350: New ebdb-message-buffer-name subst, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb ae377c1 199/350: Use ebdb-field-search in notes-type record searches, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 54bb078 200/350: Remove final references to ebdb-print, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 072bb74 205/350: ebdb-parse-i18n must also accept a slots argument, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 79ed878 201/350: Handle formatting to a fake *EBDB* buffer, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 1ae4bbf 206/350: Provide internationalized ebdb-string and ebdb-parse for phones, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 0cb406e 210/350: Expand ebdb-test-save-vars to save ebdb-db-list as well, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 722e2c3 211/350: Mild hack to make pop up windows work well, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 374919e 196/350: Fixes to proper name formatting, part III, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 0ccfc0a 215/350: Write generics for ebdb-db-add/remove-record, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 498a580 214/350: Allow user transformation of search strings,
Eric Abrahamsen <=
- [elpa] externals/ebdb 760fd91 204/350: More informative warning when deleting record fields, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 762f027 219/350: Add Makefile, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 325426e 207/350: Add ebdb-complete.el (#32), Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb ea13778 221/350: Autoload calendar-absolute-from-gregorian, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb af13080 218/350: Support sending text messages via Signal, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 94749fd 224/350: Expand gnus-user-format-function-%s, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb c9f8f33 226/350: Be more when careful migrating timestamps, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb b7a28f3 227/350: Be more forgiving about contents of BBDB file when migrating, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb dd675a6 223/350: Revert changes to pop-up routine., Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 1096c6e 230/350: Search read transform functions needs to work for all methods, Eric Abrahamsen, 2017/08/14