branch: master commit 7f92a9302ea189c68377aba20ab846c3b6781590 Author: Michael Heerdegen <michael_heerde...@web.de> Commit: Michael Heerdegen <michael_heerde...@web.de>
Allow `string' and `symbol' el-search patterns to set match data The rationale is to allow to use the match data when replacing symbols and strings via `el-search-query-replace'. * packages/el-search/el-search.el (el-search--string-matcher): Use `string-match' instead of `string-match-p. (symbol): Add to documentation an example of using match data with query-replace. --- packages/el-search/el-search.el | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/packages/el-search/el-search.el b/packages/el-search/el-search.el index 782afa8..6c56c32 100644 --- a/packages/el-search/el-search.el +++ b/packages/el-search/el-search.el @@ -7,7 +7,7 @@ ;; Created: 29 Jul 2015 ;; Keywords: lisp ;; Compatibility: GNU Emacs 25 -;; Version: 1.4.0.12 +;; Version: 1.4.0.13 ;; Package-Requires: ((emacs "25") (stream "2.2.4")) @@ -1497,7 +1497,7 @@ argument (that should be a string)." (byte-compile regexp-like)) (byte-compile (let ((string (make-symbol "string"))) - `(lambda (,string) (let ,match-bindings (string-match-p ,regexp ,string)))))))) + `(lambda (,string) (let ,match-bindings (string-match ,regexp ,string)))))))) (el-search-defpattern string (&rest regexps) "Matches any string that is matched by all REGEXPS. @@ -1518,7 +1518,14 @@ Any of the REGEXPS is `el-search-regexp-like-p'." (el-search-defpattern symbol (&rest regexps) "Matches any symbol whose name is matched by all REGEXPS. -Any of the REGEXPS is `el-search-regexp-like-p'." +Any of the REGEXPS is `el-search-regexp-like-p'. + +Example: to replace all symbols with names starting with \"foo-\" +to start with \"bar-\" instead, you would use +`el-search-query-replace' with a rule like this: + + (and (symbol \"\\\\`foo-\\\\(.*\\\\)\") s) > + (intern (concat \"bar-\" (match-string 1 (symbol-name s))))" (declare (heuristic-matcher (lambda (&rest regexps) (let ((matchers (mapcar #'el-search--string-matcher regexps)))