[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/el-search 75d0232 279/332: [el-search] Fix C-J with num
From: |
Stefan Monnier |
Subject: |
[elpa] externals/el-search 75d0232 279/332: [el-search] Fix C-J with numeric arg in case of no match |
Date: |
Tue, 1 Dec 2020 15:49:03 -0500 (EST) |
branch: externals/el-search
commit 75d0232d9573b2b9d02d3a03a5b1a6bdee7996c6
Author: Michael Heerdegen <michael_heerdegen@web.de>
Commit: Michael Heerdegen <michael_heerdegen@web.de>
[el-search] Fix C-J with numeric arg in case of no match
Also bump version to 1.8.5.
* packages/el-search/el-search.el (el-search-jump-to-search-head):
Handle case when numeric prefix arg given but according match doesn't
exist.
Avoid calling 'prefix-numeric-value' on the arg when it could be bound
to a search object.
---
el-search.el | 79 +++++++++++++++++++++++++++++++++---------------------------
1 file changed, 43 insertions(+), 36 deletions(-)
diff --git a/el-search.el b/el-search.el
index a2ce888..55b7a53 100644
--- a/el-search.el
+++ b/el-search.el
@@ -7,7 +7,7 @@
;; Created: 29 Jul 2015
;; Keywords: lisp
;; Compatibility: GNU Emacs 25
-;; Version: 1.8.4
+;; Version: 1.8.5
;; Package-Requires: ((emacs "25") (stream "2.2.4") (cl-print "1.0"))
@@ -2490,41 +2490,48 @@ make current."
(el-search-continue-search))
(setq this-command 'el-search-pattern)
(pop-to-buffer current-search-buffer
el-search-display-buffer-popup-action)
- (let ((last-match (el-search-object-last-match search)))
- (cond
- ((< (prefix-numeric-value arg) 0)
- (progn (setq arg (prefix-numeric-value arg))
- (goto-char (window-end))))
- ((not (numberp arg))
- (goto-char (if (not (and last-match
- ;; this should only happen for bad search
patterns
- (eq (marker-buffer last-match)
(current-buffer))))
- (el-search-head-position current-head)
- last-match)))
- ((zerop arg) (setq arg 1))
- (t (goto-char (window-start))))
- (let ((match-pos
- (save-excursion
- (el-search--search-pattern-1
- (el-search--current-matcher)
- (not (numberp arg)) nil ;FIXME: Handle no match case
explicitly
- (el-search--current-heuristic-matcher)
- (if (numberp arg) arg 1)))))
- (unless (or (numberp arg) (eq (point) match-pos))
- (message "No match at search head any more - going to the next
match")
- (redisplay)
- ;; Don't just `sit-for' here: `pop-to-buffer' may have generated
frame
- ;; focus events
- (sleep-for 1.5))
- (if (not match-pos)
- (el-search-continue-search)
- (goto-char match-pos)
- (setf (el-search-head-position current-head)
- (copy-marker (point)))
- (setf (el-search-object-last-match el-search--current-search)
- (copy-marker (point)))
- (el-search-hl-sexp)
- (el-search-hl-other-matches (el-search--current-matcher))))))
+ (el-search-protect-search-head
+ (let ((last-match (el-search-object-last-match search)))
+ (cond
+ ((and (not (el-search-object-p arg))
+ (< (prefix-numeric-value arg) 0))
+ (setq arg (prefix-numeric-value arg))
+ (goto-char (window-end)))
+ ((not (numberp arg))
+ (goto-char (if (not (and last-match
+ ;; this should only happen for bad
search patterns
+ (eq (marker-buffer last-match)
(current-buffer))))
+ (el-search-head-position current-head)
+ last-match)))
+ ((zerop arg) (setq arg 1))
+ (t (goto-char (window-start))))
+ (let ((match-pos
+ (save-excursion
+ (el-search--search-pattern-1
+ (el-search--current-matcher)
+ t nil
+ (el-search--current-heuristic-matcher)
+ (if (numberp arg) arg 1)))))
+ (when (and (numberp arg) (not match-pos))
+ (setq el-search--success nil)
+ (el-search-hl-post-command-fun)
+ (goto-char (car el-search--search-origin))
+ (user-error "No match there"))
+ (unless (or (numberp arg) (eq (point) match-pos))
+ (message "No match at search head any more - going to the next
match")
+ (redisplay)
+ ;; Don't just `sit-for' here: `pop-to-buffer' may have
generated frame
+ ;; focus events
+ (sleep-for 1.5))
+ (if (not match-pos)
+ (el-search-continue-search)
+ (goto-char match-pos)
+ (setf (el-search-head-position current-head)
+ (copy-marker (point)))
+ (setf (el-search-object-last-match el-search--current-search)
+ (copy-marker (point)))
+ (el-search-hl-sexp)
+ (el-search-hl-other-matches (el-search--current-matcher)))))))
(el-search--message-no-log "[Search completed - restarting]")
(sit-for 1.5)
(el-search-reset-search el-search--current-search)
- [elpa] externals/el-search 96b7423 245/332: [el-search] Special case 'el-search-make-matcher' for '_', (continued)
- [elpa] externals/el-search 96b7423 245/332: [el-search] Special case 'el-search-make-matcher' for '_', Stefan Monnier, 2020/12/01
- [elpa] externals/el-search eef5de0 243/332: [el-search] Save two 'eval' calls, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search 427afa8 253/332: [el-search] Bump version to 1.7.1, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search 0907a21 248/332: [el-search] Bump version to 1.7, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search 1bc9c89 252/332: [el-search] Improve 'el-search-display-match-count', Stefan Monnier, 2020/12/01
- [elpa] externals/el-search ba806ce 251/332: [el-search] Enforce defun start for heuristic matching, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search ab5bcd8 266/332: [el-search] Follow-up to "Fix nested match issues in *El Occur*", Stefan Monnier, 2020/12/01
- [elpa] externals/el-search 2c2930b 256/332: * el-search/el-search.el: Again tweak commentary in header, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search 5e97386 255/332: [el-search] Improve match faces, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search fdb5656 270/332: [el-search] Make y move forward after replacing, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search 75d0232 279/332: [el-search] Fix C-J with numeric arg in case of no match,
Stefan Monnier <=
- [elpa] externals/el-search a661225 272/332: [el-search] Minor tweaks in el-search-query-replace, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search e29370e 281/332: [el-search] Fix more "redundant _ pattern" warnings, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search 5c903d9 292/332: [el-search] Small fix for my last commit, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search be0324a 301/332: [el-search] Some minor tweaks and bump version to 1.10.1, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search 3b4b95b 304/332: [el-search] Small fix in el-search--changed-files-in-repo, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search 2f427dd 318/332: [el-search] Query-replace: Change skip keys, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search a5dd88c 322/332: [el-search] Minor fix in el-search-query-replace--read-args, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search 1939340 324/332: [el-search] Harmonize search and qu-replace prefix arg, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search 43779b9 329/332: [el-search] Improve "New command el-search-repository", Stefan Monnier, 2020/12/01
- [elpa] externals/el-search 0c25a34 331/332: Update copyright years of some packages, Stefan Monnier, 2020/12/01