From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Kaushal Newsgroups: gmane.emacs.bugs Subject: bug#20687: 25.0.50; `perform-replace' should invoke a key that you have bound in `query-replace-map' Date: Wed, 03 Jun 2015 03:35:15 +0000 Message-ID: References: <890ac68c-1c71-49c7-9e60-45afba90d74a@default> <87zj4hsr90.fsf_-_@mail.linkov.net> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=089e01160574f3de36051794bf35 X-Trace: ger.gmane.org 1433302594 2170 80.91.229.3 (3 Jun 2015 03:36:34 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 3 Jun 2015 03:36:34 +0000 (UTC) Cc: 20687@debbugs.gnu.org To: Drew Adams , Juri Linkov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Jun 03 05:36:16 2015 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1YzzTT-0005e1-7c for geb-bug-gnu-emacs@m.gmane.org; Wed, 03 Jun 2015 05:36:15 +0200 Original-Received: from localhost ([::1]:33364 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YzzTS-0005OK-ET for geb-bug-gnu-emacs@m.gmane.org; Tue, 02 Jun 2015 23:36:14 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:42384) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YzzTM-0005OD-CE for bug-gnu-emacs@gnu.org; Tue, 02 Jun 2015 23:36:10 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YzzTH-0002sT-L2 for bug-gnu-emacs@gnu.org; Tue, 02 Jun 2015 23:36:08 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:56363) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YzzTH-0002ru-FP for bug-gnu-emacs@gnu.org; Tue, 02 Jun 2015 23:36:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1YzzTG-0001t6-TM for bug-gnu-emacs@gnu.org; Tue, 02 Jun 2015 23:36:03 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Kaushal Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 03 Jun 2015 03:36:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 20687 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 20687-submit@debbugs.gnu.org id=B20687.14333025387220 (code B ref 20687); Wed, 03 Jun 2015 03:36:02 +0000 Original-Received: (at 20687) by debbugs.gnu.org; 3 Jun 2015 03:35:38 +0000 Original-Received: from localhost ([127.0.0.1]:38105 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YzzSq-0001sM-Fx for submit@debbugs.gnu.org; Tue, 02 Jun 2015 23:35:38 -0400 Original-Received: from mail-yk0-f174.google.com ([209.85.160.174]:35880) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YzzSm-0001s6-5R for 20687@debbugs.gnu.org; Tue, 02 Jun 2015 23:35:34 -0400 Original-Received: by yked142 with SMTP id d142so60010076yke.3 for <20687@debbugs.gnu.org>; Tue, 02 Jun 2015 20:35:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-type; bh=PziCGOVKH9NqDhsu/G+QM78HUxMgtiiyYYqkcgbL5bQ=; b=TbG+XJAojB7WOAzPuyOOus2z4HFdWcbrIcLmXJ59YhvC+HWV64lZZHENFwpXmqKfKL q6bsvZzoqwSNMmebfNs5YPaOtQXbO1NZ6a2S0e9PSCOb1TLa2+hdKA8wS2aFgqJkUfK4 bUqiNNxxp22JDtttMxa55mASzXPDM3w24/rtzFvA/HToIJlDrFcjy3i94D9TXMujLTdy an0siBFnQzFuvzHBUaamrdFk7/b08lhGLH5YvCGDzcfHGLERDUeoUIwwaWfFaXaK92u2 +gaasgwUjJodJBa0pKJlbiuQgeUdyVJv9phjhhLxGKZuiiQFAhPjJiND3aha80AmygXL Y2Hg== X-Received: by 10.236.45.38 with SMTP id o26mr32312388yhb.161.1433302526579; Tue, 02 Jun 2015 20:35:26 -0700 (PDT) In-Reply-To: X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:103529 Archived-At: --089e01160574f3de36051794bf35 Content-Type: text/plain; charset=ISO-8859-1 In that case, the patch becomes much more complicated. We have to modify the query-replace-map in replace.el itself as we cannot access the internal variables required to printed this message in isearch-style with (sit-for 1): (message query-replace-in-progress-message (query-replace-descr from-string) (query-replace-descr replacement-presentation) query-message-momentary) Here: from-string, replacement-presentation are internal variables and cannot be used in a function defined outside that (cond ..) form. So the earlier approach to define a function externally to toggle the case and to bind that to query-replace-map from outside does not apply (if we want to flash the case fold toggle info momentarily as done in isearch). Even the replacement-presentation was in a (let .. ) form not accessible to the (cond ..) form and so I moved it to an outer (let ..) form as seen in the below patch. I tested this out and the M-c and M-r bindings work great. It now also gives clear info on what the user should expect after that binding is used. Please give it a try. I have still kept this line (def (call-interactively def)) ; User-defined key, invoke it. as it could be useful to bind any other function from outside that does not need internal variables. --- replace.el 2015-06-02 23:21:42.631715000 -0400 +++ replace-editted.el 2015-06-02 23:32:47.754001000 -0400 @@ -1834,6 +1834,8 @@ (define-key map [M-next] 'scroll-other-window) (define-key map [?\C-\M-\S-v] 'scroll-other-window-down) (define-key map [M-prior] 'scroll-other-window-down) + (define-key map "\M-c" 'toggle-query-case) + (define-key map "\M-r" 'toggle-replace-preserve-case) ;; Binding ESC would prohibit the M-v binding. Instead, callers ;; should check for ESC specially. ;; (define-key map "\e" 'exit-prefix) @@ -2100,12 +2102,14 @@ ;; (match-data); otherwise it is t if a match is possible at point. (match-again t) - (message + (query-replace-in-progress-message (if query-flag (apply 'propertize (substitute-command-keys - "Query replacing %s with %s: (\\\\[help] for help) ") - minibuffer-prompt-properties)))) + (concat "Query replacing %s with %s: " + "(\\\\[help] for help) %s ")) + minibuffer-prompt-properties))) + (query-message-momentary "")) ;; If region is active, in Transient Mark mode, operate on region. (if backward @@ -2251,7 +2255,7 @@ noedit real-match-data backward) replace-count (1+ replace-count))) (undo-boundary) - (let (done replaced key def) + (let (done replaced key def replacement-presentation) ;; Loop reading commands until one of them sets done, ;; which means it has finished handling this ;; occurrence. Any command that sets `done' should @@ -2266,17 +2270,18 @@ regexp-flag delimited-flag case-fold-search backward) ;; Bind message-log-max so we don't fill up the message log ;; with a bunch of identical messages. - (let ((message-log-max nil) - (replacement-presentation - (if query-replace-show-replacement - (save-match-data - (set-match-data real-match-data) - (match-substitute-replacement next-replacement - nocasify literal)) - next-replacement))) - (message message + (let ((message-log-max nil)) + (setq replacement-presentation + (if query-replace-show-replacement + (save-match-data + (set-match-data real-match-data) + (match-substitute-replacement next-replacement + nocasify literal)) + next-replacement)) + (message query-replace-in-progress-message (query-replace-descr from-string) - (query-replace-descr replacement-presentation))) + (query-replace-descr replacement-presentation) + query-message-momentary)) (setq key (read-event)) ;; Necessary in case something happens during read-event ;; that clobbers the match data. @@ -2404,6 +2409,51 @@ (replace-dehighlight) (save-excursion (recursive-edit)) (setq replaced t)) + + ((eq def 'toggle-query-case) + (setq case-fold-search (not case-fold-search)) + (let ((message-log-max nil) + (query-message-momentary + (concat "[" + (if case-fold-search + "case insensitive search" + "Case Sensitive Search") + "]"))) + (message query-replace-in-progress-message + (query-replace-descr from-string) + (query-replace-descr replacement-presentation) + query-message-momentary) + (sit-for 1))) + + ((eq def 'toggle-replace-preserve-case) + (let ((message-log-max nil) + (nocasify-value-reason "") + query-message-momentary) + (setq nocasify (not nocasify)) + (cond + ((null case-fold-search) + (setq nocasify nil) + (setq nocasify-value-reason ", as case-fold-search is nil")) + ((null (isearch-no-upper-case-p from-string regexp-flag)) + (setq nocasify nil) + (setq nocasify-value-reason ", as FROM-STRING has an upper case char.")) + ((null (isearch-no-upper-case-p next-replacement regexp-flag)) + (setq nocasify t) + (setq nocasify-value-reason ", as REPLACEMENT has an upper case char."))) + (setq query-message-momentary + (concat "[Replaced text case will " + (if nocasify "NOT " "") + "be preserved" + nocasify-value-reason + "]")) + (message query-replace-in-progress-message + (query-replace-descr from-string) + (query-replace-descr replacement-presentation) + query-message-momentary) + (sit-for 1.5))) + + (def (call-interactively def)) ; User-defined key, invoke it. + ;; Note: we do not need to treat `exit-prefix' ;; specially here, since we reread ;; any unrecognized character. On Tue, Jun 2, 2015 at 6:51 PM Drew Adams wrote: > > > + ;; 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. > --089e01160574f3de36051794bf35 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
In that case, the patch becomes much more complicated.=A0<= br>
We have to modify the query-replace-map in replace.el itself as we c= annot access the internal variables required to printed this message in ise= arch-style with (sit-for 1):

(message query-replace-in-p= rogress-message
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0 =A0 =A0 (query-replace-descr from-string)
=A0 =A0= =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (query-rep= lace-descr replacement-presentation)
=A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 query-message-momentary)
<= div>
Here: from-string, replacement-presentation are internal= variables and cannot be used in a function defined outside that (cond ..) = form. So the earlier approach to define a function externally to toggle the= case and to bind that to query-replace-map from outside does not apply (if= we want to flash the case fold toggle info momentarily as done in isearch)= . Even the replacement-presentation was in a (let .. ) form not accessible = to the (cond ..) form and so I moved it to an outer (let ..) form as seen i= n the below patch.

I tested this out and the M-c a= nd M-r bindings work great. It now also gives clear info on what the user s= hould expect after that binding is used.
Please give it a try.=A0=

I have still kept this line

=A0(def (call-interactively def)) ; User-defined key, invoke it.<= br>

as it could be useful to bind any oth= er function from outside that does not need internal variables.

--- replace.el 2015-06-02 23:21:42.631715000 -0= 400
+++ replace-editted.el 2015-06-02 23:32:47.754001000 -0400
@@ = -1834,6 +1834,8 @@
=A0 =A0 =A0(define-key map [M-next] 'scrol= l-other-window)
=A0 =A0 =A0(define-key map [?\C-\M-\S-v] 'scr= oll-other-window-down)
=A0 =A0 =A0(define-key map [M-prior] '= scroll-other-window-down)
+ =A0 =A0(define-key map "\M-c&quo= t; 'toggle-query-case)
+ =A0 =A0(define-key map "\M-r&qu= ot; 'toggle-replace-preserve-case)
=A0 =A0 =A0;; Binding ESC = would prohibit the M-v binding.=A0 Instead, callers
=A0 =A0 =A0;;= should check for ESC specially.
=A0 =A0 =A0;; (define-key map &q= uot;\e" 'exit-prefix)
@@ -2100,12 +2102,14 @@
= =A0 =A0 =A0 =A0 =A0 ;; (match-data); otherwise it is t if a match is possib= le at point.
=A0 =A0 =A0 =A0 =A0 (match-again t)
=A0
- =A0 =A0 =A0 =A0 (message
+ =A0 =A0 =A0 =A0 (query-repla= ce-in-progress-message
=A0 =A0 =A0 =A0 =A0 =A0(if query-flag
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(apply 'propertize
=A0 = =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (substitute-command-keys
= - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0"Query replacing %s with = %s: (\\<query-replace-map>\\[help] for help) ")
- =A0 = =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 minibuffer-prompt-properties))))
<= div>+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(concat "Query replac= ing %s with %s: "
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0 =A0"(\\<query-replace-map>\\[help] for help) %s = "))
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 minibuffer-pro= mpt-properties)))
+ =A0 =A0 =A0 =A0 (query-message-momentary &quo= t;"))
=A0
=A0 =A0 =A0;; If region is active, in Tr= ansient Mark mode, operate on region.
=A0 =A0 =A0(if backward
@@ -2251,7 +2255,7 @@
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0 noedit real-match-data backward)
=A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0replace-count (1+ replace-count)))
=
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(undo-boundary)
- =A0 =A0 =A0= =A0 =A0 =A0 =A0(let (done replaced key def)
+ =A0 =A0 =A0 =A0 = =A0 =A0 =A0(let (done replaced key def replacement-presentation)
= =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0;; Loop reading commands until one of th= em sets done,
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0;; which means i= t has finished handling this
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0;= ; occurrence.=A0 Any command that sets `done' should
@@ -2266= ,17 +2270,18 @@
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 regexp-fl= ag delimited-flag case-fold-search backward)
=A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0 =A0;; Bind message-log-max so we don't fill up the mess= age log
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0;; with a bunch of= identical messages.
- =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(let ((= message-log-max nil)
- =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0(replacement-presentation
- =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0 =A0 (if query-replace-show-replacement
- =A0 =A0 = =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (save-match-data
= - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (set-match-da= ta real-match-data)
- =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0= =A0 =A0 =A0 =A0 (match-substitute-replacement next-replacement
-= =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 nocasify literal))
- =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 next-replacement)))=
- =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(message message
<= div>+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(let ((message-log-max nil))
=
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(setq replacement-presentatio= n
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(if query-= replace-show-replacement
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0 =A0 =A0(save-match-data
+ =A0 =A0 =A0 =A0 =A0 =A0= =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(set-match-data real-match-data)
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(m= atch-substitute-replacement next-replacement
+ =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0= =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0nocasify literal))
+ =A0 =A0 =A0 = =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0next-replacement))
+ = =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(message query-replace-in-progress-m= essage
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 (query-replace-descr from-string)
- =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (query-replace-descr replacement-presentati= on)))
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (= query-replace-descr replacement-presentation)
+ =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 query-message-momentary))
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(setq key (read-event))
= =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0;; Necessary in case something happe= ns during read-event
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0;; th= at clobbers the match data.
@@ -2404,6 +2409,51 @@
=A0 = =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (replace-dehighlight)
=
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (save-excursion (r= ecursive-edit))
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 (setq replaced t))
+
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0 =A0((eq def 'toggle-query-case)
+ =A0 =A0 =A0= =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (setq case-fold-search (not case-fold-= search))
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (let (= (message-log-max nil)
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0 =A0 (query-message-momentary
+ =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(concat "["
<= div>+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0(if case-fold-search
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0= =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0"case insensit= ive search"
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0"Case Sensitive Search")
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0"]")))
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0= =A0 =A0 =A0 =A0 =A0 (message query-replace-in-progress-message
+= =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(qu= ery-replace-descr from-string)
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(query-replace-descr replacement-pre= sentation)
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0 =A0query-message-momentary)
+ =A0 =A0 =A0 =A0 =A0= =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (sit-for 1)))
+
+ =A0 = =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0((eq def 'toggle-replace-pre= serve-case)
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (le= t ((message-log-max nil)
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0 =A0 =A0 (nocasify-value-reason "")
+ = =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 query-message-m= omentary)
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (= setq nocasify (not nocasify))
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0 =A0 (cond
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0 =A0((null case-fold-search)
+ =A0 =A0 =A0 =A0 =A0= =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (setq nocasify nil)
+ =A0 = =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (setq nocasify-value-re= ason ", as case-fold-search is nil"))
+ =A0 =A0 =A0 =A0= =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0((null (isearch-no-upper-case-p fro= m-string regexp-flag))
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0 (setq nocasify nil)
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0= =A0 =A0 =A0 =A0 =A0 =A0 =A0 (setq nocasify-value-reason ", as FROM-ST= RING has an upper case char."))
+ =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0((null (isearch-no-upper-case-p next-replace= ment regexp-flag))
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 (setq nocasify t)
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0 =A0 =A0 (setq nocasify-value-reason ", as REPLACEMENT = has an upper case char.")))
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0 =A0 =A0 (setq query-message-momentary
+ =A0 =A0 = =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (concat "[Repl= aced text case will "
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (if nocasify "NOT " &= quot;")
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 "be preserved"
+ =A0 = =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0= nocasify-value-reason
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 "]"))
+ =A0 =A0= =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (message query-replace-in-prog= ress-message
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0 =A0 =A0(query-replace-descr from-string)
+ =A0 = =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(query-r= eplace-descr replacement-presentation)
+ =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0query-message-momentary)
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (sit-for 1.5))= )
+
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(d= ef (call-interactively def)) ; User-defined key, invoke it.
+
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0;; Note: we do no= t need to treat `exit-prefix'
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0= =A0 =A0 =A0 =A0 =A0;; specially here, since we reread
=A0 =A0 = =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0;; any unrecognized character.


<= div dir=3D"ltr">On Tue, Jun 2, 2015 at 6:51 PM Drew Adams <drew.adams@oracle.com> wrote:
<= blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px= #ccc solid;padding-left:1ex">> > +=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 ;; Show whether `case-fold-search' is `t' or `nil'
> > +=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (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).=A0 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.=A0 There is what `case-fold-search' controls (the<= br> 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).=A0 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 confusin= g.
The first three paragraphs (2/3 of the node), for instance:

=A0If the first argument of a replace command is all lower case, the
=A0command ignores case while searching for occurrences to
=A0replace--provided `case-fold-search' is non-`nil'.=A0 If
=A0`case-fold-search' is set to `nil', case is always significant i= n all
=A0searches.

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

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

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