]> code.delx.au - gnu-emacs-elpa/blobdiff - packages/el-search/el-search.el
Merge commit '8438ff5e71ca040e7a1e325d608a3f5ea050503f'
[gnu-emacs-elpa] / packages / el-search / el-search.el
index 52e919a9c6dd48ab538ce01d0c374d6bc146b6c0..a1bdd23e2b0b2473f6a6a654cdd537648cccf000 100644 (file)
@@ -389,6 +389,17 @@ of the definitions is limited to \"el-search\"."
   `(setf (alist-get ',name el-search--pcase-macros)
          (lambda ,args ,@body)))
 
+(defun el-search--macroexpand-1 (pattern)
+  "Expand \"el-search\" PATTERN.
+This is like `pcase--macroexpand', but expands only patterns
+defined with `el-search-defpattern' and performs only one
+expansion step.
+
+Return PATTERN if this pattern type was not defined with
+`el-search-defpattern'."
+  (if-let ((expander (alist-get (car-safe pattern) el-search--pcase-macros)))
+      (apply expander (cdr pattern))
+    pattern))
 
 (defmacro el-search--with-additional-pcase-macros (&rest body)
   `(cl-letf ,(mapcar (pcase-lambda (`(,symbol . ,fun))
@@ -590,7 +601,7 @@ matches the list (1 2 3 4 5 6 7 8 9) and binds `x' to (4 5 6)."
           (pred (lambda (,string)
                   (cl-every
                    (lambda (,regexp) (el-search--smart-string-match-p ,regexp ,string))
-                   (list ,@regexps)))))))
+                   ',regexps))))))
 
 (el-search-defpattern symbol (&rest regexps)
   "Matches any symbol whose name is matched by all REGEXPS."