From 4c51588850f83b4a8dec95867f410ae7b7d5db25 Mon Sep 17 00:00:00 2001 From: William Carroll Date: Mon, 8 Nov 2021 10:36:45 -0800 Subject: refactor(wpcarro/emacs): Tidy-up bookmark.el 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 Autosubmit: wpcarro --- users/wpcarro/emacs/.emacs.d/wpc/bookmark.el | 27 ++++++++++++++----------- users/wpcarro/emacs/.emacs.d/wpc/keybindings.el | 6 +++--- 2 files changed, 18 insertions(+), 15 deletions(-) (limited to 'users/wpcarro/emacs') diff --git a/users/wpcarro/emacs/.emacs.d/wpc/bookmark.el b/users/wpcarro/emacs/.emacs.d/wpc/bookmark.el index 26c20399e2..c5e3bf3ac9 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 "" + :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 "" - :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 diff --git a/users/wpcarro/emacs/.emacs.d/wpc/keybindings.el b/users/wpcarro/emacs/.emacs.d/wpc/keybindings.el index 25c026c09e..a90da9af59 100644 --- a/users/wpcarro/emacs/.emacs.d/wpc/keybindings.el +++ b/users/wpcarro/emacs/.emacs.d/wpc/keybindings.el @@ -53,9 +53,6 @@ ;; General Keybindings ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; Install KBDs like jb to search through my monorepo. -(bookmark-install-kbds) - ;; Ensure that evil's command mode behaves with readline bindings. (general-define-key :keymaps 'evil-ex-completion-map @@ -383,5 +380,8 @@ "" #'buffer-show-previous "k" #'kill-buffer) +;; Install KBDs like jb to search through my monorepo. +(bookmark-install-kbds) + (provide 'keybindings) ;;; keybindings.el ends here -- cgit 1.4.1