Subject: 24.4.50; Isearch case sensitivity broken/confusing

From: Drew Adams <[email-masked]>
Date: Mon, 14 Jul 2014 09:02:56 -0700 (PDT)

emacs -Q

Type this in buffer *scratch*:

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).

IOW, what seems to happen is this:

When you repeat the last search string, that text is not interpreted
anew, per the current value of `case-fold-search'.  Instead, search is
put back into the state it was in for the last search
you did (from scratch), ignoring the current value of `case-fold-search'. 

If instead of C-s C-s you retype (or yank) the same text then it is
handled as you would expect (i.e., per `case-fold-search').

Similarly, if you used `M-c' during the previous search to turn off case
sensitivity, then when you start a new search by repeating the search
string, that new search acts case-insensitively, regardless of the value
of `case-fold-search'.  Again, search seems to be put back into the state
it had for the previous search session, ignoring `case-fold-search'.

Similarly, if you do C-s M-c C-s then the M-c is ignored and search
takes on the case sensitivity or lack thereof that you had for the
previous search.  Search ignores M-c if you repeat the previous search
string using C-s.

Is this considered a feature?  Or should it be considered a bug?

It seems quit confusing, at least.  Is there some advantage to having
Isearch behave this way?

Note that the doc (emacs, node Search Case) says:

  The effect [of M-c] does not extend beyond the current incremental
  search to the next one

which contradicts this behavior (starting with nil `case-fold-search'):

C-s add M-c C-s

C-s C-s

The M-c of the first search does affect the case-sensitivity of the
second search, because of the phenomenon described above: C-s C-s
restores not only the search string from the previous search but also
the case-sensitivity of the search state.

In GNU Emacs 24.4.50.1 (i686-pc-mingw32)
 of 2014-06-28 on ODIEONE
Bzr revision: 117431 [email-masked]
Windowing system distributor `Microsoft Corp.', version 6.1.7601
Configured using:
 `configure --prefix=/c/Devel/emacs/snapshot/trunk
 --enable-checking=yes,glyphs 'CFLAGS=-O0 -g3'
 LDFLAGS=-Lc:/Devel/emacs/lib 'CPPFLAGS=-DGC_MCHECK=1
 -Ic:/Devel/emacs/include''