emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/el-search 1175d21 200/332: Allow `string' and `symbol'


From: Stefan Monnier
Subject: [elpa] externals/el-search 1175d21 200/332: Allow `string' and `symbol' el-search patterns to set match data
Date: Tue, 1 Dec 2020 15:48:44 -0500 (EST)

branch: externals/el-search
commit 1175d21ef8006d037c7a8e5b311ba088becb13c4
Author: Michael Heerdegen <michael_heerdegen@web.de>
Commit: Michael Heerdegen <michael_heerdegen@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.
---
 el-search.el | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/el-search.el b/el-search.el
index 782afa8..6c56c32 100644
--- a/el-search.el
+++ b/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)))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]