--- a/bash_profile Thu Dec 20 17:11:06 2018 -0500
+++ b/bash_profile Thu Dec 20 23:55:17 2018 -0500
@@ -15,7 +15,7 @@
fi
}
-export PATH=~/bin:~/src/dotfiles/bin:~/src/dotfiles/lisp/binaries:/usr/local/share/python:/usr/local/bin/:$PATH
+export PATH=~/bin:~/src/dotfiles/bin:~/src/dotfiles/lisp/bin:/usr/local/share/python:/usr/local/bin/:$PATH
alias h='hg'
alias g='git'
--- a/bin/clhs Thu Dec 20 17:11:06 2018 -0500
+++ b/bin/clhs Thu Dec 20 23:55:17 2018 -0500
@@ -2,4 +2,4 @@
set -euo pipefail
-~/src/dotfiles/lisp/binaries/clhs --url "file:///home/sjl/Dropbox/HyperSpec/HyperSpec/" --open "w3m" "$@"
+~/src/dotfiles/lisp/bin/clhs --url "file:///home/sjl/Dropbox/HyperSpec/HyperSpec/" --open "w3m" "$@"
--- a/fish/config.fish Thu Dec 20 17:11:06 2018 -0500
+++ b/fish/config.fish Thu Dec 20 23:55:17 2018 -0500
@@ -81,7 +81,7 @@
prepend_to_path "/usr/local/go/bin"
prepend_to_path "/usr/local/sbin"
prepend_to_path "/usr/games"
-prepend_to_path "$HOME/src/dotfiles/lisp/binaries"
+prepend_to_path "$HOME/src/dotfiles/lisp/bin"
prepend_to_path "$HOME/src/dotfiles/bin"
prepend_to_path "$HOME/src/hg"
prepend_to_path "$HOME/bin"
--- a/lisp/Makefile Thu Dec 20 17:11:06 2018 -0500
+++ b/lisp/Makefile Thu Dec 20 23:55:17 2018 -0500
@@ -1,26 +1,21 @@
files := $(shell ls *.lisp)
-binaries := $(files:.lisp=)
+names := $(files:.lisp=)
+
+.PHONY: all clean $(names)
-.PHONY: all $(binaries)
+all: $(names)
+
+$(names): %: bin/% man/man1/%.1
-all: $(binaries)
+bin/%: %.lisp build-binary
+ mkdir -p bin
+ ./build-binary $<
+ mv $(@F) bin/
-%: bin/% man/%.1
- echo
+man/man1/%.1: %.lisp build-manual
+ mkdir -p man/man1
+ ./build-manual $<
+ mv $(@F) man/man1/
clean:
rm -rf bin man
-
-bin/%: %.lisp bin build-binary
- ./build-binary $<
- mv $(@F) bin/
-
-man/%.1: %.lisp man build-manual
- ./build-manual $<
- mv $(@F) man/
-
-bin:
- mkdir -p bin
-
-man:
- mkdir -p man
--- a/lisp/clhs.lisp Thu Dec 20 17:11:06 2018 -0500
+++ b/lisp/clhs.lisp Thu Dec 20 23:55:17 2018 -0500
@@ -96,19 +96,28 @@
;;;; User Interface -----------------------------------------------------------
+(defmacro define-string (var string)
+ `(defparameter ,var (format nil ,string)))
+
+(define-string *documentation*
+ "Look up SYMBOL in the Common Lisp HyperSpec and open its page 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.")
+
+(defparameter *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")))
+
(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")))
+ :documentation *documentation*
+ :examples *examples*)
((help)
:documentation "display help and exit"
:manual "Display help and exit."
@@ -116,30 +125,25 @@
:short #\h
:reduce (constantly t))
((rebuild-cache)
- :documentation "rebuild the symbol cache, even if it already exists"
- :manual "Rebuild the symbol cache, even if it already exists."
+ :documentation "rebuild the symbol cache"
+ :manual "Rebuild the symbol cache, even if it already exists, instead of looking up a symbol."
:long "rebuild-cache"
:reduce (constantly t))
((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*)
+ :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)
- :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*)
+ :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/lispindent.lisp Thu Dec 20 17:11:06 2018 -0500
+++ b/lisp/lispindent.lisp Thu Dec 20 23:55:17 2018 -0500
@@ -1,6 +1,9 @@
;; Fork of lispindent https://github.com/ds26gte/scmindent
;; Some day I need to rewrite this with smug or something, jesus.
+(eval-when (:compile-toplevel :load-toplevel :execute)
+ (ql:quickload '(:adopt) :silent t))
+
;Dorai Sitaram
;Oct 8, 1999
@@ -253,7 +256,32 @@
(incf i))))))))
-(defun toplevel ()
+(defun run ()
(source-config-files)
(indent-lines)
t)
+
+(adopt:define-interface *ui*
+ (:name "lispindent"
+ :usage ""
+ :summary "Indent Common Lisp code."
+ :documentation (format nil
+ "Read Common Lisp code from standard input, indent ~
+ it according to some simple rules and configuration, ~
+ and write the result to standard output."))
+ ((help)
+ :documentation "display help and exit"
+ :manual "Display help and exit."
+ :long "help"
+ :short #\h
+ :reduce (constantly t)))
+
+(defun toplevel ()
+ (handler-case
+ (multiple-value-bind (arguments options) (adopt:parse-options *ui*)
+ (when (gethash 'help options)
+ (adopt:print-usage-and-exit *ui*))
+ (when arguments
+ (error "Unrecognized arguments: ~S" arguments))
+ (run))
+ (error (c) (adopt:print-error-and-exit c))))