From 31ad74e07ca4b77ffbfdc104b403efda61487e40 Mon Sep 17 00:00:00 2001 From: Matthias Benkard Date: Thu, 4 Dec 2008 21:17:37 +0100 Subject: Add function IN-METHOD-SYNTAX. darcs-hash:d988f9cdc21410c6910aa52e0f396a2ebc7216fb --- Lisp/defpackage.lisp | 1 + Lisp/reader-syntax.lisp | 15 +++++++++++---- 2 files changed, 12 insertions(+), 4 deletions(-) (limited to 'Lisp') diff --git a/Lisp/defpackage.lisp b/Lisp/defpackage.lisp index 074e8ab..3c560e5 100644 --- a/Lisp/defpackage.lisp +++ b/Lisp/defpackage.lisp @@ -25,6 +25,7 @@ #:shutdown-runtime #:install-reader-syntax #:enable-method-syntax + #:in-method-syntax #:enable-objective-c-syntax #:disable-method-syntax #:disable-objective-c-syntax diff --git a/Lisp/reader-syntax.lisp b/Lisp/reader-syntax.lisp index 18174d2..905807d 100644 --- a/Lisp/reader-syntax.lisp +++ b/Lisp/reader-syntax.lisp @@ -22,6 +22,16 @@ (defvar *bracket-syntax-macro-chars* (list)) +(defun in-method-syntax () + ;; FIXME: Document. + (setq *readtable* (copy-readtable *readtable*)) + (push (get-dispatch-macro-character #\# #\/) *method-syntax-macro-chars*) + (set-dispatch-macro-character #\# #\/ #'(lambda (stream char arg) + (declare (ignore char arg)) + (read-objective-c-method stream))) + (values)) + + (defun enable-method-syntax () "Install a **reader macro** that makes method calls look nicer. @@ -76,10 +86,7 @@ __selector__s registered by way of __collect-methods__. __enable-objective-c-syntax__" (save-readtable) - (push (get-dispatch-macro-character #\# #\/) *method-syntax-macro-chars*) - (set-dispatch-macro-character #\# #\/ #'(lambda (stream char arg) - (declare (ignore char arg)) - (read-objective-c-method stream))) + (in-method-syntax) (values)) -- cgit v1.2.3