Last active
December 24, 2015 17:39
-
-
Save fukamachi/6837386 to your computer and use it in GitHub Desktop.
Common Lisp script to open a HyperSpec HTML which corresponds to a specified symbol. (Works only with SBCL on Mac)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env sbcl --script | |
;; -*- mode: common-lisp -*- | |
;; Usage: | |
;; clhs [SYMBOL] | |
(require 'asdf) | |
(defparameter *hyperspec-home* | |
(merge-pathnames "Dropbox/Documents/HyperSpec/" (user-homedir-pathname)) | |
"Set a directory where HyperSpec HTML files are in.")) | |
(defun find-clhs-file (target-symbol) | |
(let ((map-sym-file (merge-pathnames "Data/Map_Sym.txt" *hyperspec-home*))) | |
(with-open-file (in map-sym-file | |
:direction :input) | |
(loop with eof = '#:end-of-file | |
for symbol = (read-line in nil eof) | |
for file = (read-line in nil eof) | |
until (eq symbol eof) | |
when (string-equal symbol target-symbol) | |
do (return (merge-pathnames file map-sym-file)))))) | |
(defun clhs (target-symbol) | |
(let ((file (find-clhs-file target-symbol))) | |
(if file | |
(progn | |
(format t "~&Opening ~A~%" file) | |
(asdf:run-shell-command "open ~A" file)) | |
(format *error-output* "~&Symbol not found: ~A~%" | |
target-symbol)))) | |
(let ((symbol (second sb-ext:*posix-argv*))) | |
(if symbol | |
(clhs symbol) | |
(format t "~&Usage: clhs [SYMBOL]~%"))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment