Subject: bug#20687: 25.0.50; `perform-replace' should invoke a key that you have bound in `query-replace-map'

From: Drew Adams <[email-masked]>
Date: Tue, 2 Jun 2015 15:50:51 -0700 (PDT)

> > +                  ;; Show whether `case-fold-search' is `t' or `nil'
> > +                  (if case-fold-search "[case] " "[CaSe] ")
> 
> Maybe we should use the same message about case-folding like in
> isearch?

The msg should somehow indicate that what is involved here is (only)
case-sensitivity wrt FROM (i.e., wrt search, not replacement).  Not
sure what the best way to do that would be.

IOW, there is more than one use of case sensitivity here, unlike
the case for search.  There is what `case-fold-search' controls (the
search), and there is what `case-replace' controls (the replacement).
And then there is what happens for the replacement according to the
case of FROM.

---

BTW, we might consider binding a key to toggle case sensitivity for
search as part of this bug fix (i.e., not just fixing `perform-replace'
so it respects keys that user might bind).  In that case, maybe the
same key we use in Isearch (`M-c') would be a good choice.

---

BTW2, I think that Emacs manual node `Replacement and Case' is confusing.
The first three paragraphs (2/3 of the node), for instance:

 If the first argument of a replace command is all lower case, the
 command ignores case while searching for occurrences to
 replace--provided `case-fold-search' is non-`nil'.  If
 `case-fold-search' is set to `nil', case is always significant in all
 searches.

  An upper-case letter anywhere in the incremental search string makes
  the search case-sensitive.  Thus, searching for `Foo' does not find
  `foo' or `FOO'.  This applies to regular expression search as well as
  to string search.  The effect ceases if you delete the upper-case
  letter from the search string.

  If you set the variable `case-fold-search' to `nil', then all
  letters must match exactly, including case.  This is a per-buffer
  variable; altering the variable normally affects only the current
  buffer, unless you change its default value.  *Note Locals::.  This
  variable applies to nonincremental searches also, including those
  performed by the replace commands (*note Replace::) and the minibuffer
  history matching commands (*note Minibuffer History::).

These paragraphs really say only that the search part of replace commands
acts normally: `case-fold-search' governs.  They should be removed or
changed to say just that.  Leaving them as they are just confuses readers, IMO.