>From 4be7abaa0af33936b62119732609a1d4ff8ee1b4 Mon Sep 17 00:00:00 2001 From: Jeremy Bryant Date: Tue, 23 Apr 2024 22:21:07 +0100 Subject: [PATCH] Add Macrostep section in manual Macrostep is an Emacs Lisp macro-expander useful for exploring and writing macros. This is based on Jonathan's Oddie's documentation in the macrostep package. * doc/emacs/programs.texi (Programs): Add Macrostep section. * doc/emacs/emacs.texi (Top): Add detailed menu reference. --- doc/emacs/emacs.texi | 3 ++ doc/emacs/programs.texi | 61 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 64 insertions(+) diff --git a/doc/emacs/emacs.texi b/doc/emacs/emacs.texi index 7d77f13ab21..2ce47dd6e5e 100644 --- a/doc/emacs/emacs.texi +++ b/doc/emacs/emacs.texi @@ -694,6 +694,9 @@ Top @ifnottex * Fortran:: Fortran mode and its special features. @end ifnottex +@ifnottex +* Macrostep:: Interactive Emacs Lisp macro-expander. +@end ifnottex Top-Level Definitions, or Defuns diff --git a/doc/emacs/programs.texi b/doc/emacs/programs.texi index de28a9f1dd4..8c8542cc374 100644 --- a/doc/emacs/programs.texi +++ b/doc/emacs/programs.texi @@ -45,6 +45,10 @@ Programs @ifnottex * Fortran:: Fortran mode and its special features. @end ifnottex +@ifnottex +* Macrostep:: Interactive Emacs Lisp macro-expander. +@end ifnottex + @end menu @node Program Modes @@ -2235,3 +2239,60 @@ Asm Mode @ifnottex @include fortran-xtra.texi @end ifnottex + +@ifnottex +@node Macrostep +@section Macrostep: interactive Emacs Lisp macro-expander + +You can use @code{macrostep-mode} to explore Lisp macro definitions, and +help write new macros, using @kbd{M-x macrostep-expand} when point is +in a macro. + +@code{macrostep-mode} is a minor mode for interactively stepping through the +expansion of macros in Emacs Lisp source code. It lets you see exactly +what happens at each step of the expansion process by pretty-printing +the expanded forms inline in the source buffer, which is temporarily +read-only while macro expansions are visible. You can expand and +collapse macro forms one step at a time, and evaluate or instrument the +expansions for debugging with Edebug as usual. Single-stepping through +the expansion is particularly useful for debugging macros that expand +into another macro form. These can be difficult to debug with +@code{macroexpand}, which continues expansion until the top-level form +is no longer a macro call. + +The standard keybindings in @code{macrostep-mode} are the following: +@table @kbd +@findex macrostep-expand +@item e +@itemx = +@itemx RET +Expand the macro form following point one step (@code{macrostep-expand}). +@findex macrostep-collapse +@item c +@itemx u +@itemx DEL +Collapse the form following point (@code{macrostep-collapse}). +@findex macrostep-next-macro +@item n +@itemx TAB +Jump to the next macro form in the expansion (@code{macrostep-next-macro}). +@findex macrostep-previous-macro +@item p +@itemx M-TAB +Jump to the previous macro form in the expansion (@code{macrostep-previous-macro}). +@findex macrostep-collapse-all +@item q +@itemx C-c C-c +Collapse all expanded forms and exit macrostep-mode (@code{macrostep-collapse-all}). +@end table + +It's not very useful to enable and disable macrostep-mode directly. +Instead, bind @code{macrostep-expand} to a key in +@code{emacs-lisp-mode-map}, for example @kbd{C-c e}. + +You can then enter @code{macrostep-mode} and expand a macro form +completely by typing @kbd{C-c e e e@dots{}} as many times as necessary. + +Exit macrostep-mode by typing @kbd{q} or @kbd{C-c C-c}, or by +successively typing @kbd{c} to collapse all surrounding expansions. +@end ifnottex -- 2.42.0