(Note: This patch is identical to my previous submission, but with
the attachment filename extension changed from .patch to .patch.txt.)
Attached (sorry, GMail) please find a one-character patch to fix a
prompt-previewing corner case in promptinit's default/fallback
prompt_preview_theme function.
This chang was wholly inspired by the documentation patch Stephane
Chazelas submitted some time ago:
https://www.zsh.org/mla/workers/2023/msg00726.html(A patch, I notice, which was never merged. It does seem like SOME
form of documentation update along those lines would benefit the
documentation. The information about 'print -rP' definitely helped me
squash a bug I was beginning to think was unsolvable. It apparently
escaped the notice of the print_preview_theme function's author as
well.)
The adam2 prompt is seemingly alone in triggering this bug, at least
for now, because it contains an escaped character (a backtick) in the
ascii-art version of its $PS1 string. Due to the escaped character,
'prompt -p adam2' (a request to preview the theme) will succeed, but
not without printing an error message between the theme name and the
actual preview: "prompt_preview_theme:22: parse error". Line 22 of the
function is the 'print -P' that attempts to display the theme's value
for $PS1, and would require the backslash be doubled to avoid the
error.
By switching to 'print -rP', the adam2 theme (and all themes) can be
previewed directly from their unaltered $PS1 value by the
prompt_preview_theme function.