0370a4bc53be

Merge
[view raw] [browse files]
author Steve Losh <steve@stevelosh.com>
date Mon, 29 Mar 2021 20:30:15 -0400
parents c815c49ae234 (diff) abb473227306 (current diff)
children 782d9fce020f
branches/tags (none)
files

Changes

--- a/lisp/Makefile	Mon Mar 29 11:34:42 2021 -0400
+++ b/lisp/Makefile	Mon Mar 29 20:30:15 2021 -0400
@@ -1,4 +1,4 @@
-files := $(shell ls *.lisp)
+files := $(wildcard *.lisp)
 names := $(files:.lisp=)
 
 .PHONY: all clean $(names)
@@ -7,14 +7,14 @@
 
 $(names): %: bin/% man/man1/%.1
 
-bin/%: %.lisp build-binary
+bin/%: %.lisp build-binary.sh Makefile
 	mkdir -p bin
-	./build-binary $<
+	./build-binary.sh $<
 	mv $(@F) bin/
 
-man/man1/%.1: %.lisp build-manual
+man/man1/%.1: %.lisp build-manual.sh Makefile
 	mkdir -p man/man1
-	./build-manual $<
+	./build-manual.sh $<
 	mv $(@F) man/man1/
 
 clean:
--- a/lisp/batchcolor.lisp	Mon Mar 29 11:34:42 2021 -0400
+++ b/lisp/batchcolor.lisp	Mon Mar 29 20:30:15 2021 -0400
@@ -8,34 +8,8 @@
 (in-package :batchcolor)
 
 ;;;; Configuration ------------------------------------------------------------
-(defparameter *version* "1.0.0")
 (defparameter *start* 0)
 (defparameter *dark* t)
-(defparameter *only-matching* nil)
-
-
-;;;; Colors -------------------------------------------------------------------
-(defun rgb-code (r g b)
-  ;; The 256 color mode color values are essentially r/g/b in base 6, but
-  ;; shifted 16 higher to account for the intiial 8+8 colors.
-  (+ (* r 36)
-     (* g 6)
-     (* b 1)
-     16))
-
-(defun make-colors (excludep)
-  (let ((result (make-array 256 :fill-pointer 0)))
-    (dotimes (r 6)
-      (dotimes (g 6)
-        (dotimes (b 6)
-          (unless (funcall excludep (+ r g b))
-            (vector-push-extend (rgb-code r g b) result)))))
-    result))
-
-(defparameter *dark-colors*  (make-colors (lambda (v) (< v 3))))
-(defparameter *light-colors* (make-colors (lambda (v) (> v 11))))
-
-(defparameter *explicits* (make-hash-table :test #'equal))
 
 
 ;;;; Errors -------------------------------------------------------------------
@@ -60,6 +34,29 @@
 
 
 ;;;; Functionality ------------------------------------------------------------
+(defun rgb-code (r g b)
+  ;; The 256 color mode color values are essentially r/g/b in base 6, but
+  ;; shifted 16 higher to account for the intiial 8+8 colors.
+  (+ (* r 36)
+     (* g 6)
+     (* b 1)
+     16))
+
+(defun make-colors (excludep)
+  (let ((result (make-array 256 :fill-pointer 0)))
+    (dotimes (r 6)
+      (dotimes (g 6)
+        (dotimes (b 6)
+          (unless (funcall excludep (+ r g b))
+            (vector-push-extend (rgb-code r g b) result)))))
+    result))
+
+(defparameter *dark-colors*  (make-colors (lambda (v) (< v 3))))
+(defparameter *light-colors* (make-colors (lambda (v) (> v 11))))
+
+(defparameter *explicits* (make-hash-table :test #'equal))
+
+
 (defun djb2 (string)
   ;; http://www.cse.yorku.ca/~oz/hash.html
   (reduce (lambda (hash c)
@@ -101,8 +98,7 @@
                  (print-colorized (subseq line word-start word-end))
                  (setf start word-end))
            starts ends)))
-  (unless (and (zerop start) *only-matching*)
-    (write-line line *standard-output* :start start))
+  (write-line line *standard-output* :start start)
   (values))
 
 
@@ -156,13 +152,6 @@
     :help-no "Optimize for light terminals."
     :initial-value t))
 
-(adopt:defparameters (*option-only-matching* *option-no-only-matching*)
-  (adopt:make-boolean-options 'only-matching
-    :long "only-matching"
-    :long-no "all-lines"
-    :short #\o
-    :help "Only print lines with at least one match."
-    :help-no "Print all lines, even if they don't have any matches (the default)."))
 
 (defparameter *option-explicit*
   (adopt:make-option 'explicit
@@ -185,12 +174,6 @@
     :short #\h
     :reduce (constantly t)))
 
