all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#18017: 24.4.50; Isearch case sensitivity broken/confusing
@ 2014-07-14 16:02 Drew Adams
  2014-07-14 21:17 ` Juri Linkov
  0 siblings, 1 reply; 5+ messages in thread
From: Drew Adams @ 2014-07-14 16:02 UTC (permalink / raw)
  To: 18017

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 rgm@gnu.org-20140628015517-eku6hj8mpgcvfnso
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''





^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#18017: 24.4.50; Isearch case sensitivity broken/confusing
  2014-07-14 16:02 bug#18017: 24.4.50; Isearch case sensitivity broken/confusing Drew Adams
@ 2014-07-14 21:17 ` Juri Linkov
  2014-07-14 22:39   ` Drew Adams
  2021-07-14  9:14   ` Lars Ingebrigtsen
  0 siblings, 2 replies; 5+ messages in thread
From: Juri Linkov @ 2014-07-14 21:17 UTC (permalink / raw)
  To: Drew Adams; +Cc: 18017

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

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





^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#18017: 24.4.50; Isearch case sensitivity broken/confusing
  2014-07-14 21:17 ` Juri Linkov
@ 2014-07-14 22:39   ` Drew Adams
  2021-07-14  9:14   ` Lars Ingebrigtsen
  1 sibling, 0 replies; 5+ messages in thread
From: Drew Adams @ 2014-07-14 22:39 UTC (permalink / raw)
  To: Juri Linkov; +Cc: 18017

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





^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#18017: 24.4.50; Isearch case sensitivity broken/confusing
  2014-07-14 21:17 ` Juri Linkov
  2014-07-14 22:39   ` Drew Adams
@ 2021-07-14  9:14   ` Lars Ingebrigtsen
  2021-07-14 23:39     ` Juri Linkov
  1 sibling, 1 reply; 5+ messages in thread
From: Lars Ingebrigtsen @ 2021-07-14  9:14 UTC (permalink / raw)
  To: Juri Linkov; +Cc: 18017

Juri Linkov <juri@jurta.org> writes:

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

The patch from bug#11378 was apparently never applied?  I think it
sounds like a good idea to let the user control whether `C-s C-s' should
also restore the case sensitivity of the previous match or not.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#18017: 24.4.50; Isearch case sensitivity broken/confusing
  2021-07-14  9:14   ` Lars Ingebrigtsen
@ 2021-07-14 23:39     ` Juri Linkov
  0 siblings, 0 replies; 5+ messages in thread
From: Juri Linkov @ 2021-07-14 23:39 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: 18017

>> 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.
>> 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.
>
> The patch from bug#11378 was apparently never applied?  I think it
> sounds like a good idea to let the user control whether `C-s C-s' should
> also restore the case sensitivity of the previous match or not.

Recently Augusto proposed fresh ideas on emacs-devel
that could also be taken into account.





^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-07-14 23:39 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-07-14 16:02 bug#18017: 24.4.50; Isearch case sensitivity broken/confusing Drew Adams
2014-07-14 21:17 ` Juri Linkov
2014-07-14 22:39   ` Drew Adams
2021-07-14  9:14   ` Lars Ingebrigtsen
2021-07-14 23:39     ` Juri Linkov

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.