~nytpu/nytpu.lisp-utils

fc8fa0023a5cddca41941a7828c30c6693aa09f4 — nytpu 7 days ago 5610ae3 master
nytpu.lisp-utils, shorthand-lambdas: fix ENABLE-* bugs
2 files changed, 10 insertions(+), 8 deletions(-)

M nytpu.lisp-utils.lisp
M shorthand-lambdas.lisp
M nytpu.lisp-utils.lisp => nytpu.lisp-utils.lisp +8 -6
@@ 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)."

M shorthand-lambdas.lisp => shorthand-lambdas.lisp +2 -2
@@ 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)))

#|