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

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

[elpa] master cbaa811 014/167: Use forward-line instead of line-move if


From: Oleh Krehel
Subject: [elpa] master cbaa811 014/167: Use forward-line instead of line-move if possible
Date: Tue, 08 Dec 2015 10:49:36 +0000

branch: master
commit cbaa81195ec5cc0b4b06dcf29a12bd73bf0ad0ff
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>

    Use forward-line instead of line-move if possible
    
    * swiper.el (swiper--candidates):
    (swiper--update-input-ivy):
    (swiper--action): `line-move' is much slower than `forward-line'. Use it
    only if `visual-line-mode' is on.
---
 swiper.el |   14 +++++++++++---
 1 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/swiper.el b/swiper.el
index cfc80cd..9e70265 100644
--- a/swiper.el
+++ b/swiper.el
@@ -195,6 +195,9 @@
       (setq swiper--format-spec
             (format "%%-%dd " swiper--width))
       (let ((line-number 0)
+            (advancer (if visual-line-mode
+                          #'line-move
+                        #'forward-line))
             candidates)
         (save-excursion
           (goto-char (point-min))
@@ -212,7 +215,7 @@
                                          (cl-incf line-number))
                                  str)
               (push str candidates))
-            (line-move 1))
+            (funcall advancer 1))
           (nreverse candidates))))))
 
 (defvar swiper--opoint 1
@@ -322,7 +325,9 @@ When non-nil, INITIAL-INPUT is the initial search pattern."
         (goto-char (point-min))
         (when (cl-plusp num)
           (goto-char (point-min))
-          (line-move (1- num))
+          (if visual-line-mode
+              (line-move (1- num))
+            (forward-line (1- num)))
           (if (and (equal ivy-text "")
                    (>= swiper--opoint (line-beginning-position))
                    (<= swiper--opoint (line-end-position)))
@@ -389,7 +394,10 @@ BEG and END, when specified, are the point bounds."
   (if (null x)
       (user-error "No candidates")
     (goto-char (point-min))
-    (line-move (1- (read (get-text-property 0 'display x))))
+    (funcall (if visual-line-mode
+                 #'line-move
+               #'forward-line)
+             (1- (read (get-text-property 0 'display x))))
     (re-search-forward
      (ivy--regex input) (line-end-position) t)
     (swiper--ensure-visible)



reply via email to

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