Teach format_menu about menu_stack

The menu stack and format_menu are tightly coupled. Mutating the stack
directly in format_menu simplifies its use without significantly
complicating the use of multiple stacks.