Assert that the labels used in the bookmark/magit-status are defined
My current self hoping to help my future self.
This commit is contained in:
parent
e11ba0598e
commit
fcfed99600
1 changed files with 14 additions and 8 deletions
|
@ -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.
|
||||
|
|
Loading…
Reference in a new issue