about summary refs log tree commit diff
diff options
context:
space:
mode:
authorWilliam Carroll <wpcarro@gmail.com>2022-08-02T21·20-0700
committerclbot <clbot@tvl.fyi>2022-08-03T20·23+0000
commitdb0cfd0616f7432516068f6cb680c0b7c25cde4b (patch)
tree11387e60c8edf413ac1439f8383276b5982ff9d6
parent3461753478c2a8eff47c565d8729bbfd991f2729 (diff)
refactor(wpcarro/emacs): Remove cycle.el's dep on maybe.el r/4379
More pruning on inter-library dependencies.

Change-Id: I711ab92f2985b543ee2684752f9cdbf5559f2eaf
Reviewed-on: https://cl.tvl.fyi/c/depot/+/6035
Reviewed-by: wpcarro <wpcarro@gmail.com>
Autosubmit: wpcarro <wpcarro@gmail.com>
Tested-by: BuildkiteCI
-rw-r--r--users/wpcarro/emacs/pkgs/cycle/cycle.el15
-rw-r--r--users/wpcarro/emacs/pkgs/cycle/default.nix2
-rw-r--r--users/wpcarro/emacs/pkgs/cycle/tests.el3
3 files changed, 6 insertions, 14 deletions
diff --git a/users/wpcarro/emacs/pkgs/cycle/cycle.el b/users/wpcarro/emacs/pkgs/cycle/cycle.el
index 17dbd2fdb9..2f5b252a0d 100644
--- a/users/wpcarro/emacs/pkgs/cycle/cycle.el
+++ b/users/wpcarro/emacs/pkgs/cycle/cycle.el
@@ -15,7 +15,6 @@
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
 (require 'dash)
-(require 'maybe)
 (require 'struct)
 (require 'cl-lib)
 
@@ -55,19 +54,15 @@
 (defun cycle-previous-focus (cycle)
   "Return the previously focused entry in CYCLE."
   (let ((i (cycle-previous-index cycle)))
-    (if (maybe-some? i)
-        (nth i (cycle-xs cycle))
-      nil)))
+    (when i (nth i (cycle-xs cycle)))))
 
 (defun cycle-focus-previous! (xs)
   "Jump to the item in XS that was most recently focused; return the cycle.
 This will error when previous-index is nil.  This function mutates the
 underlying struct."
   (let ((i (cycle-previous-index xs)))
-    (if (maybe-some? i)
-        (progn
-          (cycle-jump! i xs)
-          (cycle-current xs))
+    (if i
+        (progn (cycle-jump! i xs) (cycle-current xs))
       (error "Cannot focus the previous element since cycle-previous-index is nil"))))
 
 (defun cycle-next! (xs)
@@ -163,7 +158,7 @@ If X is the currently focused value, after it's deleted, current-index will be
 
 (defun cycle-contains? (x xs)
   "Return t if cycle, XS, has member X."
-  (maybe-some? (-contains? (cycle-xs xs) x)))
+  (not (null (-contains? (cycle-xs xs) x))))
 
 (defun cycle-empty? (xs)
   "Return t if cycle XS has no elements."
@@ -171,7 +166,7 @@ If X is the currently focused value, after it's deleted, current-index will be
 
 (defun cycle-focused? (xs)
   "Return t if cycle XS has a non-nil value for current-index."
-  (maybe-some? (cycle-current-index xs)))
+  (not (null (cycle-current-index xs))))
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; Helper Functions
diff --git a/users/wpcarro/emacs/pkgs/cycle/default.nix b/users/wpcarro/emacs/pkgs/cycle/default.nix
index 16c887bbfc..7ef3b431ad 100644
--- a/users/wpcarro/emacs/pkgs/cycle/default.nix
+++ b/users/wpcarro/emacs/pkgs/cycle/default.nix
@@ -12,7 +12,6 @@ let
             dash
           ]) ++
           (with depot.users.wpcarro.emacs.pkgs; [
-            maybe
             struct
           ]);
       })
@@ -20,7 +19,6 @@ let
 
   emacs = (pkgs.emacsPackagesFor pkgs.emacs28).emacsWithPackages (epkgs: [
     epkgs.dash
-    depot.users.wpcarro.emacs.pkgs.maybe
     cycle
   ]);
 in
diff --git a/users/wpcarro/emacs/pkgs/cycle/tests.el b/users/wpcarro/emacs/pkgs/cycle/tests.el
index e58c97bedb..29c0e2a0d5 100644
--- a/users/wpcarro/emacs/pkgs/cycle/tests.el
+++ b/users/wpcarro/emacs/pkgs/cycle/tests.el
@@ -5,7 +5,6 @@
 (require 'ert)
 (require 'cycle)
 (require 'dash)
-(require 'maybe)
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; Tests
@@ -15,7 +14,7 @@
 
 (ert-deftest cycle-initializes-properly ()
   (should (= 3 (cycle-count xs)))
-  (should (maybe-nil? (cycle-previous-focus xs)))
+  (should (null (cycle-previous-focus xs)))
   (should (cycle-contains? 1 xs))
   (should (cycle-contains? 2 xs))
   (should (cycle-contains? 3 xs)))