about summary refs log tree commit diff
path: root/users/wpcarro/emacs/.emacs.d/wpc
diff options
context:
space:
mode:
authorWilliam Carroll <wpcarro@gmail.com>2022-02-14T19·56-0800
committerclbot <clbot@tvl.fyi>2022-02-14T20·12+0000
commita8e76b24e81b8be4621414742ed96ed42eb4e9e8 (patch)
treeee9501cf57fe865e041141a1ac83f2280f6e33d0 /users/wpcarro/emacs/.emacs.d/wpc
parenta9effe690caea538e6e9924376757f9b9db815e3 (diff)
refactor(wpcarro/emacs): Simplify bookmark.el r/3826
- narrow lib's scope and update documentation
- remove unnecessary dependencies

Change-Id: I5931a5a6e571466b3334dc02e88c9c283754d263
Reviewed-on: https://cl.tvl.fyi/c/depot/+/5282
Tested-by: BuildkiteCI
Reviewed-by: wpcarro <wpcarro@gmail.com>
Autosubmit: wpcarro <wpcarro@gmail.com>
Diffstat (limited to 'users/wpcarro/emacs/.emacs.d/wpc')
-rw-r--r--users/wpcarro/emacs/.emacs.d/wpc/bookmark.el52
-rw-r--r--users/wpcarro/emacs/.emacs.d/wpc/keybindings.el6
2 files changed, 10 insertions, 48 deletions
diff --git a/users/wpcarro/emacs/.emacs.d/wpc/bookmark.el b/users/wpcarro/emacs/.emacs.d/wpc/bookmark.el
index c5e3bf3ac965..2fa9b5de80d6 100644
--- a/users/wpcarro/emacs/.emacs.d/wpc/bookmark.el
+++ b/users/wpcarro/emacs/.emacs.d/wpc/bookmark.el
@@ -5,13 +5,7 @@
 ;; Package-Requires: ((emacs "24.3"))
 
 ;;; Commentary:
-;; After enjoying and relying on Emacs's builtin `jump-to-register' command, I'd
-;; like to recreate this functionality with a few extensions.
-;;
-;; Everything herein will mimmick my previous KBDs for `jump-to-register', which
-;; were <leader>-j-<register-kbd>.  If the `bookmark-path' is a file, Emacs will
-;; open a buffer with that file.  If the `bookmark-path' is a directory, Emacs
-;; will open an ivy window searching that directory.
+;; A more opinionated version of Emacs's builtin `jump-to-register'.
 
 ;;; Code:
 
@@ -19,52 +13,23 @@
 ;; Dependencies
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
-(require 'f)
-(require 'buffer)
-(require 'dash)
-(require 'string)
-(require 'set)
-(require 'constants)
 (require 'general)
-(require 'tvl)
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;; Constants
+;; Configuration
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
 (cl-defstruct bookmark label path kbd)
 
-(defun bookmark-handle-directory-dwim (path)
-  "Open PATH as either a project directory or a regular directory."
-  (with-temp-buffer
-    (cd path)
-    (call-interactively #'project-find-file)))
-
-(defconst bookmark-handle-directory #'bookmark-handle-directory-dwim
-  "Function to call when a bookmark points to a directory.")
-
-(defconst bookmark-handle-file #'counsel-find-file-action
-  "Function to call when a bookmark points to a file.")
-
-(defconst bookmark-whitelist
-  (list
-   (make-bookmark :label "depot"
-                  :path tvl-depot-path
-                  :kbd "d"))
-  "List of registered bookmarks.")
-
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; API
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
 (defun bookmark-open (b)
-  "Open bookmark, B, in a new buffer or an ivy minibuffer."
-  (let ((path (bookmark-path b)))
-    (cond
-     ((f-directory? path)
-      (funcall bookmark-handle-directory path))
-     ((f-file? path)
-      (funcall bookmark-handle-file path)))))
+  "Open bookmark, B, as either a project directory or a regular directory."
+  (with-temp-buffer
+    (cd path)
+    (call-interactively #'project-find-file)))
 
 (defun bookmark-install-kbd (b)
   "Define two functions to explore B and assign them to keybindings."
@@ -80,10 +45,5 @@
    (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
-       (-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 c8be25aa0cd8..b1a6df6690f0 100644
--- a/users/wpcarro/emacs/.emacs.d/wpc/keybindings.el
+++ b/users/wpcarro/emacs/.emacs.d/wpc/keybindings.el
@@ -397,8 +397,10 @@
 ;; bookmarks
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
-;; Install KBDs like <SPC>jb to search through my monorepo.
-(bookmark-install-kbds)
+(bookmark-install-kbd
+ (make-bookmark :label "depot"
+                :path tvl-depot-path
+                :kbd "d"))
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; refine