-(defparameter *option-version*
-  (adopt:make-option 'version
-    :help "Display version information and exit."
-    :long "version"
-    :reduce (constantly t)))
-
 
 (adopt:define-string *help-text*
   "batchcolor takes a regular expression and matches it against standard ~
@@ -219,8 +202,8 @@
      . "tail -f /var/log/foo | batchcolor '[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}'")
     ("Colorize some keywords explicitly and IPv4 addresses randomly (note that the keywords have to be in the main regex too, not just in the -e options):"
      . "batchcolor 'WARN|INFO|ERR|(?:[0-9]{1,3}\\\\.){3}[0-9]{1,3}' -e '5,0,0:ERR' -e '5,4,0:WARN' -e '2,2,5:INFO' foo.log")
-    ("Colorize earmuffed symbols in a Lisp file, only printing lines with at least one such symbol:"
-     . "batchcolor --only-matching '(?:^|[^*])([*][-a-zA-Z0-9]+[*])(?:$|[^*])' tests/test.lisp")))
+    ("Colorize earmuffed symbols in a Lisp file:"
+     . "batchcolor '(?:^|[^*])([*][-a-zA-Z0-9]+[*])(?:$|[^*])' tests/test.lisp")))
 
 
 (defparameter *ui*
@@ -229,11 +212,10 @@
     :usage "[OPTIONS] REGEX [FILE...]"
     :summary "colorize regex matches in batches"
     :help *help-text*
-    :manual (concatenate 'string *help-text* (format nil "~2%") *extra-manual-text*)
+    :manual (format nil "~A~2%~A" *help-text* *extra-manual-text*)
     :examples *examples*
     :contents (list
                 *option-help*
-                *option-version*
                 *option-debug*
                 *option-no-debug*
                 (adopt:make-group 'color-options
@@ -242,11 +224,7 @@
                                                  *option-no-randomize*
                                                  *option-dark*
                                                  *option-light*
-                                                 *option-explicit*))
-                (adopt:make-group 'output-options
-                                  :title "Output Options"
-                                  :options (list *option-only-matching*
-                                                 *option-no-only-matching*)))))
+                                                 *option-explicit*)))))
 
 
 (defmacro exit-on-ctrl-c (&body body)
@@ -259,8 +237,7 @@
   (setf *start* (if (gethash 'randomize options)
                   (random 256 (make-random-state t))
                   0)
-        *dark* (gethash 'dark options)
-        *only-matching* (gethash 'only-matching options)))
+        *dark* (gethash 'dark options)))
 
 (defun toplevel ()
   (sb-ext:disable-debugger)
@@ -271,7 +248,6 @@
       (handler-case
           (cond
             ((gethash 'help options) (adopt:print-help-and-exit *ui*))
-            ((gethash 'version options) (write-line *version*) (adopt:exit))
             ((null arguments) (error 'missing-regex))
             (t (destructuring-bind (pattern . files) arguments
                  (configure options)
--- a/lisp/build-binary	Mon Mar 29 11:34:42 2021 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,9 +0,0 @@
-#!/usr/bin/env bash
-
-set -euo pipefail
-
-LISP=$1
-BINARY=$(basename "$1" .lisp)
-shift
-
-sbcl --load "$LISP" --eval "(sb-ext:save-lisp-and-die \"$BINARY\" :executable t :save-runtime-options t :toplevel '$BINARY:toplevel)" "$@"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/lisp/build-binary.sh	Mon Mar 29 20:30:15 2021 -0400
@@ -0,0 +1,13 @@
+#!/usr/bin/env bash
+
+set -euo pipefail
+
+LISP=$1
+NAME=$(basename "$1" .lisp)
+shift
+
+sbcl --load "$LISP" \
+    --eval "(sb-ext:save-lisp-and-die \"$NAME\"
+              :executable t
+              :save-runtime-options t
+              :toplevel '$NAME:toplevel)"
--- a/lisp/build-manual	Mon Mar 29 11:34:42 2021 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,10 +0,0 @@
-#!/usr/bin/env bash
-
-set -euo pipefail
-
-LISP=$1
-NAME=$(basename "$LISP" .lisp)
-OUT="$NAME.1"
-shift
-
-sbcl --disable-debugger --load "$LISP" --eval "(with-open-file (f \"$OUT\" :direction :output :if-exists :supersede) (adopt:print-manual $NAME:*ui* :stream f))" --quit "$@"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/lisp/build-manual.sh	Mon Mar 29 20:30:15 2021 -0400
@@ -0,0 +1,13 @@
+#!/usr/bin/env bash
+
+set -euo pipefail
+
+LISP=$1
+NAME=$(basename "$LISP" .lisp)
+OUT="$NAME.1"
+shift
+
+sbcl --load "$LISP" \
+    --eval "(with-open-file (f \"$OUT\" :direction :output :if-exists :supersede)
+              (adopt:print-manual $NAME:*ui* :stream f))" \
+    --quit
--- a/vim/custom-dictionary.utf-8.add	Mon Mar 29 11:34:42 2021 -0400
+++ b/vim/custom-dictionary.utf-8.add	Mon Mar 29 20:30:15 2021 -0400
@@ -312,3 +312,4 @@
 lifecycle
 unapplied
 reimplementations
+UUIDs