about summary refs log tree commit diff
path: root/configs/shared/.emacs.d/wpc/bookmark.el
diff options
context:
space:
mode:
authorWilliam Carroll <wpcarro@gmail.com>2020-01-23T14·55+0000
committerWilliam Carroll <wpcarro@gmail.com>2020-01-23T14·55+0000
commitfcfed99600d970a628a2c30a00fa7ee7fb224025 (patch)
tree24bda51be81cee2164431338d0484fb0e64fe2f8 /configs/shared/.emacs.d/wpc/bookmark.el
parente11ba0598e26e0863ba79dc72f72ccbd88d4d968 (diff)
Assert that the labels used in the bookmark/magit-status are defined
My current self hoping to help my future self.
Diffstat (limited to 'configs/shared/.emacs.d/wpc/bookmark.el')
-rw-r--r--configs/shared/.emacs.d/wpc/bookmark.el22
1 files changed, 14 insertions, 8 deletions
diff --git a/configs/shared/.emacs.d/wpc/bookmark.el b/configs/shared/.emacs.d/wpc/bookmark.el
index 8d7ce99e69dc..851f9be09436 100644
--- a/configs/shared/.emacs.d/wpc/bookmark.el
+++ b/configs/shared/.emacs.d/wpc/bookmark.el
@@ -16,6 +16,7 @@
 (require 'buffer)
 (require 'list)
 (require 'string)
+(require 'set)
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; Constants
@@ -76,14 +77,19 @@ Otherwise, open with `counsel-find-file'."
 (defun bookmark/magit-status ()
   "Use ivy to select a bookmark and jump to its `magit-status' buffer."
   (interactive)
-  (ivy-read "Repository: "
-            '("dotfiles" "mono" "tazjins-depot")
-            :require-match t
-            :action (lambda (label)
-                      (->> label
-                           bookmark/from-label
-                           bookmark-path
-                           magit-status))))
+  (let ((labels (set/new "dotfiles" "mono" "depot"))
+        (all-labels (->> bookmark/whitelist
+                         (list/map (>> bookmark-label))
+                         set/from-list)))
+    (prelude/assert (set/subset? labels all-labels))
+    (ivy-read "Repository: "
+              (set/to-list labels)
+              :require-match t
+              :action (lambda (label)
+                        (->> label
+                             bookmark/from-label
+                             bookmark-path
+                             magit-status)))))
 
 ;; TODO: Consider `ivy-read' extension that takes a list of structs,
 ;; `struct-to-label' and `label-struct' functions.