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

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

[elpa] master cf71b09 64/67: ivy.el (ivy-wrap): New defcustom


From: Oleh Krehel
Subject: [elpa] master cf71b09 64/67: ivy.el (ivy-wrap): New defcustom
Date: Sun, 22 Mar 2015 17:34:13 +0000

branch: master
commit cf71b096807faf61689321e770c52fe249942b74
Author: John Mastro <address@hidden>
Commit: Oleh Krehel <address@hidden>

    ivy.el (ivy-wrap): New defcustom
    
    (ivy-next-line): Wrap around if `ivy-wrap' is non-nil
    (ivy-next-line-or-history): Wrap around if `ivy-wrap' is non-nil
    (ivy-previous-line): Wrap around if `ivy-wrap' is non-nil
    (ivy-previous-line-or-history): Wrap around if `ivy-wrap' is non-nil
---
 ivy.el |   20 ++++++++++++++++----
 1 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/ivy.el b/ivy.el
index 53f86c1..2ba0b8f 100644
--- a/ivy.el
+++ b/ivy.el
@@ -55,6 +55,10 @@
 Set this to nil if you don't want the count."
   :type 'string)
 
+(defcustom ivy-wrap nil
+  "Whether to wrap around after the first and last candidate."
+  :type 'boolean)
+
 ;;* User Visible
 ;;** Keymap
 (require 'delsel)
@@ -104,7 +108,9 @@ of `history-length', which see.")
 (defun ivy-next-line ()
   "Select the next completion candidate."
   (interactive)
-  (unless (>= ivy--index (1- ivy--length))
+  (if (>= ivy--index (1- ivy--length))
+      (when ivy-wrap
+        (ivy-beginning-of-buffer))
     (cl-incf ivy--index)))
 
 (defun ivy-next-line-or-history ()
@@ -113,13 +119,17 @@ If the input is empty, select the previous history 
element instead."
   (interactive)
   (when (string= ivy-text "")
     (ivy-previous-history-element 1))
-  (unless (>= ivy--index (1- ivy--length))
+  (if (>= ivy--index (1- ivy--length))
+      (when ivy-wrap
+        (ivy-beginning-of-buffer))
     (cl-incf ivy--index)))
 
 (defun ivy-previous-line ()
   "Select the previous completion candidate."
   (interactive)
-  (unless (zerop ivy--index)
+  (if (zerop ivy--index)
+      (when ivy-wrap
+        (ivy-end-of-buffer))
     (cl-decf ivy--index)))
 
 (defun ivy-previous-line-or-history ()
@@ -128,7 +138,9 @@ If the input is empty, select the previous history element 
instead."
   (interactive)
   (when (string= ivy-text "")
     (ivy-previous-history-element 1))
-  (unless (zerop ivy--index)
+  (if (zerop ivy--index)
+      (when ivy-wrap
+        (ivy-end-of-buffer))
     (cl-decf ivy--index)))
 
 (defun ivy-previous-history-element (arg)



reply via email to

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