>> Instead of adding an `isearch-whitespace' flag, I think this is best
>> implemented as a third possible value for `isearch-word', say the
>> symbol `match-any-whitespace'.
>
> Whoops, `isearch-word' already accepts function values, for purposes of
> symbol searching. The `isearch-toggle-whitespace' command simply needs
> to set this. Maybe that's is what you already had in mind.
The problem is that whitespace mode can be active together with regexp mode
and also simultaneously with plain C-s mode. This is different from
`isearch-word' that is a separate mode mutually exclusive with C-s and C-M-s.
For instance, `isearch-toggle-regexp' sets `isearch-word' to nil, but it
should not disable whitespace mode (it should be disabled only with
the command `isearch-toggle-whitespace').
This is why I tend to implement it more like `isearch-toggle-case-fold'
than `isearch-toggle-word'.