diff options
-rw-r--r-- | emacs/.emacs.d/wpc/>.el | 29 | ||||
-rw-r--r-- | emacs/.emacs.d/wpc/alist.el | 11 | ||||
-rw-r--r-- | emacs/.emacs.d/wpc/cache.el | 3 | ||||
-rw-r--r-- | emacs/.emacs.d/wpc/colorscheme.el | 3 | ||||
-rw-r--r-- | emacs/.emacs.d/wpc/irc.el | 5 | ||||
-rw-r--r-- | emacs/.emacs.d/wpc/macros.el | 7 | ||||
-rw-r--r-- | emacs/.emacs.d/wpc/scope.el | 6 | ||||
-rw-r--r-- | emacs/.emacs.d/wpc/stack.el | 13 |
8 files changed, 52 insertions, 25 deletions
diff --git a/emacs/.emacs.d/wpc/>.el b/emacs/.emacs.d/wpc/>.el new file mode 100644 index 000000000000..68d8576b8079 --- /dev/null +++ b/emacs/.emacs.d/wpc/>.el @@ -0,0 +1,29 @@ +;;; >.el --- Small utility functions -*- lexical-binding: t -*- + +;; Author: William Carroll <wpcarro@gmail.com> +;; Version: 0.0.1 +;; URL: https://git.wpcarro.dev/wpcarro/briefcase +;; Package-Requires: ((emacs "24")) + +;;; Commentary: +;; Originally I stored the `>>` macro in macros.el, but after setting up linting +;; for my Elisp in CI, `>>` failed because it didn't have the `macros-` +;; namespace. I created this module to establish a `>-` namespace under which I +;; can store some utilities that would be best kept without a cumbersome +;; namespace. + +;;; Code: + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; Library +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +(defmacro >-> (&rest forms) + "Compose a new, point-free function by composing FORMS together." + (let ((sym (gensym))) + `(lambda (,sym) + (->> ,sym ,@forms)))) + + +(provide '>) +;;; >.el ends here diff --git a/emacs/.emacs.d/wpc/alist.el b/emacs/.emacs.d/wpc/alist.el index 52493c6c03a7..dd4b10133d53 100644 --- a/emacs/.emacs.d/wpc/alist.el +++ b/emacs/.emacs.d/wpc/alist.el @@ -60,21 +60,18 @@ ;; TODO: Include a section that compares alist.el to a.el from ;; github.com/plexus/a.el. +;;; Code: + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Dependencies: +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; TODO: Consider dropping explicit dependency white-listing since all of these -;; should be available in my Emacs. The problem arises when this library needs -;; to be published, in which case, something like Nix and a build process could -;; possible insert the necessary require statements herein. Not sure how I feel -;; about this though. (require 'maybe) (require 'macros) (require 'dash) (require 'tuple) (require 'maybe) -;;; Code: - ;; TODO: Support function aliases for: ;; - create/set ;; - read/get diff --git a/emacs/.emacs.d/wpc/cache.el b/emacs/.emacs.d/wpc/cache.el index 7cba788945d2..be2049091c6d 100644 --- a/emacs/.emacs.d/wpc/cache.el +++ b/emacs/.emacs.d/wpc/cache.el @@ -29,6 +29,7 @@ (require 'prelude) (require 'struct) +(require '>) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Library @@ -55,7 +56,7 @@ If X isn't in XS (using `equal'), insert it at the front." (struct-update cache xs - (>> (list-reject (lambda (y) (equal x y))) + (>-> (list-reject (lambda (y) (equal x y))) (list-cons x)) xs)) diff --git a/emacs/.emacs.d/wpc/colorscheme.el b/emacs/.emacs.d/wpc/colorscheme.el index 2045777c4ee2..f04b1d65766c 100644 --- a/emacs/.emacs.d/wpc/colorscheme.el +++ b/emacs/.emacs.d/wpc/colorscheme.el @@ -20,6 +20,7 @@ (require 'cycle) (require 'general) +(require '>) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Constants @@ -36,7 +37,7 @@ (cycle-from-list (->> (custom-available-themes) (list-map #'symbol-name) - (list-filter (>> (s-starts-with? "doom-"))) + (list-filter (>-> (s-starts-with? "doom-"))) (list-map #'intern))) "The whitelist of colorschemes through which to cycle.") diff --git a/emacs/.emacs.d/wpc/irc.el b/emacs/.emacs.d/wpc/irc.el index 46a0fa73af60..1dfffd329b81 100644 --- a/emacs/.emacs.d/wpc/irc.el +++ b/emacs/.emacs.d/wpc/irc.el @@ -22,6 +22,7 @@ (require 'set) (require 'maybe) (require 'macros) +(require '>) (require 'password-store) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -79,8 +80,8 @@ (setq erc-autojoin-channels-alist (->> irc-server->channels (alist-map-values #'cycle-to-list) - (alist-map-keys (>> (s-chop-prefix "irc.") - (s-chop-suffix ".net"))))) + (alist-map-keys (>-> (s-chop-prefix "irc.") + (s-chop-suffix ".net"))))) (defcustom irc-install-kbds? t "When t, install the keybindings defined herein.") diff --git a/emacs/.emacs.d/wpc/macros.el b/emacs/.emacs.d/wpc/macros.el index e7fd16229efb..715ca3e43ced 100644 --- a/emacs/.emacs.d/wpc/macros.el +++ b/emacs/.emacs.d/wpc/macros.el @@ -54,13 +54,6 @@ Usage: (add-hook-before-save 'reason-mode-hook #'refmt-before-save)" "Empty comment s-expresion where `BODY' is ignored." `nil) -;; NOTE: Not prepending the "macros" to this macro, since brevity is its goal. -(defmacro >> (&rest forms) - "Compose a new, point-free function by composing FORMS together." - (let ((sym (gensym))) - `(lambda (,sym) - (->> ,sym ,@forms)))) - (defmacro macros-support-file-extension (ext mode) "Register MODE to automatically load with files ending with EXT extension. Usage: (macros-support-file-extension \"pb\" protobuf-mode)" diff --git a/emacs/.emacs.d/wpc/scope.el b/emacs/.emacs.d/wpc/scope.el index c97a59b88bd6..e8a2ad2ecc8d 100644 --- a/emacs/.emacs.d/wpc/scope.el +++ b/emacs/.emacs.d/wpc/scope.el @@ -20,7 +20,7 @@ (require 'alist) (require 'stack) (require 'struct) -(require 'macros) +(require '>) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Create @@ -47,7 +47,7 @@ The newest bindings eclipse the oldest." "Push a new, empty scope onto XS." (struct-update scope scopes - (>> (stack-push (alist-new))) + (>-> (stack-push (alist-new))) xs)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -75,7 +75,7 @@ The newest bindings eclipse the oldest." "Set value, V, at key, K, in XS for the current scope." (struct-update scope scopes - (>> (stack-map-top (>> (alist-set k v)))) + (>-> (stack-map-top (>-> (alist-set k v)))) xs)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; diff --git a/emacs/.emacs.d/wpc/stack.el b/emacs/.emacs.d/wpc/stack.el index 021004aec88d..c90f41e7602d 100644 --- a/emacs/.emacs.d/wpc/stack.el +++ b/emacs/.emacs.d/wpc/stack.el @@ -18,14 +18,19 @@ ;;; Code: -(require 'list) +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; Dependencies +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -(cl-defstruct stack xs) +(require 'list) +(require '>) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Create ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +(cl-defstruct stack xs) + (defun stack-new () "Create an empty stack." (make-stack :xs '())) @@ -52,7 +57,7 @@ "Push `X' on `XS'." (struct-update stack xs - (>> (list-cons x)) + (>-> (list-cons x)) xs)) ;; TODO: How to return something like {(list-head xs), (list-tail xs)} in Elixir @@ -63,7 +68,7 @@ Since I cannot figure out a nice way of return tuples in Elisp, if you want to look at the first element, use `stack-peek' before running `stack-pop'." (struct-update stack xs - (>> list-tail) + (>-> list-tail) xs)) (defun stack-map-top (f xs) |