Redefine >> macro as >-> in >.el
I created a strangely named Elisp module, >.el, just to appease the CI gods. My gut tells me that this is a desperate idea and fails the smell test. I'm pretty eager to pass the linting phase of my Elisp CI, however, and I can always revert this.
This commit is contained in:
		
							parent
							
								
									718899c629
								
							
						
					
					
						commit
						75a9a156a0
					
				
					 8 changed files with 53 additions and 26 deletions
				
			
		
							
								
								
									
										29
									
								
								emacs/.emacs.d/wpc/>.el
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										29
									
								
								emacs/.emacs.d/wpc/>.el
									
										
									
									
									
										Normal file
									
								
							|  | @ -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 | ||||||
|  | @ -60,21 +60,18 @@ | ||||||
| ;; TODO: Include a section that compares alist.el to a.el from | ;; TODO: Include a section that compares alist.el to a.el from | ||||||
| ;; github.com/plexus/a.el. | ;; github.com/plexus/a.el. | ||||||
| 
 | 
 | ||||||
| ;; Dependencies: | ;;; 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 'maybe) | ||||||
| (require 'macros) | (require 'macros) | ||||||
| (require 'dash) | (require 'dash) | ||||||
| (require 'tuple) | (require 'tuple) | ||||||
| (require 'maybe) | (require 'maybe) | ||||||
| 
 | 
 | ||||||
| ;;; Code: |  | ||||||
| 
 |  | ||||||
| ;; TODO: Support function aliases for: | ;; TODO: Support function aliases for: | ||||||
| ;; - create/set | ;; - create/set | ||||||
| ;; - read/get | ;; - read/get | ||||||
|  |  | ||||||
|  | @ -29,6 +29,7 @@ | ||||||
| 
 | 
 | ||||||
| (require 'prelude) | (require 'prelude) | ||||||
| (require 'struct) | (require 'struct) | ||||||
|  | (require '>) | ||||||
| 
 | 
 | ||||||
| ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | ||||||
| ;; Library | ;; Library | ||||||
|  | @ -55,7 +56,7 @@ If X isn't in XS (using `equal'), insert it at the front." | ||||||
|   (struct-update |   (struct-update | ||||||
|    cache |    cache | ||||||
|    xs |    xs | ||||||
|    (>> (list-reject (lambda (y) (equal x y))) |    (>-> (list-reject (lambda (y) (equal x y))) | ||||||
|        (list-cons x)) |        (list-cons x)) | ||||||
|    xs)) |    xs)) | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -20,6 +20,7 @@ | ||||||
| 
 | 
 | ||||||
