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 <wpcarro@gmail.com> Autosubmit: wpcarro <wpcarro@gmail.com>
This commit is contained in:
parent
821b60a2c9
commit
4c51588850
2 changed files with 18 additions and 15 deletions
|
@ -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
|
||||
|
|
|
@ -53,9 +53,6 @@
|
|||
;; General Keybindings
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
;; Install KBDs like <SPC>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 @@
|
|||
"<SPC>" #'buffer-show-previous
|
||||
"k" #'kill-buffer)
|
||||
|
||||
;; Install KBDs like <SPC>jb to search through my monorepo.
|
||||
(bookmark-install-kbds)
|
||||
|
||||
(provide 'keybindings)
|
||||
;;; keybindings.el ends here
|
||||
|
|
Loading…
Reference in a new issue