Subject: RE: bug#20351: isearch-lax-whitespace should be customizable variable

From: Drew Adams <[email-masked]>
Date: Mon, 29 Jun 2015 16:14:24 -0700 (PDT)

> I believe both ‘isearch-lax-whitespace’ and ‘character-fold-search’
> should be customizable.  bug#11378 proposed a patch that adds a new
> user variable to customize all such search parameters:
> 
> (defcustom isearch-keep-mode-variables nil
>   "A set of search variables to keep between different searches.
> When a search variable is customized to exist in this set, then
> starting a new search doesn't reset the corresponding isearch
> variable to its default value, thus keeping the value from the
> previous search (changed using toggling commands)." ...

FWIW, I agree (strongly) that some such feature is desirable.
I think you and I have discussed this a bit before.

Isearch+ has this feature, in a different form.  There is option
`isearchp-toggle-option-flag' and its associated toggle command.

  Non-nil means Isearch toggling commands can affect option values.
  If nil, the option value remains unchanged - the effect is temporary.

  Applies to toggle commands for behavior that has an associated user
  option.  Currently this means `M-s i' (`isearch-toggle-invisible')
  and `M-c' (`isearch-toggle-case-fold').

The option determines whether commands that toggle behavior also
toggle an associated user option.  For such commands, a prefix arg
flips the behavior, as if `isearchp-toggle-option-flag' were
toggled temporarily.

You can toggle this option itself, using `M-s v'
(`isearchp-toggle-option-toggle').

I mention this approach, but your suggestion sounds good too.

The point is to let users decide whether toggling the state (for
any given state attribute) also toggles the option value - so that
the effect remains after Isearch is finished.  And to let them
override their preference temporarily (e.g., with a prefix arg).

What you have added is the ability for users to pick which options
to put under the sway of something like `isearchp-toggle-option-flag',
IOW, you have in effect, provided a `isearchp-toggle-option-flag'
for each togglable option separately.  And that sounds like a good
thing, a priori.

I'd propose combining your suggestion with the temporary-flipping
behavior I describe: a prefix arg (or whatever) lets a user
temporarily change her mind about the `isearch-keep-mode-variables'
setting for that toggle: if the option is not listed in `i-s-k-m-v'
then `C-u' toggles the option; if the option is listed there then
`C-u' does not toggle the option (it toggles the state/behavior
only for the current Isearch duration).