[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/el-search c70b003 164/332: Use stream-x.el
From: |
Stefan Monnier |
Subject: |
[elpa] externals/el-search c70b003 164/332: Use stream-x.el |
Date: |
Tue, 1 Dec 2020 15:48:35 -0500 (EST) |
branch: externals/el-search
commit c70b003f411e502e95b5e0176608f3eb7930d8ad
Author: Michael Heerdegen <michael_heerdegen@web.de>
Commit: Michael Heerdegen <michael_heerdegen@web.de>
Use stream-x.el
---
el-search.el | 63 +++++++-----------------------------------------------------
1 file changed, 7 insertions(+), 56 deletions(-)
diff --git a/el-search.el b/el-search.el
index 837aedf..2c0fd0b 100644
--- a/el-search.el
+++ b/el-search.el
@@ -8,7 +8,7 @@
;; Keywords: lisp
;; Compatibility: GNU Emacs 25
;; Version: 1.3.2
-;; Package-Requires: ((emacs "25") (stream "2.2.3"))
+;; Package-Requires: ((emacs "25") (stream "2.2.4"))
;; This file is not part of GNU Emacs.
@@ -360,6 +360,7 @@
(require 'thingatpt)
(require 'thunk)
(require 'stream)
+(require 'stream-x)
(require 'help-fns) ;el-search--make-docstring
(require 'ring) ;el-search-history
(require 'hideshow) ;folding in *El Occur*
@@ -501,56 +502,6 @@ The non-nil value should be one of the symbols `forward'
and
(`(,(pred (equal args)) . ,result) result)
(_ (cdr (setq cached (cons args (apply function args)))))))))
-;; FIXME: the next two should go to stream.el
-(defun el-search--stream-divide (stream fun)
- "Divide STREAM after the first ELT for that (FUN ELT REST) returns nil.
-The return value is a list of two streams.
-Example:
-
- (mapcar #'seq-into-sequence
- (stream-divide
- (stream (list 1 2 3 5 6 7 9 10 11 23))
- (lambda (this rest) (< (- (stream-first rest) this) 2))))
-==> ((1 2 3)
- (5 6 7 9 10 11 23))"
- (if (stream-empty-p stream)
- (list stream (stream-empty))
- (let ((this (stream-pop stream)))
- (letrec ((take-while
- (lambda () (stream-make
- (cons this
- (if (or (stream-empty-p stream) (not (funcall fun
this stream)))
- nil
- (setq this (stream-pop stream))
- (funcall take-while)))))))
- (let ((first-part (funcall take-while)))
- (list first-part (stream-delay (progn (stream-flush first-part)
stream))))))))
-
-(defun el-search--stream-partition (stream fun)
- "Partition STREAM into bunches where FUN returns true for subsequent
elements.
-The return value is a stream of streams.
-
-Example:
-
- (seq-into-sequence
- (seq-map #'seq-into-sequence
- (stream-partition
- (stream (list 1 2 3 5 6 7 9 10 15 23))
- (lambda (x y) (< (- y x) 2)))))
- ==> ((1 2 3)
- (5 6 7)
- (9 10)
- (15)
- (23))"
- (stream-make
- (if (stream-empty-p stream)
- nil
- (let ((divided (el-search--stream-divide stream
- (lambda (x rest) (and (not
(stream-empty-p rest))
- (funcall fun x
(stream-first rest)))))))
- (cons (car divided)
- (el-search--stream-partition (cadr divided) fun))))))
-
(defun el-search--message-no-log (format-string &rest args)
"Like `message' but with `message-log-max' bound to nil."
(let ((message-log-max nil))
@@ -2191,9 +2142,10 @@ Use the normal search commands to seize the search."
(el-search--get-search-description-string search)))
(condition-case-unless-debug err
(let ((stream-of-matches
- (el-search--stream-partition
+ (stream-partition
(funcall (el-search-object-get-matches search))
- (lambda (this prev) (and (eq (car this) (car prev))
(equal (nth 2 this) (nth 2 prev))))))
+ (lambda (this prev)
+ (and (eq (car this) (car prev)) (equal (nth 2 this)
(nth 2 prev))))))
stream-of-buffer-matches buffer-matches
(matching-files 0) (matching-buffers 0) (overall-matches
0))
(while (setq stream-of-buffer-matches (stream-pop
stream-of-matches))
@@ -2278,10 +2230,9 @@ Use the normal search commands to seize the search."
(setq context-end
(or (scan-sexps cbeg
1) context-end)))))))))
(setq matches
- (car (el-search--stream-divide
+ (car (stream-divide-with-get-rest-fun
buffer-matches+contexts
- (lambda (_ rest)
- (not (eq rest
remaining-buffer-matches-+contexts))))))
+ (lambda (_)
remaining-buffer-matches-+contexts))))
(setq buffer-matches+contexts
remaining-buffer-matches-+contexts))
(cl-flet ((insert-match-and-advance
(match-beg)
- [elpa] externals/el-search 922281a 112/332: Fix replacement verification for splicing mode, (continued)
- [elpa] externals/el-search 922281a 112/332: Fix replacement verification for splicing mode, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search 6de72a5 121/332: `change', `changed': make "HEAD" as default explicit, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search 7fe5fb7 126/332: Some details, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search 2a0773f 134/332: Use jka-compr-load-suffixes instead of hardcoded suffixes, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search 644b04d 139/332: el-search: bump version to 1.2.2, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search b500266 151/332: Tweak el-search--pp-to-string, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search 79095f6 143/332: Improve summary message of `el-search-overview', Stefan Monnier, 2020/12/01
- [elpa] externals/el-search 3772a97 133/332: Add a helpful comment; bump version to 1.2.1, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search 0808109 161/332: Fix el-search--change-p for atoms, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search f028826 163/332: Narrow down the semantics of symbol LPATs, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search c70b003 164/332: Use stream-x.el,
Stefan Monnier <=
- [elpa] externals/el-search a4004b3 167/332: Make `el-search-reset-search' modify its argument, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search 2871f22 178/332: Recover from search head pointing to a killed buffer, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search cf5b5a9 177/332: Display an x/y-style match count in the echo area, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search ca6b9f2 183/332: Add a PROMPT arg to `el-search--read-pattern-for-interactive', Stefan Monnier, 2020/12/01
- [elpa] externals/el-search d2b8f84 184/332: New command `el-search-count-matches', Stefan Monnier, 2020/12/01
- [elpa] externals/el-search 468745a 185/332: Show match count for `el-search-query-replace', Stefan Monnier, 2020/12/01
- [elpa] externals/el-search c80df81 186/332: Fix resuming search in a modified buffer, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search 0b93a25 188/332: * el-search/el-search.el: Minor tweak., Stefan Monnier, 2020/12/01
- [elpa] externals/el-search 145ce47 102/332: Update copyright, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search 24d0638 099/332: Rewrite the `change' and `changed' patterns, Stefan Monnier, 2020/12/01