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

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

[elpa] externals/ivy 24a8262767 3/5: Minor cleanups/cosmetics


From: Basil L. Contovounesios
Subject: [elpa] externals/ivy 24a8262767 3/5: Minor cleanups/cosmetics
Date: Sun, 26 Mar 2023 09:22:32 -0400 (EDT)

branch: externals/ivy
commit 24a8262767b7917a91ed7ffc11298f28569e3087
Author: Basil L. Contovounesios <contovob@tcd.ie>
Commit: Basil L. Contovounesios <contovob@tcd.ie>

    Minor cleanups/cosmetics
    
    * ivy.el (ivy--regex-p): Pacify byte-compiler.
    
    * swiper.el: Explicitly load cl-lib dependency.
    (swiper--opoint): Don't initialize with a misleading value.  Clarify
    docstring.
    (swiper--update-input-ivy): Use variadic <=.
    (swiper--action): Wrap long line.
    (swiper--isearch-backward): Add docstring.
    (swiper--isearch-start-point): Remove.  Replace all uses with
    swiper--opoint.
    
    * ivy-test.el (swiper--isearch-format): Initialize starting position
    with a valid value.
---
 ivy-test.el |  2 +-
 ivy.el      |  2 +-
 swiper.el   | 26 ++++++++++++++------------
 3 files changed, 16 insertions(+), 14 deletions(-)

diff --git a/ivy-test.el b/ivy-test.el
index e44f15db9e..462dd915c8 100644
--- a/ivy-test.el
+++ b/ivy-test.el
@@ -1476,8 +1476,8 @@ a buffer visiting a file."
 "))))
 
 (ert-deftest swiper--isearch-format ()
-  (setq swiper--isearch-start-point 0)
   (with-temp-buffer
+    (setq swiper--opoint (point-min))
     (insert
      "line0\nline1\nline line\nline line\nline5")
     (let* ((input "li")
diff --git a/ivy.el b/ivy.el
index 9b66dac917..feb065ca1f 100644
--- a/ivy.el
+++ b/ivy.el
@@ -2889,7 +2889,7 @@ When GREEDY is non-nil, join words in a greedy way."
 
 (defun ivy--regex-p (object)
   "Return OBJECT if it is a valid regular expression, else nil."
-  (ignore-errors (string-match-p object "") object))
+  (ignore-errors (ignore (string-match-p object "")) object))
 
 (defun ivy--regex-or-literal (str)
   "If STR isn't a legal regexp, escape it."
diff --git a/swiper.el b/swiper.el
index 5cfb24ed56..92bb611797 100644
--- a/swiper.el
+++ b/swiper.el
@@ -1,4 +1,4 @@
-;;; swiper.el --- Isearch with an overview. Oh, man! -*- lexical-binding: t -*-
+;;; swiper.el --- Isearch with an overview.  Oh, man! -*- lexical-binding: t 
-*-
 
 ;; Copyright (C) 2015-2021 Free Software Foundation, Inc.
 
@@ -34,6 +34,7 @@
 
 ;;; Code:
 
+(require 'cl-lib)
 (require 'ivy)
 
 (defgroup swiper nil
@@ -573,8 +574,8 @@ numbers; replaces calculating the width from buffer line 
count."
             (cl-incf line-number))
           (nreverse candidates))))))
 
-(defvar swiper--opoint 1
-  "The point when `swiper' starts.")
+(defvar swiper--opoint nil
+  "Value of point when `swiper' or `swiper-isearch' starts.")
 
 ;;;###autoload
 (defun swiper-backward (&optional initial-input)
@@ -966,8 +967,9 @@ the face, window and priority of the overlay."
                       (line-move (1- num))
                     (forward-line (1- num))))
                 (if (and (equal ivy-text "")
-                         (>= swiper--opoint (line-beginning-position))
-                         (<= swiper--opoint (line-end-position)))
+                         (<= (line-beginning-position)
+                             swiper--opoint
+                             (line-end-position)))
                     (goto-char swiper--opoint)
                   (if (eq swiper--current-line num)
                       (when swiper--current-match-start
@@ -1126,7 +1128,8 @@ WND, when specified is the window."
                      #'line-move
                    #'forward-line)
                  ln)
-        (when (and (re-search-forward re (line-end-position) t) 
swiper-goto-start-of-match)
+        (when (and (re-search-forward re (line-end-position) t)
+                   swiper-goto-start-of-match)
           (goto-char (match-beginning 0)))
         (swiper--ensure-visible)
         (swiper--maybe-recenter)
@@ -1384,8 +1387,8 @@ See `ivy-format-functions-alist' for further information."
               (invisible-p (overlay-get ov 'invisible)))
             (overlays-at (point))))))
 
-(defvar swiper--isearch-backward nil)
-(defvar swiper--isearch-start-point nil)
+(defvar swiper--isearch-backward nil
+  "Non-nil when performing `swiper-isearch-backward'.")
 
 (defun swiper--isearch-function-1 (re backward)
   (unless (string= re ".")
@@ -1416,13 +1419,13 @@ See `ivy-format-functions-alist' for further 
information."
             (setq re (concat "\\=\\(?:" re "\\)"))
             (cl-position-if
              (lambda (x)
-               (when (< x swiper--isearch-start-point)
+               (when (< x swiper--opoint)
                  (goto-char x)
                  ;; Note: Not quite the same as `looking-at' + `match-end'.
-                 (re-search-forward re swiper--isearch-start-point t)))
+                 (re-search-forward re swiper--opoint t)))
              cands
              :from-end t))
-        (cl-position swiper--isearch-start-point cands :test #'<))
+        (cl-position swiper--opoint cands :test #'<))
       0))
 
 (defun swiper--isearch-filter-ignore-order (re-full cands)
@@ -1711,7 +1714,6 @@ When the input is empty, browse the search history 
instead."
 (defun swiper--isearch-init ()
   "Initialize `swiper-isearch'."
   (swiper--init)
-  (setq swiper--isearch-start-point (point))
   (swiper-font-lock-ensure))
 
 (defun swiper--isearch-unwind ()



reply via email to

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