about summary refs log tree commit diff
path: root/users/wpcarro/emacs/.emacs.d/wpc/cycle.el
diff options
context:
space:
mode:
Diffstat (limited to 'users/wpcarro/emacs/.emacs.d/wpc/cycle.el')
-rw-r--r--users/wpcarro/emacs/.emacs.d/wpc/cycle.el3
1 files changed, 2 insertions, 1 deletions
diff --git a/users/wpcarro/emacs/.emacs.d/wpc/cycle.el b/users/wpcarro/emacs/.emacs.d/wpc/cycle.el
index e683f3c201cf..a1853ece1431 100644
--- a/users/wpcarro/emacs/.emacs.d/wpc/cycle.el
+++ b/users/wpcarro/emacs/.emacs.d/wpc/cycle.el
@@ -168,7 +168,8 @@ If there is no currently focused item, add X to the beginning of XS."
       (if curr-i
           (progn
             (struct-set! cycle xs (-insert-at curr-i x (cycle-xs xs)) xs)
-            (when (>= prev-i curr-i) (struct-set! cycle previous-index (1+ prev-i) xs))
+            (when (and prev-i (>= prev-i curr-i))
+              (struct-set! cycle previous-index (1+ prev-i) xs))
             (when curr-i (struct-set! cycle current-index (1+ curr-i) xs)))
         (progn
           (struct-set! cycle xs (cons x (cycle-xs xs)) xs)