Here's at least a new version of the patch that does away with the two lines discussed below. On Sun, May 16, 2021 at 6:27 PM Lawrence Velázquez wrote: > > Hi, > > Is workers/48609 ready to commit, or should Marlon make further > changes, or...? > > vq > > On Wed, May 5, 2021, at 2:10 AM, Marlon Richert wrote: > > On Sun, May 2, 2021 at 8:59 PM Bart Schaefer wrote: > > > 2. This bit in the restore style: > > > + $( add-zsh-hook -L ) > > > + $( add-zle-hook-widget -L ) > > > There may not be anything to be done about this, but unless I'm > > > mistaken that just re-adds all the previous hooks, it doesn't remove > > > any? The code it is replacing clobbered the entire list of precmd and > > > preexec hooks, which I suppose also might also be wrong if anything > > > other than the prompt theme was manipulating them. > > > > `add-zsh-hook -L` outputs statements in the form of `typeset -g -a > > _functions=( ... )`, while `add-zle-hook-widget -L` > > outputs statements in the form of `zstyle zle- widgets > > : ...` (which is where add-zle-hook-widget stores the hook > > widgets to call internally). eval'ing either of these results in the > > same good, old-fashioned clobbering as in the old code. So, no > > functional change there. :) > > > > I just realized, though, that these lines (new and old) don't actually > > do anything useful: > > * When you call `prompt`, it will not unhook anything not called > > `prompt_*_`. So, whatever hooks you've set up that don't follow > > the naming scheme will still be there when you call `prompt restore`. > > No need to restore them. > > * When you call `prompt`, it will unhook everything called > > `prompt_*_`. So, if a prompt theme correctly implements the > > prompt system contract, its hook functions will already get unhooked > > when switching themes. Again, no need to do anything special when > > calling `prompt restore`. > > > > The only case I can think of that would need special handling is if > > you already had hooks installed that follow the `prompt_*_` > > naming convention before calling `prompt` for the first time. > > > > Should we just get rid of this part of the "restore" logic? And > > instead just document clearly that `prompt` will auto-remove all hooks > > that follow its naming scheme?