Support bookmark/from-label

Add function to resolve a bookmark from its label.
This commit is contained in:
William Carroll 2020-01-22 21:55:07 +00:00
parent 589349282f
commit 857ef43d2d

View file

@ -68,6 +68,11 @@ Otherwise, open with `counsel-find-file'."
:kbd "p")) :kbd "p"))
"List of registered bookmarks.") "List of registered bookmarks.")
(defun bookmark/from-label (label)
"Return the bookmark with LABEL or nil."
(->> bookmark/whitelist
(list/find (lambda (b) (equal label (bookmark-label b))))))
;; 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.
@ -93,11 +98,7 @@ Otherwise, open with `counsel-find-file'."
(list/map #'bookmark-label)) (list/map #'bookmark-label))
:require-match t :require-match t
:action (lambda (label) :action (lambda (label)
(->> bookmark/whitelist (bookmark/open (bookmark/from-label label)))))
(list/find
(lambda (b)
(equal label (bookmark-label b))))
bookmark/open))))
(when bookmark/install-kbds? (when bookmark/install-kbds?
(general-define-key (general-define-key