| (require 'cycle) | (require 'cycle) | ||||||
| (require 'general) | (require 'general) | ||||||
|  | (require '>) | ||||||
| 
 | 
 | ||||||
| ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | ||||||
| ;; Constants | ;; Constants | ||||||
|  | @ -36,7 +37,7 @@ | ||||||
|   (cycle-from-list |   (cycle-from-list | ||||||
|    (->> (custom-available-themes) |    (->> (custom-available-themes) | ||||||
|         (list-map #'symbol-name) |         (list-map #'symbol-name) | ||||||
|         (list-filter (>> (s-starts-with? "doom-"))) |         (list-filter (>-> (s-starts-with? "doom-"))) | ||||||
|         (list-map #'intern))) |         (list-map #'intern))) | ||||||
|   "The whitelist of colorschemes through which to cycle.") |   "The whitelist of colorschemes through which to cycle.") | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -22,6 +22,7 @@ | ||||||
| (require 'set) | (require 'set) | ||||||
| (require 'maybe) | (require 'maybe) | ||||||
| (require 'macros) | (require 'macros) | ||||||
|  | (require '>) | ||||||
| (require 'password-store) | (require 'password-store) | ||||||
| 
 | 
 | ||||||
| ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | ||||||
|  | @ -79,8 +80,8 @@ | ||||||
| (setq erc-autojoin-channels-alist | (setq erc-autojoin-channels-alist | ||||||
|       (->> irc-server->channels |       (->> irc-server->channels | ||||||
|            (alist-map-values #'cycle-to-list) |            (alist-map-values #'cycle-to-list) | ||||||
|            (alist-map-keys (>> (s-chop-prefix "irc.") |            (alist-map-keys (>-> (s-chop-prefix "irc.") | ||||||
|                                (s-chop-suffix ".net"))))) |                                 (s-chop-suffix ".net"))))) | ||||||
| 
 | 
 | ||||||
| (defcustom irc-install-kbds? t | (defcustom irc-install-kbds? t | ||||||
|   "When t, install the keybindings defined herein.") |   "When t, install the keybindings defined herein.") | ||||||
|  |  | ||||||
|  | @ -54,13 +54,6 @@ Usage: (add-hook-before-save 'reason-mode-hook #'refmt-before-save)" | ||||||
|   "Empty comment s-expresion where `BODY' is ignored." |   "Empty comment s-expresion where `BODY' is ignored." | ||||||
|   `nil) |   `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) | (defmacro macros-support-file-extension (ext mode) | ||||||
|   "Register MODE to automatically load with files ending with EXT extension. |   "Register MODE to automatically load with files ending with EXT extension. | ||||||
| Usage: (macros-support-file-extension \"pb\" protobuf-mode)" | Usage: (macros-support-file-extension \"pb\" protobuf-mode)" | ||||||
|  |  | ||||||
|  | @ -20,7 +20,7 @@ | ||||||
| (require 'alist) | (require 'alist) | ||||||
| (require 'stack) | (require 'stack) | ||||||
| (require 'struct) | (require 'struct) | ||||||
| (require 'macros) | (require '>) | ||||||
| 
 | 
 | ||||||
| ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | ||||||
| ;; Create | ;; Create | ||||||
|  | @ -47,7 +47,7 @@ The newest bindings eclipse the oldest." | ||||||
|   "Push a new, empty scope onto XS." |   "Push a new, empty scope onto XS." | ||||||
|   (struct-update scope |   (struct-update scope | ||||||
|                  scopes |                  scopes | ||||||
|                  (>> (stack-push (alist-new))) |                  (>-> (stack-push (alist-new))) | ||||||
|                  xs)) |                  xs)) | ||||||
| 
 | 
 | ||||||
| ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | ||||||
|  | @ -75,7 +75,7 @@ The newest bindings eclipse the oldest." | ||||||
|   "Set value, V, at key, K, in XS for the current scope." |   "Set value, V, at key, K, in XS for the current scope." | ||||||
|   (struct-update scope |   (struct-update scope | ||||||
|                  scopes |                  scopes | ||||||
|                  (>> (stack-map-top (>> (alist-set k v)))) |                  (>-> (stack-map-top (>-> (alist-set k v)))) | ||||||
|                  xs)) |                  xs)) | ||||||
| 
 | 
 | ||||||
| ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | ||||||
|  |  | ||||||
|  | @ -18,14 +18,19 @@ | ||||||
| 
 | 
 | ||||||
| ;;; Code: | ;;; Code: | ||||||
| 
 | 
 | ||||||
| (require 'list) | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | ||||||
|  | ;; Dependencies | ||||||
|  | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | ||||||
| 
 | 
 | ||||||
| (cl-defstruct stack xs) | (require 'list) | ||||||
|  | (require '>) | ||||||
| 
 | 
 | ||||||
| ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | ||||||
| ;; Create | ;; Create | ||||||
| ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | ||||||
| 
 | 
 | ||||||
|  | (cl-defstruct stack xs) | ||||||
|  | 
 | ||||||
| (defun stack-new () | (defun stack-new () | ||||||
|   "Create an empty stack." |   "Create an empty stack." | ||||||
|   (make-stack :xs '())) |   (make-stack :xs '())) | ||||||
|  | @ -52,7 +57,7 @@ | ||||||
|   "Push `X' on `XS'." |   "Push `X' on `XS'." | ||||||
|   (struct-update stack |   (struct-update stack | ||||||
|                  xs |                  xs | ||||||
|                  (>> (list-cons x)) |                  (>-> (list-cons x)) | ||||||
|                  xs)) |                  xs)) | ||||||
| 
 | 
 | ||||||
| ;; TODO: How to return something like {(list-head xs), (list-tail xs)} in Elixir | ;; 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'." | look at the first element, use `stack-peek' before running `stack-pop'." | ||||||
|   (struct-update stack |   (struct-update stack | ||||||
|                  xs |                  xs | ||||||
|                  (>> list-tail) |                  (>-> list-tail) | ||||||
|                  xs)) |                  xs)) | ||||||
| 
 | 
 | ||||||
| (defun stack-map-top (f xs) | (defun stack-map-top (f xs) | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue