Hello,<br><br>I've modified the code as follows (also not yet corrected the tilde bug) : <br>What you can see is that insted of restoring the full initial readtable, I only restore the #\" macro character previous function (the one I have overriden with (start). This way, I do not reset other -possible- personalized macro character functions.
<br>I also provide a (stop) method which restores the previous #\" macro character.<br><br>I also twiked the main function in order to let the initial string unchanged in case no ${} is used (usefull for a lot of macros that only accept raw strings, such as defpackage, ...).
<br><br>Please let me know if you think this would not work in a case I haven't seen.<br><br>The code follows :<br><br>(defpackage "ENHANCED-STRINGS"<br> (:USE "COMMON-LISP")<br> (:EXPORT "START")
<br> (:EXPORT "STOP"))<br><br>(in-package "ENHANCED-STRINGS")<br><br>(defun parse-enhanced-string (string)<br> (loop<br> :with chunks = '()<br> :with args = '()<br> :with start = 0<br> :for pos = (search "${" string :start2 start)
<br> :for end = (and pos (search "}" string :start2 pos))<br> :while end<br> :do (progn<br> (push (subseq string start pos) chunks)<br> (multiple-value-bind (form next)<br> (read-from-string string t nil :start (+ 2 pos) :end end)
<br> (loop :while (and (< next end)<br> (member (aref string next) '(#\space #\newline)))<br> :do (incf next))<br> (unless (= next end)<br> (error "Junk in ~S" (subseq string pos end)))
<br> (push form args))<br> (setf start (1+ end)))<br> :finally (progn<br> (push (subseq string start) chunks)<br> (if (rest chunks)<br> (return `(format nil ,(format nil "~{~A~^~~A~}" (nreverse chunks))
<br> ,@(nreverse args))))<br> (return string))))<br><br>(defun reader-macro--enhanced-string (stream dblquote)<br> (let ((*readtable* (copy-readtable)))<br> (set-macro-character #\" (get-old-macro-character))
<br> (unread-char dblquote stream)<br> (parse-enhanced-string (read stream t nil t))))<br><br>(let ((old-macro-character nil))<br> (defun start ()<br> (unless old-macro-character<br> (setf old-macro-character (get-macro-character #\"))
<br> (set-macro-character #\" #'reader-macro--enhanced-string)))<br> (defun stop ()<br> (when old-macro-character<br> (set-macro-character #\" old-macro-character)<br> (setf old-macro-character nil)))
<br> (defun get-old-macro-character ()<br> old-macro-character))<br>