From ebbda2484a47054aa16946d40c10130608c6e15a Mon Sep 17 00:00:00 2001 From: William Carroll Date: Thu, 21 Jul 2022 19:55:39 -0700 Subject: feat(wpcarro/emacs): Package zle.el The end-goal is to package all of my Elisp libraries. Why? - More granular builds/tests - More explicitly defined dependencies - Separate personal configuration from library code - Ease distribution Change-Id: I2507d129d3a0b3bf0cfe70b9790536a8b2093b96 Reviewed-on: https://cl.tvl.fyi/c/depot/+/5969 Tested-by: BuildkiteCI Reviewed-by: wpcarro Autosubmit: wpcarro --- users/wpcarro/emacs/.emacs.d/wpc/zle.el | 91 -------------------------------- users/wpcarro/emacs/default.nix | 4 ++ users/wpcarro/emacs/pkgs/zle/default.nix | 10 ++++ users/wpcarro/emacs/pkgs/zle/zle.el | 90 +++++++++++++++++++++++++++++++ 4 files changed, 104 insertions(+), 91 deletions(-) delete mode 100644 users/wpcarro/emacs/.emacs.d/wpc/zle.el create mode 100644 users/wpcarro/emacs/pkgs/zle/default.nix create mode 100644 users/wpcarro/emacs/pkgs/zle/zle.el diff --git a/users/wpcarro/emacs/.emacs.d/wpc/zle.el b/users/wpcarro/emacs/.emacs.d/wpc/zle.el deleted file mode 100644 index d4aa88258f..0000000000 --- a/users/wpcarro/emacs/.emacs.d/wpc/zle.el +++ /dev/null @@ -1,91 +0,0 @@ -;;; zle.el --- Functions to mimmick my ZLE KBDs -*- lexical-binding: t -*- - -;; Author: William Carroll -;; Version: 0.0.1 -;; Package-Requires: ((emacs "24")) - -;;; Commentary: -;; This is primarily for personal use. The keybindings that I choose are those -;; that feel slightly mnemonic while also not shadowing important bindings. -;; It's quite possible that our tastes will differ here. -;; -;; All of these keybindings are intended to shave off milliseconds off your -;; typing. I don't expect these numbers to sum up to a meaningful amount. The -;; primary reason that I wrote this, is that it introduces a small amount of -;; structural editing to my workflow. I've been using these exact keybindings -;; on the command line, and I find them subtely delightful to use. So much so -;; that I decided to bring them to my Emacs configuration. -;; -;; ZLE is the Z-shell line editor. I have some KBDs and functions that I often -;; want in Emacs. -;; -;; Usage: -;; Consider running `(zle-minor-mode)' to run this globally. Depending on your -;; configuration, it could be non-disruptive, disruptive, or extremely -;; disruptive. - -;;; Code: - -;; subshell (C-j) -(defun zle-subshell () - "Insert the characters necessary to create a subshell." - (interactive) - (insert-char ?$) - (insert-char ?\() - (save-excursion - (insert-char ?\)))) - -;; variable (C-v) -(defun zle-variable () - "Insert the characters to reference a variable." - (interactive) - (insert-char ?$) - (insert-char ?{) - (save-excursion - (insert-char ?}))) - -;; 2x dash (C-M--) -(defun zle-dash-dash () - "Insert the characters for flags with 2x dashes." - (interactive) - (insert-char ? ) - (insert-char ?-) - (insert-char ?-)) - -;; 1x quotes (M-') -(defun zle-single-quote () - "Insert the characters to quickly create single quotes." - (interactive) - (insert-char ? ) - (insert-char ?') - (save-excursion - (insert-char ?'))) - -;; 2x quotes (M-") -(defun zle-double-quote () - "Insert the characters to quickly create double quotes." - (interactive) - (insert-char ? ) - (insert-char ?\") - (save-excursion - (insert-char ?\"))) - -(defvar zle-kbds - (let ((map (make-sparse-keymap))) - (bind-keys :map map - ("C-j" . zle-subshell) - ("C-v" . zle-variable) - ("C-M--" . zle-dash-dash) - ("M-'" . zle-single-quote) - ("M-\"" . zle-double-quote)) - map) - "Keybindings shaving milliseconds off of typing.") - -(define-minor-mode zle-minor-mode - "A minor mode mirroring my ZLE keybindings." - :init-value nil - :lighter " zle" - :keymap zle-kbds) - -(provide 'zle) -;;; zle.el ends here diff --git a/users/wpcarro/emacs/default.nix b/users/wpcarro/emacs/default.nix index c6e6e913a0..6607b668d5 100644 --- a/users/wpcarro/emacs/default.nix +++ b/users/wpcarro/emacs/default.nix @@ -24,6 +24,10 @@ let emacsWithPackages = (emacsPackagesFor emacs28).emacsWithPackages; wpcarrosEmacs = emacsWithPackages (epkgs: + (with wpcarro.emacs.pkgs; [ + zle + ]) ++ + (with epkgs.tvlPackages; [ tvl ]) ++ diff --git a/users/wpcarro/emacs/pkgs/zle/default.nix b/users/wpcarro/emacs/pkgs/zle/default.nix new file mode 100644 index 0000000000..9d4820a944 --- /dev/null +++ b/users/wpcarro/emacs/pkgs/zle/default.nix @@ -0,0 +1,10 @@ +{ pkgs, ... }: + +pkgs.callPackage + ({ emacsPackages }: + emacsPackages.trivialBuild { + pname = "zle"; + version = "1.0.0"; + src = ./zle.el; + }) +{ } diff --git a/users/wpcarro/emacs/pkgs/zle/zle.el b/users/wpcarro/emacs/pkgs/zle/zle.el new file mode 100644 index 0000000000..21a6e35f13 --- /dev/null +++ b/users/wpcarro/emacs/pkgs/zle/zle.el @@ -0,0 +1,90 @@ +;;; zle.el --- Functions to mimmick my ZLE KBDs -*- lexical-binding: t -*- + +;; Author: William Carroll +;; Version: 0.0.1 +;; Package-Requires: ((emacs "24")) + +;;; Commentary: +;; This is primarily for personal use. The keybindings that I choose are those +;; that feel slightly mnemonic while also not shadowing important bindings. +;; It's quite possible that our tastes will differ here. +;; +;; All of these keybindings are intended to shave off milliseconds off your +;; typing. I don't expect these numbers to sum up to a meaningful amount. The +;; primary reason that I wrote this, is that it introduces a small amount of +;; structural editing to my workflow. I've been using these exact keybindings +;; on the command line, and I find them subtely delightful to use. So much so +;; that I decided to bring them to my Emacs configuration. +;; +;; ZLE is the Z-shell line editor. I have some KBDs and functions that I often +;; want in Emacs. +;; +;; Usage: +;; Consider running `(zle-minor-mode)' to run this globally. Depending on your +;; configuration, it could be non-disruptive, disruptive, or extremely +;; disruptive. + +;;; Code: + +;; subshell (C-j) +(defun zle-subshell () + "Insert the characters necessary to create a subshell." + (interactive) + (insert-char ?$) + (insert-char ?\() + (save-excursion + (insert-char ?\)))) + +;; variable (C-v) +(defun zle-variable () + "Insert the characters to reference a variable." + (interactive) + (insert-char ?$) + (insert-char ?{) + (save-excursion + (insert-char ?}))) + +;; 2x dash (C-M--) +(defun zle-dash-dash () + "Insert the characters for flags with 2x dashes." + (interactive) + (insert-char ? ) + (insert-char ?-) + (insert-char ?-)) + +;; 1x quotes (M-') +(defun zle-single-quote () + "Insert the characters to quickly create single quotes." + (interactive) + (insert-char ? ) + (insert-char ?') + (save-excursion + (insert-char ?'))) + +;; 2x quotes (M-") +(defun zle-double-quote () + "Insert the characters to quickly create double quotes." + (interactive) + (insert-char ? ) + (insert-char ?\") + (save-excursion + (insert-char ?\"))) + +(defvar zle-kbds + (let ((map (make-sparse-keymap))) + (define-key map (kbd "C-j") #'zle-subshell) + (define-key map (kbd "C-v") #'zle-variable) + (define-key map (kbd "C-M--") #'zle-dash-dash) + (define-key map (kbd "M-'") #'zle-single-quote) + (define-key map (kbd "M-\"") #'zle-double-quote) + map) + "Keybindings shaving milliseconds off of typing.") + +(define-minor-mode zle-minor-mode + "A minor mode mirroring my ZLE keybindings." + :init-value nil + :lighter " zle" + :keymap zle-kbds) + +(provide 'zle) +;;; zle.el ends here -- cgit 1.4.1