X-Git-Url: https://code.delx.au/gnu-emacs-elpa/blobdiff_plain/21516b4b7114e8c5dadf4747066e72eb1e9960d6..4c77f20e144dc409e3c59abdb7105fb0db41ee54:/packages/el-search/el-search.el diff --git a/packages/el-search/el-search.el b/packages/el-search/el-search.el index dea74b280..a1bdd23e2 100644 --- a/packages/el-search/el-search.el +++ b/packages/el-search/el-search.el @@ -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." @@ -849,23 +860,25 @@ The following additional pattern types are currently defined:" (not (eq (symbol-value pattern) pattern)))) (error "Please don't forget the quote when searching for a symbol")) (el-search--wrap-pattern pattern))))) - (setq this-command 'el-search-pattern) ;in case we come from isearch - (setq el-search-current-pattern pattern) - (let ((opoint (point))) - (when (and (eq this-command last-command) el-search-success) - (el-search--skip-expression nil t)) - (setq el-search-success nil) - (when (condition-case nil - (el-search--search-pattern pattern) - (end-of-buffer (message "No match") - (goto-char opoint) - (el-search-hl-remove) - (ding) - nil)) - (setq el-search-success t) - (el-search-hl-sexp) - (unless (eq this-command last-command) - (el-search-hl-other-matches pattern))))) + (if (not (called-interactively-p 'any)) + (el-search--search-pattern pattern) + (setq this-command 'el-search-pattern) ;in case we come from isearch + (setq el-search-current-pattern pattern) + (let ((opoint (point))) + (when (and (eq this-command last-command) el-search-success) + (el-search--skip-expression nil t)) + (setq el-search-success nil) + (when (condition-case nil + (el-search--search-pattern pattern) + (end-of-buffer (message "No match") + (goto-char opoint) + (el-search-hl-remove) + (ding) + nil)) + (setq el-search-success t) + (el-search-hl-sexp) + (unless (eq this-command last-command) + (el-search-hl-other-matches pattern)))))) (defvar el-search-search-and-replace-help-string "\