diff options
author | William Carroll <wpcarro@gmail.com> | 2022-11-25T05·50-0800 |
---|---|---|
committer | wpcarro <wpcarro@gmail.com> | 2022-11-25T06·27+0000 |
commit | 5a0ed0f67ee91f321c5dcdd739f5069bd3634b46 (patch) | |
tree | 3a56aa0ba74f9f53060d3053e4df887ee9a12c2d /users/wpcarro/emacs/pkgs/bookmark | |
parent | 325a7d6fa98ae7dbeabf1d8c1c34c2aed15074dd (diff) |
feat(wpcarro/emacs): Package bookmark.el r/5311
More Elisp packaging :) Change-Id: Ia4971de0815d12f8da1eaa911fa17b8b4896415d Reviewed-on: https://cl.tvl.fyi/c/depot/+/7383 Reviewed-by: wpcarro <wpcarro@gmail.com> Tested-by: BuildkiteCI
Diffstat (limited to 'users/wpcarro/emacs/pkgs/bookmark')
-rw-r--r-- | users/wpcarro/emacs/pkgs/bookmark/bookmark.el | 50 | ||||
-rw-r--r-- | users/wpcarro/emacs/pkgs/bookmark/default.nix | 13 |
2 files changed, 63 insertions, 0 deletions
diff --git a/users/wpcarro/emacs/pkgs/bookmark/bookmark.el b/users/wpcarro/emacs/pkgs/bookmark/bookmark.el new file mode 100644 index 000000000000..ab9169a078d4 --- /dev/null +++ b/users/wpcarro/emacs/pkgs/bookmark/bookmark.el @@ -0,0 +1,50 @@ +;;; bookmark.el --- Saved files and directories on my filesystem -*- lexical-binding: t -*- + +;; Author: William Carroll <wpcarro@gmail.com> +;; Version: 0.0.1 +;; Package-Requires: ((emacs "24.3")) + +;;; Commentary: +;; A more opinionated version of Emacs's builtin `jump-to-register'. + +;;; Code: + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; Dependencies +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +(require 'project) +(require 'general) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; Configuration +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +(cl-defstruct bookmark label path kbd) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; API +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +(defun bookmark-open (b) + "Open bookmark, B, as either a project directory or a regular directory." + (with-temp-buffer + (cd (bookmark-path b)) + (call-interactively #'project-find-file))) + +(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))))) + +(provide 'bookmark) +;;; bookmark.el ends here diff --git a/users/wpcarro/emacs/pkgs/bookmark/default.nix b/users/wpcarro/emacs/pkgs/bookmark/default.nix new file mode 100644 index 000000000000..882481701fa2 --- /dev/null +++ b/users/wpcarro/emacs/pkgs/bookmark/default.nix @@ -0,0 +1,13 @@ +{ pkgs, depot, ... }: + +pkgs.callPackage + ({ emacsPackages }: + emacsPackages.trivialBuild { + pname = "bookmark"; + version = "1.0.0"; + src = ./bookmark.el; + packageRequires = (with pkgs.emacsPackages; [ + general + ]); + }) +{ } |