[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/el-search cf68daf 249/332: [el-search] Avoid most calls
From: |
Stefan Monnier |
Subject: |
[elpa] externals/el-search cf68daf 249/332: [el-search] Avoid most calls to 'scan-sexps' |
Date: |
Tue, 1 Dec 2020 15:48:56 -0500 (EST) |
branch: externals/el-search
commit cf68dafe980d6b384583612334d83a93868406f1
Author: Michael Heerdegen <michael_heerdegen@web.de>
Commit: Michael Heerdegen <michael_heerdegen@web.de>
[el-search] Avoid most calls to 'scan-sexps'
Replace 'scan-sexps' with 'el-search--end-of-sexp' where possible. We
do this because 'scan-sexps' currently has a bug - bug#24542 "The
symbol `@' and sexp scanning" - which we try to avoid.
* packages/el-search/el-search.el (el-search--end-of-sexp): Implement
an optional POS argument.
Replace all calls of 'scan-sexps' with a COUNT argument 1 with
according 'el-search--end-of-sexp' calls.
(el-search--search-backward-1): Correct a variable name.
* packages/el-search/el-search-x.el: Also replace 'scan-sexps' calls.
---
el-search-x.el | 4 ++--
el-search.el | 35 ++++++++++++++++++++---------------
2 files changed, 22 insertions(+), 17 deletions(-)
diff --git a/el-search-x.el b/el-search-x.el
index 1aeff7b..0af955c 100644
--- a/el-search-x.el
+++ b/el-search-x.el
@@ -292,7 +292,7 @@ Uses 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))
+ (sexp-end (el-search--end-of-sexp posn))
(atomic? (thunk-delay (el-search--atomic-p
(save-excursion (goto-char posn)
(el-search-read
(current-buffer)))))))
@@ -317,7 +317,7 @@ Uses variable `el-search--cached-changes' for caching."
(while (and changes (<= (cdar changes) posn))
(pop changes))
(and changes
- (< (caar changes) (scan-sexps posn 1))))))
+ (< (caar changes) (el-search--end-of-sexp posn))))))
(defun el-search-change--heuristic-matcher (&optional revision)
(let* ((revision (or revision "HEAD"))
diff --git a/el-search.el b/el-search.el
index 899272b..249ba8b 100644
--- a/el-search.el
+++ b/el-search.el
@@ -639,7 +639,7 @@ nil."
(top-level-paren-start pos)
;; Iff at the beginning top-level paren group, this
succeeds and returns point
(and (not (eobp)) (top-level-paren-start (1+ pos)))))
- (cons defun-beg (scan-sexps defun-beg 1))
+ (cons defun-beg (el-search--end-of-sexp defun-beg))
;; This corner case (not inside any s-exp or current top level s-exp
;; not a list) is a bit hairy to do with syntax stuff, so let's just
;; use el-search:
@@ -784,14 +784,19 @@ PROMPT defaults to \"El-search pattern: \". The return
value is the
pattern))
-(defun el-search--end-of-sexp ()
+(defun el-search--end-of-sexp (&optional pos)
"Return the value of point at the end of this sexp.
-Point should be at a sexp beginning."
- (if (eql (char-after) ?@) ;bug#24542
- (save-excursion
- (ignore (el-search-read (current-buffer)))
- (point))
- (or (scan-sexps (point) 1) (point-max))))
+Point should be at a sexp beginning.
+
+With POS, a sexp-beginning position, return value of point at the end
+of this sexp."
+ (save-excursion
+ (when pos (goto-char pos))
+ (if (eql (char-after) ?@) ;bug#24542 "The symbol `@' and sexp scanning"
+ (progn
+ (ignore (el-search-read (current-buffer)))
+ (point))
+ (or (scan-sexps (point) 1) (point-max)))))
(defun el-search--skip-expression (expression &optional read)
;; Move forward at least one character. Don't move into a string or
@@ -1053,7 +1058,7 @@ be specified as fourth argument, and COUNT becomes the
fifth argument."
((el-search--match-p matcher current-expr)
(setq match-beg
(and (or (not bound)
- (<= (scan-sexps match-beg 1) bound)
+ (<= (el-search--end-of-sexp match-beg)
bound)
;; don't fail for >: a subsequent match
may end before BOUND
)
(point))))
@@ -2574,7 +2579,7 @@ This function is the counterpart of
`el-search--search-pattern-1'."
;; Search for the hindmost match starting before
CURRENT-UPPER-LIMIT
(let ((done nil))
(goto-char current-defun-start)
- (setq current-defun-end (scan-sexps defun-start 1))
+ (setq current-defun-end (el-search--end-of-sexp
current-defun-start))
(when (and bound (< current-defun-end bound))
(setq done t
outer-loop-done t
@@ -2920,13 +2925,13 @@ Prompt for a new pattern and revert."
context-beg))))
(cons (or context-beg match-beg)
(if context-beg (scan-lists context-beg 1 0)
- (scan-sexps match-beg 1)))))
+ (el-search--end-of-sexp match-beg)))))
(defun el-search-occur-get-defun-context (match-beg)
(el-search--bounds-of-defun match-beg))
(defun el-search-occur-get-null-context (match-beg)
- (cons match-beg (scan-sexps match-beg 1)))
+ (cons match-beg (el-search--end-of-sexp match-beg)))
(defvar el-search-get-occur-context-function #'el-search-occur-get-some-context
"Function determining amount of context shown in *El Occur* buffers.")
@@ -3019,7 +3024,7 @@ Prompt for a new pattern and revert."
(when (< cbeg context-beg)
(setq context-beg cbeg)
(setq context-end
- (or (scan-sexps cbeg
1) context-end)))))))))
+ (or
(el-search--end-of-sexp cbeg) context-end)))))))))
(setq matches
(car (stream-divide-with-get-rest-fun
buffer-matches+contexts
@@ -3032,7 +3037,7 @@ Prompt for a new pattern and revert."
(with-current-buffer buffer
(buffer-substring-no-properties
(goto-char match-beg)
- (goto-char (scan-sexps
(point) 1))))
+ (goto-char
(el-search--end-of-sexp))))
'match-data `(,buffer
,match-beg ,file)))
(let ((ov (make-overlay
insertion-point (point) nil t)))
(overlay-put ov 'face
'el-search-match)
@@ -3057,7 +3062,7 @@ Prompt for a new pattern and revert."
(insert
(with-current-buffer buffer
(buffer-substring-no-properties
- (point) (scan-sexps context-beg 1))))))
+ (point) (el-search--end-of-sexp
context-beg))))))
(let ((inhibit-message t) (message-log-max nil))
(indent-region insertion-point (point))
- [elpa] externals/el-search 365f93f 197/332: * el-search/el-search.el: Some buffer display related minor tweaks, (continued)
- [elpa] externals/el-search 365f93f 197/332: * el-search/el-search.el: Some buffer display related minor tweaks, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search c69dd52 205/332: * el-search/el-search.el: Some minor tweaks, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search c41288f 208/332: Make el-search key binding installation more flexible, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search 8d20f8a 217/332: Add face `el-search-highlight-in-prompt-face', Stefan Monnier, 2020/12/01
- [elpa] externals/el-search 75f94f9 218/332: Improve quit/error handling in el-search-query-replace, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search b278fb7 219/332: Update a variable when splicing mode is toggled, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search 8175417 237/332: * el-search/el-search.el: More minor tweaks, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search 1f81442 241/332: [el-search] Improve forward search functions, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search 5c3bd4e 247/332: [el-search] Add bindings for first/last match jumping, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search 3699425 246/332: [el-search] Add command 'el-search-last-buffer-match', Stefan Monnier, 2020/12/01
- [elpa] externals/el-search cf68daf 249/332: [el-search] Avoid most calls to 'scan-sexps',
Stefan Monnier <=
- [elpa] externals/el-search 894f8b1 254/332: [el-search] More minor tweaks, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search 6c5a6b4 265/332: [el-search] Fix an infloop in el-search--search-pattern-1, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search b830be5 263/332: [el-search] Some scrolling tweaks, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search e60f228 267/332: [el-search] Don't try to kill modified buffers, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search 34f734e 258/332: [el-search] Add special scroll commands, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search d4ad652 278/332: [el-search] Implement an explicit quit command, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search fbe70bf 284/332: [el-search] Add C-h help, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search fac5586 285/332: [el-search] Improve my last commit "Add C-h help", Stefan Monnier, 2020/12/01
- [elpa] externals/el-search 23911d1 288/332: [el-search] Add menus, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search 68fcfcd 286/332: [el-search] Include preceding comments in occur defun context, Stefan Monnier, 2020/12/01