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

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

[elpa] externals/el-search 7fe5fb7 126/332: Some details


From: Stefan Monnier
Subject: [elpa] externals/el-search 7fe5fb7 126/332: Some details
Date: Tue, 1 Dec 2020 15:48:27 -0500 (EST)

branch: externals/el-search
commit 7fe5fb7b060f4e4cf40746d6d371fd89f55fb5b2
Author: Michael Heerdegen <michael_heerdegen@web.de>
Commit: Michael Heerdegen <michael_heerdegen@web.de>

    Some details
---
 el-search-x.el |  4 ++--
 el-search.el   | 28 +++++++++++++++++++---------
 2 files changed, 21 insertions(+), 11 deletions(-)

diff --git a/el-search-x.el b/el-search-x.el
index d5ff11b..ddd015c 100644
--- a/el-search-x.el
+++ b/el-search-x.el
@@ -246,7 +246,7 @@ Use variable `el-search--cached-changes' for caching."
 
 Requires library \"diff-hl\".  REVISION defaults to the file's
 repository's HEAD commit and is a git revision string.  Customize
-`el-search-change-revision-transformer-function' to modify how
+`el-search-change-revision-transformer-function' to control how
 REVISION is interpreted."
   `(guard (el-search--change-p (point) ,(or revision "HEAD"))))
 
@@ -255,7 +255,7 @@ REVISION is interpreted."
 
 Requires library \"diff-hl\".  REVISION defaults to the file's
 repository's HEAD commit and is a git revision string.  Customize
-`el-search-change-revision-transformer-function' to modify how
+`el-search-change-revision-transformer-function' to control how
 REVISION is interpreted."
   `(guard (el-search--changed-p (point) ,(or revision "HEAD"))))
 
diff --git a/el-search.el b/el-search.el
index 9c0a6b8..a823e0a 100644
--- a/el-search.el
+++ b/el-search.el
@@ -226,7 +226,11 @@
 ;;  (el-search-all-matches (el-search-make-search pattern stream))
 ;;
 ;; where PATTERN is the search pattern and STREAM is a stream of
-;; buffers or files.  For example,
+;; buffers or files (typical ways to construct such a STREAM are to
+;; call the `stream' function on a list of buffers, or to use
+;; `el-search-stream-of-directory-files').
+;;
+;; For example,
 ;;
 ;;   (el-search-all-matches
 ;;    (el-search-make-search
@@ -685,10 +689,12 @@ Keys are pattern names (i.e. symbols), and values the 
associated
 heuristical matcher functions.")
 
 (defmacro el-search-defpattern (name args &rest body)
-  "Like `pcase-defmacro', but limited to el-search patterns.
+  "Like `pcase-defmacro', but for defining el-search patterns.
+
 The semantics is exactly that of `pcase-defmacro', but the scope
 of the definitions is limited to \"el-search\", using a separate
-name space.
+name space.  The expansion is allowed to use any defined `pcase'
+pattern as well as any defined el-search pattern.
 
 The docstring may be followed by a `defun' style declaration list
 DECL.  There is only one respected specification, it has the form
@@ -718,16 +724,19 @@ match.
 
 \(fn NAME ARGLIST &optional DOCSTRING DECL &rest BODY)"
   (declare (indent 2) (debug defun))
-  (let ((set-heuristical-matcher ()))
-    (pcase body
-      (`(,(and (pred stringp) doc) (declare (heuristical-matcher 
,heuristical-matcher)) . ,real-body)
+  (let ((doc nil) (set-heuristical-matcher ()))
+    (when (stringp (car body))
+      (setq doc       (car body)
+            body (cdr body)))
+    (pcase (car body)
+      (`(declare (heuristical-matcher ,heuristical-matcher))
        (setq set-heuristical-matcher
              `((setf (alist-get ',name el-search--heuristical-matchers) 
,heuristical-matcher)))
-       (setq body (cons doc real-body))))
+       (setq body (cdr body))))
     `(progn
        ,@set-heuristical-matcher
        (setf (alist-get ',name el-search--pcase-macros)
-             (lambda ,args ,@body)))))
+             (lambda ,args ,doc ,@body)))))
 
 (defmacro el-search--with-additional-pcase-macros (&rest body)
   `(cl-letf ,(mapcar (pcase-lambda (`(,symbol . ,fun)) `((get ',symbol 
'pcase-macroexpander) #',fun))
@@ -1431,7 +1440,8 @@ continued."
           (setf (el-search-head-position head) (copy-marker (point))))
          ((and current-search-buffer (buffer-live-p current-search-buffer))
           (error "Please resume from buffer %s" (buffer-name 
current-search-buffer)))
-         (t (error "Invalid search head: buffer killed")))))
+         (current-search-buffer
+          (error "Invalid search head: buffer killed")))))
     (unwind-protect
         (let ((stream-of-matches (el-search-object-matches 
el-search--current-search)))
           (if (not (stream-empty-p stream-of-matches))



reply via email to

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