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 'buffer)
|
||||||
(require 'list)
|
(require 'list)
|
||||||
(require 'string)
|
(require 'string)
|
||||||
|
(require 'set)
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
;; Constants
|
;; Constants
|
||||||
|
@ -76,14 +77,19 @@ Otherwise, open with `counsel-find-file'."
|
||||||
(defun bookmark/magit-status ()
|
(defun bookmark/magit-status ()
|
||||||
"Use ivy to select a bookmark and jump to its `magit-status' buffer."
|
"Use ivy to select a bookmark and jump to its `magit-status' buffer."
|
||||||
(interactive)
|
(interactive)
|
||||||
(ivy-read "Repository: "
|
(let ((labels (set/new "dotfiles" "mono" "depot"))
|
||||||
'("dotfiles" "mono" "tazjins-depot")
|
(all-labels (->> bookmark/whitelist
|
||||||
:require-match t
|
(list/map (>> bookmark-label))
|
||||||
:action (lambda (label)
|
set/from-list)))
|
||||||
(->> label
|
(prelude/assert (set/subset? labels all-labels))
|
||||||
bookmark/from-label
|
(ivy-read "Repository: "
|
||||||
bookmark-path
|
(set/to-list labels)
|
||||||
magit-status))))
|
: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,
|
;; TODO: Consider `ivy-read' extension that takes a list of structs,
|
||||||
;; `struct-to-label' and `label-struct' functions.
|
;; `struct-to-label' and `label-struct' functions.
|
||||||
|
|
Loading…
Reference in a new issue