Subject: RE: bug#18017: 24.4.50; Isearch case sensitivity broken/confusing

From: Drew Adams <[email-masked]>
Date: Mon, 14 Jul 2014 15:39:01 -0700 (PDT)

> > Add
> > add
> > ADD
> > M-x set-variable case-fold-search nil
> > C-s add C-s
> > C-s M-c C-s
> >
> > The M-c says that search is now case-insensitive, but the second and
> > subsequent C-s's do not find occurrences Add and ADD.
> >
> > C-s add C-s
> > That finds all three (case-insensitive).
> 
> Did you mean `C-s M-c add C-s' in the last key sequence
> (that finds all case-insensitive)?  You have to use M-c to toggle
> case-sensitivity for case-fold-search that you set to nil.

I meant that after you use C-s add M-c C-s and then you start again
with C-s C-s, the case insensitivity of the first search continues for
the second (independent) search.  IOW, M-c *does* extend beyond the
current search, if you use C-s C-s to reuse the last search string.

>From what I see, reusing the last search string really means, not
just reusing its text, but reusing the last search state, including
(at least) whether searching is case-sensitive.

> And `C-s C-s' naturally restores case-sensitivity of the
> previous search string, but it's possible to configure this
> using `isearch-keep-mode-variables' from bug#11378.

Dunno about "naturally".  I'm really not sure what the best behavior
to shoot for is.  It does seem to me that the current behavior can be
confusing.  On the other hand, perhaps someone finds it handy to not
have to repeat M-c to get back the same sensitivity as for the last search.

Perhaps you and some others could play with this and make a suggestion
wrt the best behavior.  And perhaps we should define whatever is
decided on as the _default_ behavior, and add a user option that lets
users choose.  I'd welcome your ideas about this.  Currently I think
the behavior is confusing and could probably be improved.

For non-nil `case-fold-search' I think the current behavior is OK.
But I suspect that less thought went into the behavior wrt
case-sensitivity for the nil case.

Note that things are additionally complicated for users because of
the (handy) special handling based on the case of the chars you type
(i.e., the special handling described in (emacs) `Special Isearch').

Emacs gives users lots of possibilities here, but _discovery_ of how
things work is not straightforward.  It is all too easy to stumble
into behavior that one doesn't understand, especially for a newbie.