From fcfed99600d970a628a2c30a00fa7ee7fb224025 Mon Sep 17 00:00:00 2001 From: William Carroll Date: Thu, 23 Jan 2020 14:55:22 +0000 Subject: Assert that the labels used in the bookmark/magit-status are defined My current self hoping to help my future self. --- configs/shared/.emacs.d/wpc/bookmark.el | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) (limited to 'configs/shared') 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. -- cgit 1.4.1