diff options
author | William Carroll <wpcarro@gmail.com> | 2021-11-08T18·36-0800 |
---|---|---|
committer | clbot <clbot@tvl.fyi> | 2022-01-08T06·10+0000 |
commit | 4c51588850f83b4a8dec95867f410ae7b7d5db25 (patch) | |
tree | 3cb40ecc7ab35626f423575155d376cd86cbbc05 /users/wpcarro/emacs/.emacs.d/wpc/bookmark.el | |
parent | 821b60a2c9d474b61e573d99c2c2a03636d559cb (diff) |
refactor(wpcarro/emacs): Tidy-up bookmark.el r/3561
TL;DR: - Prefer dash.el - Remove "current project" bookmark - Prefer named functions instead of lambdas to (hopefully) improve `which-key` Change-Id: I090bf372316702f313284a80af9dd076dbf270a3 Reviewed-on: https://cl.tvl.fyi/c/depot/+/4806 Tested-by: BuildkiteCI Reviewed-by: wpcarro <wpcarro@gmail.com> Autosubmit: wpcarro <wpcarro@gmail.com>
Diffstat (limited to 'users/wpcarro/emacs/.emacs.d/wpc/bookmark.el')
-rw-r--r-- | users/wpcarro/emacs/.emacs.d/wpc/bookmark.el | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/users/wpcarro/emacs/.emacs.d/wpc/bookmark.el b/users/wpcarro/emacs/.emacs.d/wpc/bookmark.el index 26c20399e2d4..c5e3bf3ac965 100644 --- a/users/wpcarro/emacs/.emacs.d/wpc/bookmark.el +++ b/users/wpcarro/emacs/.emacs.d/wpc/bookmark.el @@ -21,7 +21,7 @@ (require 'f) (require 'buffer) -(require 'list) +(require 'dash) (require 'string) (require 'set) (require 'constants) @@ -66,21 +66,24 @@ ((f-file? path) (funcall bookmark-handle-file path))))) +(defun bookmark-install-kbd (b) + "Define two functions to explore B and assign them to keybindings." + (eval `(defun ,(intern (format "bookmark-visit-%s" (bookmark-label b))) () + (interactive) + (find-file ,(bookmark-path b)))) + (eval `(defun ,(intern (format "bookmark-browse-%s" (bookmark-label b))) () + (interactive) + (bookmark-open ,b))) + (general-define-key + :prefix "<SPC>" + :states '(motion) + (format "J%s" (bookmark-kbd b)) `,(intern (format "bookmark-visit-%s" (bookmark-label b))) + (format "j%s" (bookmark-kbd b)) `,(intern (format "bookmark-browse-%s" (bookmark-label b))))) (defun bookmark-install-kbds () "Install the keybindings defined herein." (->> bookmark-whitelist - (list-map - (lambda (b) - (general-define-key - :prefix "<SPC>" - :states '(normal) - (format "J%s" (bookmark-kbd b)) - (lambda () (interactive) (find-file (bookmark-path b))) - (format "j%s" (bookmark-kbd b)) - ;; TODO: Consider `cl-labels' so `which-key' minibuffer is more - ;; helpful. - (lambda () (interactive) (bookmark-open b))))))) + (-map #'bookmark-install-kbd))) (provide 'bookmark) ;;; bookmark.el ends here |