diff --git a/racket-stepper.el b/racket-stepper.el index b9ce42af..25dd4d7c 100644 --- a/racket-stepper.el +++ b/racket-stepper.el @@ -160,20 +160,22 @@ INTO-BASE is treated as a raw command prefix arg and converted to boolp." ,(and into-base t)) #'racket-stepper--insert))) -(defun racket-stepper--insert (steps) - (with-current-buffer (racket--stepper-buffer-name) - (let ((inhibit-read-only t)) - (goto-char (point-max)) - (dolist (step steps) - (pcase step - (`(original . ,text) - (delete-region (point-min) (point-max)) - (insert "Original\n" text "\n" "\n")) - (`(final . ,text) (insert "Final\n" text "\n")) - (`(,label . ,diff) (insert label "\n" diff "\n")))) - (racket-stepper-previous-item) - (when (equal (selected-window) (get-buffer-window (current-buffer))) - (recenter))))) +(defun racket-stepper--insert (nothing-or-steps) + (if (eq nothing-or-steps 'nothing) + (message "Nothing to expand") + (with-current-buffer (racket--stepper-buffer-name) + (let ((inhibit-read-only t)) + (goto-char (point-max)) + (dolist (step nothing-or-steps) + (pcase step + (`(original . ,text) + (delete-region (point-min) (point-max)) + (insert "Original\n" text "\n" "\n")) + (`(final . ,text) (insert "Final\n" text "\n")) + (`(,label . ,diff) (insert label "\n" diff "\n")))) + (racket-stepper-previous-item) + (when (equal (selected-window) (get-buffer-window (current-buffer))) + (recenter)))))) (defun racket-stepper-step (prefix) (interactive "P") diff --git a/racket/commands/macro.rkt b/racket/commands/macro.rkt index 613c474a..8de37d19 100644 --- a/racket/commands/macro.rkt +++ b/racket/commands/macro.rkt @@ -22,8 +22,10 @@ macro-stepper/next) (define step/c (cons/c (or/c 'original string? 'final) string?)) -(define step-proc/c (-> (or/c 'next 'all) (listof step/c))) +(define step-proc/c (-> (or/c 'next 'all) + (or/c 'nothing (listof step/c)))) (define step-proc #f) +(define (nothing-step-proc _) 'nothing) (define/contract (make-expr-stepper str) (-> string? step-proc/c) @@ -73,7 +75,7 @@ (stepper-text stx (if into-base? (λ _ #t) (not-in-base))))) (define step-num #f) - (define step-last-after "") + (define step-last-after (pretty-format-syntax stx)) (log-racket-mode-debug "~v ~v ~v" path into-base? raw-step) (define/contract (step what) step-proc/c (cond [(not step-num) @@ -131,11 +133,9 @@ (macro-stepper/next 'next)) (define/contract (macro-stepper/next what) step-proc/c - (unless step-proc - (error 'macro-stepper "Nothing to expand")) (define v (step-proc what)) (match v - [(list (cons 'final _)) (set! step-proc #f)] + [(list (cons 'final _)) (set! step-proc nothing-step-proc)] [_ (void)]) v)