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 | ||||
| ;; 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 'macros) | ||||
| (require 'dash) | ||||
| (require 'tuple) | ||||
| (require 'maybe) | ||||
| 
 | ||||
| ;;; Code: | ||||
| 
 | ||||
| ;; TODO: Support function aliases for: | ||||
| ;; - create/set | ||||
| ;; - read/get | ||||
|  |  | |||
|  | @ -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)) | ||||
| 
 | ||||
|  |  | |||
|  | @ -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.") | ||||
| 
 | ||||
|  |  | |||
|  | @ -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.") | ||||
|  |  | |||
|  | @ -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)" | ||||
|  |  | |||
|  | @ -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)) | ||||
| 
 | ||||
| ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | ||||
|  |  | |||
|  | @ -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) | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue