c6afac579697

More
[view raw] [browse files]
author Steve Losh <steve@stevelosh.com>
date Thu, 20 Dec 2018 17:11:06 -0500
parents 6ee2d1d3d487
children e3f5572c7738
branches/tags (none)
files .hgignore lisp/Makefile lisp/binaries/.placeholder lisp/build-binary lisp/build-manual lisp/clhs.lisp lisp/compile lispwords

Changes

--- a/.hgignore	Wed Dec 19 18:49:56 2018 -0500
+++ b/.hgignore	Thu Dec 20 17:11:06 2018 -0500
@@ -43,5 +43,6 @@
 vim/bundle/simple-scala
 vim/bundle/LanguageClient-neovim
 weechat/sec.conf
-lisp/binaries
+lisp/bin
+lisp/man
 mutt/accounts
--- a/lisp/Makefile	Wed Dec 19 18:49:56 2018 -0500
+++ b/lisp/Makefile	Thu Dec 20 17:11:06 2018 -0500
@@ -1,11 +1,26 @@
-.PHONY: all
+files := $(shell ls *.lisp)
+binaries := $(files:.lisp=)
+
+.PHONY: all $(binaries)
 
-all: binaries/clhs binaries/lispindent
+all: $(binaries)
+
+%: bin/% man/%.1
+	echo
+
+clean:
+	rm -rf bin man
 
-binaries/clhs: clhs.lisp compile
-	./compile clhs.lisp
-	mv clhs binaries/clhs
+bin/%: %.lisp bin build-binary
+	./build-binary $<
+	mv $(@F) bin/
 
-binaries/lispindent: lispindent.lisp compile
-	./compile lispindent.lisp --no-userinit
-	mv lispindent binaries/lispindent
+man/%.1: %.lisp man build-manual
+	./build-manual $<
+	mv $(@F) man/
+
+bin:
+	mkdir -p bin
+
+man:
+	mkdir -p man
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/lisp/build-binary	Thu Dec 20 17:11:06 2018 -0500
@@ -0,0 +1,9 @@
+#!/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 'toplevel)" "$@"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/lisp/build-manual	Thu Dec 20 17:11:06 2018 -0500
@@ -0,0 +1,10 @@
+#!/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 *ui* :stream f))" --quit "$@"
--- a/lisp/clhs.lisp	Wed Dec 19 18:49:56 2018 -0500
+++ b/lisp/clhs.lisp	Thu Dec 20 17:11:06 2018 -0500
@@ -1,6 +1,9 @@
 ;; Based on https://gist.github.com/fukamachi/3510ea1609c1b52830c2
 
-(ql:quickload '(:adopt :drakma :plump :clss :alexandria))
+(eval-when (:compile-toplevel :load-toplevel :execute)
+  (ql:quickload '(:adopt :drakma :plump :clss :alexandria)
+                :silent t))
+
 
 ;;;; Config -------------------------------------------------------------------
 (defparameter *default-hyperspec-url* "http://www.lispworks.com/documentation/HyperSpec/")
@@ -93,23 +96,50 @@
 
 
 ;;;; User Interface -----------------------------------------------------------
-(adopt:define-interface *ui* "SYMBOL"
-  "Look up SYMBOL in the hyperspec and open it in a web browser."
-  ((help) "display help and exit"
+(adopt:define-interface *ui*
+    (:name "clhs"
+     :usage "[OPTIONS] SYMBOL"
+     :summary "Look up a symbol in the Common Lisp HyperSpec."
+     :documentation
+     (format nil "Look up SYMBOL in the Common Lisp HyperSpec and open it in a web browser.~@
+       ~@
+       The first time the program is run it will create a cache of all symbols in the HyperSpec.  Subsequent runs will use this cache to look up symbol links faster.")
+     :examples
+     '(("Look up STRING in the HyperSpec and open it in the default browser:" .
+        "clhs string")
+       ("Look up MAKE-ARRAY in a local copy of the HyperSpec and open it in lynx:" .
+        "clhs --url file:///home/sjl/doc/hyperspec/ --open lynx make-array")))
+  ((help)
+   :documentation "display help and exit"
+   :manual "Display help and exit."
    :long "help"
    :short #\h
    :reduce (constantly t))
-  ((rebuild-cache) "rebuild the symbol cache, even if it already exists"
+  ((rebuild-cache)
+   :documentation "rebuild the symbol cache, even if it already exists"
+   :manual "Rebuild the symbol cache, even if it already exists."
    :long "rebuild-cache"
    :reduce (constantly t))
-  ((open) (format nil "program to use to open hyperspec URLs (default ~A)"
-                  *default-open-command*)
+  ((open)
+   :documentation
+   (format nil "program to use to open hyperspec URLs (default ~A)"
+           *default-open-command*)
+   :manual
+   (format nil "The program to use to open hyperspec URLs.  The default is: ~A"
+           *default-open-command*)
    :long "open"
    :short #\o
    :parameter "COMMAND"
    :initial-value *default-open-command*
    :reduce #'adopt:newest)
-  ((url) (format nil "base Hyperspec URL (default ~A)" *default-hyperspec-url*)
+  ((url)
+   :documentation
+   (format nil "base HyperSpec URL (default ~A)" *default-hyperspec-url*)
+   :manual
+   (format nil "The base HyperSpec URL.  The default is: ~A~@
+           ~@
+           A local copy of the HyperSpec can be used with a file:// prefix."
+           *default-hyperspec-url*)
    :long "url"
    :short #\u
    :parameter "URL"
--- a/lisp/compile	Wed Dec 19 18:49:56 2018 -0500
+++ /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 'toplevel)" "$@"
--- a/lispwords	Wed Dec 19 18:49:56 2018 -0500
+++ b/lispwords	Thu Dec 20 17:11:06 2018 -0500
@@ -116,3 +116,6 @@
 
 ; stumpwm
 (3 defcommand)
+
+; adopt
+(2 define-interface)