Skip to content

Improve the macroexpansion module#3971

Merged
bbatsov merged 3 commits into
masterfrom
improve-macroexpansion
Jun 18, 2026
Merged

Improve the macroexpansion module#3971
bbatsov merged 3 commits into
masterfrom
improve-macroexpansion

Conversation

@bbatsov

@bbatsov bbatsov commented Jun 18, 2026

Copy link
Copy Markdown
Member

A pass over the separate-buffer macroexpansion module (cider-macroexpansion.el) - a real bug fix, a UX addition, its first tests, and doc updates. (The inline macrostep work in #3970 is kept entirely separate.)

Bug fix

  • cider-macroexpand-again (g in the macroexpansion buffer) stored the input form and passed it to the buffer as if it were the expansion, so it redisplayed the original instead of re-expanding. It now remembers the expander and re-runs the expansion (picking up macro redefinitions and display-option changes), and errors cleanly when nothing has been expanded yet.

UX

  • New n and t keys (and menu entries) in the macroexpansion buffer: cycle cider-macroexpansion-display-namespaces (tidy -> qualified -> none) and toggle cider-macroexpansion-print-metadata, re-expanding in place - so you can see the same expansion with/without namespaces or metadata without reconfiguring and re-running.

Tidy

  • Removed a spurious (interactive) from the cider-macroexpand-expr-inplace helper (it requires an expander arg, so it was never validly interactive).

Tests + docs

  • The module had no tests; added a basic suite (the cider/macroexpand request construction + error handling, the again re-expansion regression, the toggle/cycle commands, region redraw, keymap). Documented the new keys and clarified the g behavior in macroexpansion.adoc.

bbatsov added 3 commits June 18, 2026 16:28
- Fix cider-macroexpand-again (g): it passed the original input form to the
  buffer as if it were the expansion, so it redisplayed the input instead of
  re-expanding. Store the expander and actually re-expand; error when there is
  nothing to repeat.
- Add n / t in the macroexpansion buffer to cycle namespace display and toggle
  metadata, re-expanding in place, plus matching menu entries.
- Drop a spurious (interactive) from the cider-macroexpand-expr-inplace helper,
  which requires an expander argument.
- Add the module's first test suite and document the new keys.
Display the active expander and the current namespace/metadata display
options, plus a reminder of the buffer's key bindings, so the state the new
n/t toggles control is visible at a glance and the keys are discoverable.
The in-place expansion commands (m/a) re-expanded the sexp before point; make
them target the form at point instead, so you can put point on a nested macro
call in the expansion and drill into just that node (SLIME-style). This also
makes the behavior match what the docs already described.
@bbatsov bbatsov merged commit b395760 into master Jun 18, 2026
13 checks passed
@bbatsov bbatsov deleted the improve-macroexpansion branch June 18, 2026 13:52
bbatsov added a commit that referenced this pull request Jun 18, 2026
Make the in-place expansion commands (m/a) target the sexp before point, like
the entry commands and cider-macrostep, instead of the form at point. This
restores a single, consistent CIDER convention across all macroexpansion
entry points (the at-point variant from #3971 was inconsistent with the rest).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant