[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] scratch/isearch-character-group-folding 879c072 2/4: (isea
From: |
Artur Malabarba |
Subject: |
[Emacs-diffs] scratch/isearch-character-group-folding 879c072 2/4: (isearch--replace-groups-in-string): New function. |
Date: |
Tue, 27 Jan 2015 16:13:25 +0000 |
branch: scratch/isearch-character-group-folding
commit 879c072016b69f06f945ca6364322bdee23a3c19
Author: Artur Malabarba <address@hidden>
Commit: Artur Malabarba <address@hidden>
(isearch--replace-groups-in-string): New function.
Return a regexp, replacing each character in STRING as given by
`isearch-groups-alist'.
---
lisp/isearch.el | 13 +++++++++++++
1 files changed, 13 insertions(+), 0 deletions(-)
diff --git a/lisp/isearch.el b/lisp/isearch.el
index 86850db..b6bd876 100644
--- a/lisp/isearch.el
+++ b/lisp/isearch.el
@@ -58,6 +58,7 @@
;;; Code:
(eval-when-compile (require 'cl-lib))
+(eval-when-compile (require 'subr-x))
;; Some additional options and constants.
@@ -2582,6 +2583,18 @@ search for the first occurrence of STRING or its
translation.")
Can be changed via `isearch-search-fun-function' for special needs."
(funcall (or isearch-search-fun-function 'isearch-search-fun-default)))
+(defun isearch--replace-groups-in-string (string)
+ "Return a group-folded regexp version of STRING.
+Any character that has an entry in `isearch-groups-alist' is
+replaced with the cdr of that entry (which should be a regexp).
+Other characters are `regexp-quote'd."
+ (apply #'concat
+ (mapcar (lambda (c)
+ (if-let ((entry (assq c isearch-groups-alist)))
+ (cdr entry)
+ (regexp-quote (string c))))
+ string)))
+
(defun isearch-search-fun-default ()
"Return default functions to use for the search."
(cond