[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/el-search 0808109 161/332: Fix el-search--change-p for
From: |
Stefan Monnier |
Subject: |
[elpa] externals/el-search 0808109 161/332: Fix el-search--change-p for atoms |
Date: |
Tue, 1 Dec 2020 15:48:35 -0500 (EST) |
branch: externals/el-search
commit 0808109fe6950928ee467cf8054db880aa005967
Author: Michael Heerdegen <michael_heerdegen@web.de>
Commit: Michael Heerdegen <michael_heerdegen@web.de>
Fix el-search--change-p for atoms
Factor out predicate `el-search--atomic-p'.
Fix a bug in the implementation of `change': Count any
el-search--atomic-p thing (e.g. a large string spanning multiple
lines) as a change even when not all of its lines have changed.
---
el-search-x.el | 21 +++++++++++++++------
el-search.el | 11 +++++++----
2 files changed, 22 insertions(+), 10 deletions(-)
diff --git a/el-search-x.el b/el-search-x.el
index a03b225..8e96682 100644
--- a/el-search-x.el
+++ b/el-search-x.el
@@ -35,8 +35,8 @@
;;; Code:
(eval-when-compile
- (require 'subr-x)
- (require 'thunk))
+ (require 'subr-x))
+(require 'thunk)
(require 'el-search)
@@ -251,11 +251,20 @@ Use variable `el-search--cached-changes' for caching."
(save-restriction
(widen)
(let ((changes (el-search--changes-from-diff-hl revision))
- (sexp-end (scan-sexps posn 1)))
- (while (and changes (< (cdar changes) sexp-end))
+ (sexp-end (scan-sexps posn 1))
+ (atomic? (thunk-delay (el-search--atomic-p
+ (save-excursion (goto-char posn)
+ (read (current-buffer)))))))
+ (while (and changes (or (< (cdar changes) posn)
+ (and
+ ;; a string spanning multiple lines is a change
even when not all
+ ;; lines are changed
+ (< (cdar changes) sexp-end)
+ (not (thunk-force atomic?)))))
(pop changes))
- (and changes
- (<= (caar changes) posn)))))
+ (and changes (or (<= (caar changes) posn)
+ (and (thunk-force atomic?)
+ (<= (caar changes) sexp-end)))))))
(defun el-search--changed-p (posn &optional revision)
;; Non-nil when sexp after POSN contains a change
diff --git a/el-search.el b/el-search.el
index ace64d1..898c0ba 100644
--- a/el-search.el
+++ b/el-search.el
@@ -989,8 +989,8 @@ non-nil when this file or buffer or defun could contain a
match
for the pattern (NAME . ARGS), and nil when we can be sure that
it doesn't contain a match. \"Atom\" here means anything whose
parts aren't searched by el-searching, like integers or strings,
-but unlike arrays. When in doubt, the heuristic matcher function
-must return non-nil.
+but unlike arrays (see `el-search--atomic-p'). When in doubt,
+the heuristic matcher function must return non-nil.
When el-searching is started with a certain PATTERN, a heuristic
matcher function is constructed by recursively destructuring the
@@ -1090,14 +1090,17 @@ PATTERN and combining the heuristic matchers of the
subpatterns."
el-search--atom-list-cache))
atom-list))))))
+(defun el-search--atomic-p (object)
+ (or (not (sequencep object)) (stringp object) (null object)
+ (char-table-p object) (bool-vector-p object)))
+
(defun el-search--flatten-tree (tree)
(let ((elements ())
(walked-objects ;to avoid infinite recursion for circular TREEs
(make-hash-table :test #'eq))
(gc-cons-percentage 0.8)) ;Why is binding it here more effective than
binding it more top-level?
(cl-labels ((walker (object)
- (if (or (not (sequencep object)) (stringp object)
(null object)
- (char-table-p object) (bool-vector-p object))
+ (if (el-search--atomic-p object)
(push object elements)
(unless (gethash object walked-objects)
(puthash object t walked-objects)
- [elpa] externals/el-search e2f56c7 109/332: Simplify nested backquotes, (continued)
- [elpa] externals/el-search e2f56c7 109/332: Simplify nested backquotes, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search e7dda1b 118/332: Call el-search--wrap-pattern at better places, Stefan Monnier, 2020/12/01
- [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 <=
- [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, 2020/12/01
- [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