Permalink
Browse files

Use NAMED-READTABLES to replace (clesh:enable) with

(named-readtables:in-readtables clesh:syntax).
  • Loading branch information...
1 parent a106f7c commit 393b75e6621a58d4aabc1642d310825667e257f5 @daimrod daimrod committed Jan 26, 2012
Showing with 30 additions and 19 deletions.
  1. +11 −5 clesh.asd
  2. +19 −14 clesh.lisp
View
@@ -2,13 +2,19 @@
:serial t
:author "Christian von Essen <christian@mvonessen.de>"
:license "FreeBSD (see LICENSE)"
- :depends-on (#:trivial-shell)
+ :depends-on (#:trivial-shell
+ #:named-readtables)
:components ((:file "clesh"))
- :description ("Clesh is a very short program that provides mechanisms for running and composing Unix shell commands and constructs from Common Lisp.
+ :description ("Clesh is a very short program that provides
+ mechanisms for running and composing Unix shell commands and
+ constructs from Common Lisp.
-Essentially, it provides a '!' syntax that you can use to run commands and a '[]' embedded mode where you can enter bash scripts and obtain the standard output as a lisp string, and some other features.
+Essentially, it provides a '!' syntax that you can use to run commands
+and a '[]' embedded mode where you can enter bash scripts and obtain
+the standard output as a lisp string, and some other features.
-Lisp expressions can be included in any command or script using a '?' syntax.
+Lisp expressions can be included in any command or script using a '?'
+syntax.
Clesh works on every implementation of Common Lisp that is supported
-by trivial-shell."))
+by trivial-shell."))
View
@@ -44,12 +44,18 @@
;;;; #[ My standard output: ?*standard-output* ]#
;;;; instead because then we will have a space in the end of the returned string.
-(defpackage clesh
- (:use cl trivial-shell)
- (:nicknames clsh)
- (:export lines-to-list script *shell* enable))
-
-(in-package clesh)
+(defpackage #:clesh
+ (:use #:cl
+ #:trivial-shell
+ #:named-readtables)
+ (:nicknames #:clsh)
+ (:export #:lines-to-list
+ #:script
+ #:*shell*
+ #:enable
+ #:syntax))
+
+(in-package #:clesh)
(defparameter *shell* "/bin/sh"
"Program to use to execute shell commands.")
@@ -192,11 +198,10 @@ will be read as (\"asd foo \" (+ 2 2) \" bar \" (+ 3 3))."
(declare (ignore char1 char2))
(list 'quote (cons 'mixed-template (read-interpolated-string stream #\# #\}))))
-(defun enable (&optional (copy-readtable t))
- "Enable the reader macros in the current readtable (specified by *READTABLE*)"
- (when copy-readtable
- (setf *readtable* (copy-readtable)))
- (set-macro-character #\! #'simple-shell-escape-reader nil)
- (set-macro-character #\[ #'embedded-shell-escape-reader nil)
- (set-dispatch-macro-character #\# #\[ #'template-escape-reader)
- (set-dispatch-macro-character #\# #\{ #'storable-template-escape-reader))
+(defreadtable clesh:syntax
+ (:merge :standard)
+ (:macro-char #\! #'simple-shell-escape-reader nil)
+ (:macro-char #\[ #'embedded-shell-escape-reader nil)
+ (:dispatch-macro-char #\# #\[ #'template-escape-reader)
+ (:dispatch-macro-char #\# #\{ #'storable-template-escape-reader))
+

0 comments on commit 393b75e

Please sign in to comment.