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

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

[elpa] master c4775b6 031/348: ivy.el (ivy-action-wrap): New defcustom


From: Oleh Krehel
Subject: [elpa] master c4775b6 031/348: ivy.el (ivy-action-wrap): New defcustom
Date: Sat, 8 Apr 2017 11:03:17 -0400 (EDT)

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

    ivy.el (ivy-action-wrap): New defcustom
    
    * ivy.el (ivy-next-action): Update.
    (ivy-prev-action): Update.
    
    Fixes #516
---
 ivy.el | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/ivy.el b/ivy.el
index 0ac9006..a77ee6c 100644
--- a/ivy.el
+++ b/ivy.el
@@ -860,20 +860,30 @@ If the input is empty, select the previous history 
element instead."
   "Return non-nil when X is a list of actions."
   (and x (listp x) (not (eq (car x) 'closure))))
 
+(defcustom ivy-action-wrap nil
+  "When non-nil, `ivy-next-action' and `ivy-prev-action' wrap."
+  :type 'boolean)
+
 (defun ivy-next-action ()
   "When the current action is a list, scroll it forwards."
   (interactive)
   (let ((action (ivy-state-action ivy-last)))
     (when (ivy--actionp action)
-      (unless (>= (car action) (1- (length action)))
-        (cl-incf (car action))))))
+      (let ((len (1- (length action)))
+            (idx (car action)))
+        (if (>= idx len)
+            (when ivy-action-wrap
+              (setf (car action) 1))
+          (cl-incf (car action)))))))
 
 (defun ivy-prev-action ()
   "When the current action is a list, scroll it backwards."
   (interactive)
   (let ((action (ivy-state-action ivy-last)))
     (when (ivy--actionp action)
-      (unless (<= (car action) 1)
+      (if (<= (car action) 1)
+          (when ivy-action-wrap
+            (setf (car action) (1- (length action))))
         (cl-decf (car action))))))
 
 (defun ivy-action-name ()



reply via email to

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