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

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

[elpa] master 896fed3: [el-search] Fix C-J with numeric arg in case of n


From: Michael Heerdegen
Subject: [elpa] master 896fed3: [el-search] Fix C-J with numeric arg in case of no match
Date: Mon, 17 Dec 2018 13:23:57 -0500 (EST)

branch: master
commit 896fed339f94c7e19fd3d25bfe9e87799933b78c
Author: Michael Heerdegen <address@hidden>
Commit: Michael Heerdegen <address@hidden>

    [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.
---
 packages/el-search/el-search.el | 79 ++++++++++++++++++++++-------------------
 1 file changed, 43 insertions(+), 36 deletions(-)

diff --git a/packages/el-search/el-search.el b/packages/el-search/el-search.el
index a2ce888..55b7a53 100644
--- a/packages/el-search/el-search.el
+++ b/packages/el-search/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)



reply via email to

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