From fc8fa0023a5cddca41941a7828c30c6693aa09f4 Mon Sep 17 00:00:00 2001 From: nytpu Date: Sat, 28 Sep 2024 16:50:40 -0600 Subject: [PATCH] nytpu.lisp-utils, shorthand-lambdas: fix ENABLE-* bugs --- nytpu.lisp-utils.lisp | 14 ++++++++------ shorthand-lambdas.lisp | 4 ++-- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/nytpu.lisp-utils.lisp b/nytpu.lisp-utils.lisp index 6b6b423..5db8e86 100644 --- a/nytpu.lisp-utils.lisp +++ b/nytpu.lisp-utils.lisp @@ -40,7 +40,7 @@ ;; VALUES with no arguments instead of just NIL to truly omit any expression. (values)) -(defun enable-commented-sexps (&optional (copy-readtable t)) +(defmacro enable-commented-sexps (&optional (copy-readtable t)) "Enable the #; reader macro character to comment a full s-expression. If COPY-READTABLE is T, then *READTABLE* will be copied with COPY-READTABLE before adding the reader macro. @@ -48,8 +48,8 @@ When enabled, prefixing any form (s-expression or atom) with #; will comment it form must be valid according to the reader (albiet with *READ-SUPPRESS* true), but is otherwise not parsed in any way." `(eval-when (:compile-toplevel :load-toplevel :execute) - (when copy-readtable - (setf *readtable* (copy-readtable))) + ,(when copy-readtable + '(setf *readtable* (copy-readtable))) (set-dispatch-macro-character #\# #\; #'commented-sexp-reader))) #| @@ -267,13 +267,15 @@ new syntax." `(progn (enable-commented-sexps ,copy-readtable) ;; handle if SHORTHAND-LAMBDAS isn't loaded - ,(when (find-package ,(string '#:nytpu.lisp-utils.shorthand-lambdas)) + ,(when (find-package (string '#:nytpu.lisp-utils.shorthand-lambdas)) ;; no COPY-READTABLE because ENABLE-COMMENTED-SEXPS already copied it once, no need to do it ;; again - `(,(find-symbol ,(string '#:enable-shorthand-lambdas) - ,(string '#:nytpu.lisp-utils.shorthand-lambdas)) + `(,(find-symbol (string '#:enable-shorthand-lambdas) + (string '#:nytpu.lisp-utils.shorthand-lambdas)) nil)))) +(macroexpand-1 '(enable-syntaxes)) + (defmacro togglef (&rest places) "Given a list of places, expand to a SETF form consisting of each place being set to (NOT place)." diff --git a/shorthand-lambdas.lisp b/shorthand-lambdas.lisp index 297f3fc..5ad38db 100644 --- a/shorthand-lambdas.lisp +++ b/shorthand-lambdas.lisp @@ -115,8 +115,8 @@ Examples: (^(list $ $ 'c $ $2 $1) 'a 'b 'd) ; → (a b c d b a)" `(eval-when (:compile-toplevel :load-toplevel :execute) - (when copy-readtable - (setf *readtable* (copy-readtable))) + ,(when copy-readtable + '(setf *readtable* (copy-readtable))) (set-macro-character #\^ #'shorthand-lambda-reader))) #| -- 2.45.2