GNU bug report logs -
#45617
<query-replace> loses the edit region. Works in 23.3, broke in 26.3
Previous Next
Reported by: "Bob Floyd" <bobfloyd <at> comcast.net>
Date: Sun, 3 Jan 2021 01:07:02 UTC
Severity: normal
Tags: fixed
Fixed in version 28.0.50
Done: Juri Linkov <juri <at> linkov.net>
Bug is archived. No further changes may be made.
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 45617 in the body.
You can then email your comments to 45617 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#45617
; Package
emacs
.
(Sun, 03 Jan 2021 01:07:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
"Bob Floyd" <bobfloyd <at> comcast.net>
:
New bug report received and forwarded. Copy sent to
bug-gnu-emacs <at> gnu.org
.
(Sun, 03 Jan 2021 01:07:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
Use this c++ test:
main()
{
int _xx;
_xx = _xx + 2;
return _xx;
}
"query-replace" loses the edit region.
Works in Emacs 23.3. Broke in GNU Emacs 26.3 (build 1, x86_64-w64-mingw32)
of 2019-08-29
1. Select region from line 2 '{' to line 8 '}'
2. Do "query-replace" to begin "Query replace in region"
3. Do Double-click left mouse to select '_xx' on line 3
-or-
<down-mouse-one> "mouse-drag-region" to select '_xx' on line 3
4. In "Query replace in region:" window do <mouse-2> "mouse-yank-at-click"
to insert '_xx'.
5. Via keyboard hit "Enter" key, now you see:
"Query replace in region _xx with:"
6. Via keyboard type '_yy' and 'enter'
"Query replace in region _xx with: _yy"
7. Nothing happens because the region in step (1) has been lost.
It should ask to replace 4 '_xx's in the region.
[Message part 2 (text/html, inline)]
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#45617
; Package
emacs
.
(Sun, 03 Jan 2021 14:49:01 GMT)
Full text and
rfc822 format available.
Message #8 received at 45617 <at> debbugs.gnu.org (full text, mbox):
> From: "Bob Floyd" <bobfloyd <at> comcast.net>
> Date: Sat, 2 Jan 2021 17:05:57 -0800
>
> 7. Nothing happens because the region in step (1) has been lost.
> It should ask to replace 4 ‘_xx’s in the region.
I suspect this is due to changes in how selection works in Emacs.
Those changes were made in Emacs 24; please see the section "Selection
changes" in the file etc/NEWS.24, where you will also find
instructions for getting back the old behavior.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#45617
; Package
emacs
.
(Sun, 03 Jan 2021 19:19:02 GMT)
Full text and
rfc822 format available.
Message #11 received at 45617 <at> debbugs.gnu.org (full text, mbox):
Hi Eli,
I already had the NEWS.24 changes in my .emacs file! So that is not the cause of this issue.
You do agree this is a bug - that <query-replace> fails, correct?
Thanks for your quick reply.
Bob
-----Original Message-----
From: Eli Zaretskii [mailto:eliz <at> gnu.org]
Sent: Sunday, January 3, 2021 6:48 AM
To: Bob Floyd
Cc: 45617 <at> debbugs.gnu.org
Subject: Re: bug#45617: <query-replace> loses the edit region. Works in 23.3, broke in 26.3
> From: "Bob Floyd" <bobfloyd <at> comcast.net>
> Date: Sat, 2 Jan 2021 17:05:57 -0800
>
> 7. Nothing happens because the region in step (1) has been lost.
> It should ask to replace 4 �_xx�s in the region.
I suspect this is due to changes in how selection works in Emacs.
Those changes were made in Emacs 24; please see the section "Selection
changes" in the file etc/NEWS.24, where you will also find
instructions for getting back the old behavior.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#45617
; Package
emacs
.
(Mon, 04 Jan 2021 17:27:01 GMT)
Full text and
rfc822 format available.
Message #14 received at 45617 <at> debbugs.gnu.org (full text, mbox):
> From: "Bob Floyd" <bobfloyd <at> comcast.net>
> Cc: <45617 <at> debbugs.gnu.org>
> Date: Sun, 3 Jan 2021 11:18:03 -0800
>
> I already had the NEWS.24 changes in my .emacs file! So that is not the cause of this issue.
That is strange, because if I make all the changes mentioned in
NEWS.24, in "emacs -Q", then your recipe works for me as you expected.
Did you try that in "emacs -Q"? If not, please try; if "emacs -Q"
with the changes from NEWS.24 does work, then there's some other
customization in your init files which gets in the way.
> You do agree this is a bug - that <query-replace> fails, correct?
It is not a bug, it is a consequence of the changes in how selections
work in Emacs. Your example assumes the old handling of selections,
so it doesn't work with Emacs >= 24 defaults.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#45617
; Package
emacs
.
(Mon, 04 Jan 2021 18:09:03 GMT)
Full text and
rfc822 format available.
Message #17 received at 45617 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
>> 7. Nothing happens because the region in step (1) has been lost.
>> It should ask to replace 4 ‘_xx’s in the region.
>
> I suspect this is due to changes in how selection works in Emacs.
> Those changes were made in Emacs 24; please see the section "Selection
> changes" in the file etc/NEWS.24, where you will also find
> instructions for getting back the old behavior.
I tried to fix this problem by this patch, and indeed it fixed it,
so the region boundaries are preserved even when changed during
the minibuffer reading the strings:
[query-replace-region.patch (text/x-diff, attachment)]
[Message part 3 (text/plain, inline)]
But then I noticed this comment in 'query-replace':
;; These are done separately here
;; so that command-history will record these expressions
;; rather than the values they had this time.
And indeed this patch broke this feature, so region boundaries
are saved as numbers in command-history for repeat-complex-command
instead of such code:
C-x M-: (query-replace "a" "z" nil (if (use-region-p) (region-beginning)) (if (use-region-p) (region-end)) nil nil)
But anyway this feature was broken by design and never worked:
with a compiled replace.el it saves region boundaries as numbers,
and only when 'query-replace' is manually evaluated with 'eval-defun',
only then region boundaries are saved as code to command-history.
So we could just delete 'fix_command' from callint.c,
and don't worry about such cases.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#45617
; Package
emacs
.
(Mon, 04 Jan 2021 22:41:02 GMT)
Full text and
rfc822 format available.
Message #20 received at 45617 <at> debbugs.gnu.org (full text, mbox):
Thanks! The patch has fixed the issue.
-----Original Message-----
From: Juri Linkov [mailto:juri <at> linkov.net]
Sent: Monday, January 4, 2021 9:37 AM
To: Eli Zaretskii
Cc: Bob Floyd; 45617 <at> debbugs.gnu.org
Subject: Re: bug#45617: <query-replace> loses the edit region. Works in 23.3, broke in 26.3
>> 7. Nothing happens because the region in step (1) has been lost.
>> It should ask to replace 4 _xx s in the region.
>
> I suspect this is due to changes in how selection works in Emacs.
> Those changes were made in Emacs 24; please see the section "Selection
> changes" in the file etc/NEWS.24, where you will also find
> instructions for getting back the old behavior.
I tried to fix this problem by this patch, and indeed it fixed it, so the region boundaries are preserved even when changed during the minibuffer reading the strings:
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#45617
; Package
emacs
.
(Tue, 05 Jan 2021 18:32:02 GMT)
Full text and
rfc822 format available.
Message #23 received at 45617 <at> debbugs.gnu.org (full text, mbox):
> Thanks! The patch has fixed the issue.
If there is no need to support the broken feature of saving
region boundaries as code in the command history, then
this patch could be pushed. Otherwise, another solution is
to restore the previously selected region after exiting the minibuffer
the same way as exiting the minibuffer restores window configurations
(there is a new option to disable this discussed in bug#45072).
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#45617
; Package
emacs
.
(Tue, 05 Jan 2021 19:46:02 GMT)
Full text and
rfc822 format available.
Message #26 received at 45617 <at> debbugs.gnu.org (full text, mbox):
For my two cents, what you write sounds like the real problem is the
minibuffer failing to restore on exit. A fix to that would be preferable to
the patch. After all, who knows what else may affected by the minibuffer!
I'd be happy to test this alternative.
-----Original Message-----
From: Juri Linkov [mailto:juri <at> linkov.net]
Sent: Tuesday, January 5, 2021 10:27 AM
To: Bob Floyd
Cc: 'Eli Zaretskii'; 45617 <at> debbugs.gnu.org
Subject: Re: bug#45617: <query-replace> loses the edit region. Works in
23.3, broke in 26.3
> Thanks! The patch has fixed the issue.
If there is no need to support the broken feature of saving
region boundaries as code in the command history, then
this patch could be pushed. Otherwise, another solution is
to restore the previously selected region after exiting the minibuffer
the same way as exiting the minibuffer restores window configurations
(there is a new option to disable this discussed in bug#45072).
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#45617
; Package
emacs
.
(Wed, 06 Jan 2021 18:11:03 GMT)
Full text and
rfc822 format available.
Message #29 received at 45617 <at> debbugs.gnu.org (full text, mbox):
> For my two cents, what you write sounds like the real problem is the
> minibuffer failing to restore on exit. A fix to that would be preferable to
> the patch. After all, who knows what else may affected by the minibuffer!
> I'd be happy to test this alternative.
The question we need to answer: should this fix affect all other uses
of the minibuffer? So for any command that operates on the active region
and asks its arguments from the minibuffer, when you copy the text
from the original buffer to the minibuffer and thus change its region,
should quitting the minibuffer restore the original region for
all such commands? This means restoring the original mark and point.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#45617
; Package
emacs
.
(Wed, 06 Jan 2021 18:20:01 GMT)
Full text and
rfc822 format available.
Message #32 received at 45617 <at> debbugs.gnu.org (full text, mbox):
> From: Juri Linkov <juri <at> linkov.net>
> Cc: "'Eli Zaretskii'" <eliz <at> gnu.org>, <45617 <at> debbugs.gnu.org>
> Date: Wed, 06 Jan 2021 19:44:30 +0200
>
> > For my two cents, what you write sounds like the real problem is the
> > minibuffer failing to restore on exit. A fix to that would be preferable to
> > the patch. After all, who knows what else may affected by the minibuffer!
> > I'd be happy to test this alternative.
>
> The question we need to answer: should this fix affect all other uses
> of the minibuffer? So for any command that operates on the active region
> and asks its arguments from the minibuffer, when you copy the text
> from the original buffer to the minibuffer and thus change its region,
> should quitting the minibuffer restore the original region for
> all such commands? This means restoring the original mark and point.
I think the answer is YES, especially if we did behave like that in
the distant past.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#45617
; Package
emacs
.
(Wed, 06 Jan 2021 22:11:02 GMT)
Full text and
rfc822 format available.
Message #35 received at 45617 <at> debbugs.gnu.org (full text, mbox):
Perhaps another way to think about this is that emacs is "mode-less".
I can begin a command, recurse into another, pop out and resume the first
command.
Without the patch, or minibuffer fix, <query-replace> breaks that design.
If the minibffer fix better supports mode-less operation in general it would
be better than the patch.
-----Original Message-----
From: Eli Zaretskii [mailto:eliz <at> gnu.org]
Sent: Wednesday, January 6, 2021 10:19 AM
To: Juri Linkov
Cc: bobfloyd <at> comcast.net; 45617 <at> debbugs.gnu.org
Subject: Re: bug#45617: <query-replace> loses the edit region. Works in
23.3, broke in 26.3
> From: Juri Linkov <juri <at> linkov.net>
> Cc: "'Eli Zaretskii'" <eliz <at> gnu.org>, <45617 <at> debbugs.gnu.org>
> Date: Wed, 06 Jan 2021 19:44:30 +0200
>
> > For my two cents, what you write sounds like the real problem is the
> > minibuffer failing to restore on exit. A fix to that would be preferable
to
> > the patch. After all, who knows what else may affected by the
minibuffer!
> > I'd be happy to test this alternative.
>
> The question we need to answer: should this fix affect all other uses
> of the minibuffer? So for any command that operates on the active region
> and asks its arguments from the minibuffer, when you copy the text
> from the original buffer to the minibuffer and thus change its region,
> should quitting the minibuffer restore the original region for
> all such commands? This means restoring the original mark and point.
I think the answer is YES, especially if we did behave like that in
the distant past.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#45617
; Package
emacs
.
(Thu, 07 Jan 2021 18:49:01 GMT)
Full text and
rfc822 format available.
Message #38 received at 45617 <at> debbugs.gnu.org (full text, mbox):
>> The question we need to answer: should this fix affect all other uses
>> of the minibuffer? So for any command that operates on the active region
>> and asks its arguments from the minibuffer, when you copy the text
>> from the original buffer to the minibuffer and thus change its region,
>> should quitting the minibuffer restore the original region for
>> all such commands? This means restoring the original mark and point.
>
> I think the answer is YES, especially if we did behave like that in
> the distant past.
Interesting, this means this behavior was changed intentionally
in a recent version?
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#45617
; Package
emacs
.
(Thu, 07 Jan 2021 19:37:01 GMT)
Full text and
rfc822 format available.
Message #41 received at 45617 <at> debbugs.gnu.org (full text, mbox):
> From: Juri Linkov <juri <at> linkov.net>
> Cc: bobfloyd <at> comcast.net, 45617 <at> debbugs.gnu.org
> Date: Thu, 07 Jan 2021 20:46:05 +0200
>
> >> The question we need to answer: should this fix affect all other uses
> >> of the minibuffer? So for any command that operates on the active region
> >> and asks its arguments from the minibuffer, when you copy the text
> >> from the original buffer to the minibuffer and thus change its region,
> >> should quitting the minibuffer restore the original region for
> >> all such commands? This means restoring the original mark and point.
> >
> > I think the answer is YES, especially if we did behave like that in
> > the distant past.
>
> Interesting, this means this behavior was changed intentionally
> in a recent version?
AFAICT, it did change, but only slightly.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#45617
; Package
emacs
.
(Wed, 13 Jan 2021 19:05:02 GMT)
Full text and
rfc822 format available.
Message #44 received at 45617 <at> debbugs.gnu.org (full text, mbox):
> Perhaps another way to think about this is that emacs is "mode-less".
>
> I can begin a command, recurse into another, pop out and resume the first
> command.
>
> Without the patch, or minibuffer fix, <query-replace> breaks that design.
So here is a simpler patch that fixes all query-replace commands:
diff --git a/lisp/replace.el b/lisp/replace.el
index d41dc98a0d..16b80a8fd1 100644
--- a/lisp/replace.el
+++ b/lisp/replace.el
@@ -327,6 +336,7 @@ query-replace-read-to
(defun query-replace-read-args (prompt regexp-flag &optional noerror)
(unless noerror
(barf-if-buffer-read-only))
+ (save-mark-and-excursion
(let* ((from (query-replace-read-from prompt regexp-flag))
(to (if (consp from) (prog1 (cdr from) (setq from (car from)))
(query-replace-read-to from prompt regexp-flag))))
@@ -334,7 +344,7 @@ query-replace-read-args
(or (and current-prefix-arg (not (eq current-prefix-arg '-)))
(and (plist-member (text-properties-at 0 from) 'isearch-regexp-function)
(get-text-property 0 'isearch-regexp-function from)))
- (and current-prefix-arg (eq current-prefix-arg '-)))))
+ (and current-prefix-arg (eq current-prefix-arg '-))))))
(defun query-replace (from-string to-string &optional delimited start end backward region-noncontiguous-p)
"Replace some occurrences of FROM-STRING with TO-STRING.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#45617
; Package
emacs
.
(Fri, 15 Jan 2021 01:23:01 GMT)
Full text and
rfc822 format available.
Message #47 received at 45617 <at> debbugs.gnu.org (full text, mbox):
I've removed the earlier patch and installed these changes. Now testing it!
Thanks.
-----Original Message-----
From: Juri Linkov [mailto:juri <at> linkov.net]
Sent: Wednesday, January 13, 2021 10:54 AM
To: Bob Floyd
Cc: 'Eli Zaretskii'; 45617 <at> debbugs.gnu.org
Subject: Re: bug#45617: <query-replace> loses the edit region. Works in
23.3, broke in 26.3
> Perhaps another way to think about this is that emacs is "mode-less".
>
> I can begin a command, recurse into another, pop out and resume the first
> command.
>
> Without the patch, or minibuffer fix, <query-replace> breaks that design.
So here is a simpler patch that fixes all query-replace commands:
diff --git a/lisp/replace.el b/lisp/replace.el
index d41dc98a0d..16b80a8fd1 100644
--- a/lisp/replace.el
+++ b/lisp/replace.el
@@ -327,6 +336,7 @@ query-replace-read-to
(defun query-replace-read-args (prompt regexp-flag &optional noerror)
(unless noerror
(barf-if-buffer-read-only))
+ (save-mark-and-excursion
(let* ((from (query-replace-read-from prompt regexp-flag))
(to (if (consp from) (prog1 (cdr from) (setq from (car from)))
(query-replace-read-to from prompt regexp-flag))))
@@ -334,7 +344,7 @@ query-replace-read-args
(or (and current-prefix-arg (not (eq current-prefix-arg '-)))
(and (plist-member (text-properties-at 0 from)
'isearch-regexp-function)
(get-text-property 0 'isearch-regexp-function from)))
- (and current-prefix-arg (eq current-prefix-arg '-)))))
+ (and current-prefix-arg (eq current-prefix-arg '-))))))
(defun query-replace (from-string to-string &optional delimited start end
backward region-noncontiguous-p)
"Replace some occurrences of FROM-STRING with TO-STRING.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#45617
; Package
emacs
.
(Fri, 15 Jan 2021 09:18:02 GMT)
Full text and
rfc822 format available.
Message #50 received at 45617 <at> debbugs.gnu.org (full text, mbox):
> I've removed the earlier patch and installed these changes. Now testing it!
> Thanks.
>
> -----Original Message-----
> (defun query-replace-read-args (prompt regexp-flag &optional noerror)
> (unless noerror
> (barf-if-buffer-read-only))
> + (save-mark-and-excursion
> (let* ((from (query-replace-read-from prompt regexp-flag))
> (to (if (consp from) (prog1 (cdr from) (setq from (car from)))
> (query-replace-read-to from prompt regexp-flag))))
It seems this is what we need to push to be able to close this bug report.
Indeed, it fixes only query-replace commands. But fixing all commands
that use the minibuffer is not as easy as adding 'save-mark-and-excursion'
like in the patch above.
The problem is that 'read-from-minibuffer' is implemented in C.
If it was implemented in Lisp, it would be easy to add just
'save-mark-and-excursion', but in C this is impossible.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#45617
; Package
emacs
.
(Fri, 15 Jan 2021 11:24:02 GMT)
Full text and
rfc822 format available.
Message #53 received at 45617 <at> debbugs.gnu.org (full text, mbox):
> From: Juri Linkov <juri <at> linkov.net>
> Cc: "'Eli Zaretskii'" <eliz <at> gnu.org>, <45617 <at> debbugs.gnu.org>
> Date: Fri, 15 Jan 2021 10:54:56 +0200
>
> The problem is that 'read-from-minibuffer' is implemented in C.
> If it was implemented in Lisp, it would be easy to add just
> 'save-mark-and-excursion', but in C this is impossible.
You can do the equivalent of that in C, can't you?
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#45617
; Package
emacs
.
(Fri, 15 Jan 2021 18:06:01 GMT)
Full text and
rfc822 format available.
Message #56 received at 45617 <at> debbugs.gnu.org (full text, mbox):
I'm having an issue with the new patch. <query-replace> fails!
1. Select entire region by dragging mouse.
2. Begin <query-replace>
In the command window: Query replace in region:
3. Enter RL using the keyboard
In the command window: Query replace in region RL with:
4. Now, with the mouse, select RL at line 12 ...
paramset P2 RL; <--- THIS ONE
... then yank it to the command window and with keyboard enter X:
In the command window: Query replace in region RL with: RLX
5. Enter
Only one of the two RL's in the region are selected, depending on
if the region was selected from top-to-bottom or bottom-to-top.
It should select both RL's!
----------------------------------------------------
module RL ( electrical in, out );
parameter real R1 = 7000.0;
parameter real C = 1p;
analog begin
I(in,out) <+ V(in,out) / R1;
I(out) <+ C * ddt( V(out) );
end
endmodule // Sub
paramset P2 RL;
parameter real R=1000;
.R1= R;
endparamset
----------------------------------------------------
Just in case I misread the diff, this is the function as I have manually
patched it:
(defun query-replace-read-args (prompt regexp-flag &optional noerror)
(unless noerror
(barf-if-buffer-read-only))
(save-mark-and-excursion
(let* ((from (query-replace-read-from prompt regexp-flag))
(to (if (consp from) (prog1 (cdr from) (setq from (car from)))
(query-replace-read-to from prompt regexp-flag))))
(or (and current-prefix-arg (not (eq current-prefix-arg '-)))
(and (plist-member (text-properties-at 0 from)
'isearch-regexp-function)
(get-text-property 0 'isearch-regexp-function from)))
(list from to
(and current-prefix-arg (not (eq current-prefix-arg '-)))
(and current-prefix-arg (eq current-prefix-arg '-))))))
-----Original Message-----
From: Juri Linkov [mailto:juri <at> linkov.net]
Sent: Friday, January 15, 2021 12:55 AM
To: Bob Floyd
Cc: 'Eli Zaretskii'; 45617 <at> debbugs.gnu.org
Subject: Re: bug#45617: <query-replace> loses the edit region. Works in
23.3, broke in 26.3
> I've removed the earlier patch and installed these changes. Now testing
it!
> Thanks.
>
> -----Original Message-----
> (defun query-replace-read-args (prompt regexp-flag &optional noerror)
> (unless noerror
> (barf-if-buffer-read-only))
> + (save-mark-and-excursion
> (let* ((from (query-replace-read-from prompt regexp-flag))
> (to (if (consp from) (prog1 (cdr from) (setq from (car from)))
> (query-replace-read-to from prompt regexp-flag))))
It seems this is what we need to push to be able to close this bug report.
Indeed, it fixes only query-replace commands. But fixing all commands
that use the minibuffer is not as easy as adding 'save-mark-and-excursion'
like in the patch above.
The problem is that 'read-from-minibuffer' is implemented in C.
If it was implemented in Lisp, it would be easy to add just
'save-mark-and-excursion', but in C this is impossible.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#45617
; Package
emacs
.
(Fri, 15 Jan 2021 18:10:02 GMT)
Full text and
rfc822 format available.
Message #59 received at 45617 <at> debbugs.gnu.org (full text, mbox):
PS: The 1st patch has the same wrong behavior also!
-----Original Message-----
From: Juri Linkov [mailto:juri <at> linkov.net]
Sent: Wednesday, January 13, 2021 10:54 AM
To: Bob Floyd
Cc: 'Eli Zaretskii'; 45617 <at> debbugs.gnu.org
Subject: Re: bug#45617: <query-replace> loses the edit region. Works in
23.3, broke in 26.3
> Perhaps another way to think about this is that emacs is "mode-less".
>
> I can begin a command, recurse into another, pop out and resume the first
> command.
>
> Without the patch, or minibuffer fix, <query-replace> breaks that design.
So here is a simpler patch that fixes all query-replace commands:
diff --git a/lisp/replace.el b/lisp/replace.el
index d41dc98a0d..16b80a8fd1 100644
--- a/lisp/replace.el
+++ b/lisp/replace.el
@@ -327,6 +336,7 @@ query-replace-read-to
(defun query-replace-read-args (prompt regexp-flag &optional noerror)
(unless noerror
(barf-if-buffer-read-only))
+ (save-mark-and-excursion
(let* ((from (query-replace-read-from prompt regexp-flag))
(to (if (consp from) (prog1 (cdr from) (setq from (car from)))
(query-replace-read-to from prompt regexp-flag))))
@@ -334,7 +344,7 @@ query-replace-read-args
(or (and current-prefix-arg (not (eq current-prefix-arg '-)))
(and (plist-member (text-properties-at 0 from)
'isearch-regexp-function)
(get-text-property 0 'isearch-regexp-function from)))
- (and current-prefix-arg (eq current-prefix-arg '-)))))
+ (and current-prefix-arg (eq current-prefix-arg '-))))))
(defun query-replace (from-string to-string &optional delimited start end
backward region-noncontiguous-p)
"Replace some occurrences of FROM-STRING with TO-STRING.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#45617
; Package
emacs
.
(Tue, 19 Jan 2021 17:59:02 GMT)
Full text and
rfc822 format available.
Message #62 received at 45617 <at> debbugs.gnu.org (full text, mbox):
> I'm having an issue with the new patch. <query-replace> fails!
Sorry, I tried your test case, but can't reproduce the problem.
> 1. Select entire region by dragging mouse.
> 2. Begin <query-replace>
> In the command window: Query replace in region:
> 3. Enter RL using the keyboard
> In the command window: Query replace in region RL with:
> 4. Now, with the mouse, select RL at line 12 ...
> paramset P2 RL; <--- THIS ONE
> ... then yank it to the command window and with keyboard enter X:
The most important line of your test case is the line above,
but I don't understand what you mean by yanking the selected text.
I tried to drag the selected text "RL" to the minibuffer window,
as all other apps allow to do, but Emacs fails to do the same.
Please help to clarify how do you yank the selected text.
> In the command window: Query replace in region RL with: RLX
> 5. Enter
> Only one of the two RL's in the region are selected, depending on
> if the region was selected from top-to-bottom or bottom-to-top.
>
> It should select both RL's!
It selects both RL's when I tried.
> Just in case I misread the diff, this is the function as I have manually
> patched it:
>
> (defun query-replace-read-args (prompt regexp-flag &optional noerror)
> (unless noerror
> (barf-if-buffer-read-only))
> (save-mark-and-excursion
> (let* ((from (query-replace-read-from prompt regexp-flag))
> (to (if (consp from) (prog1 (cdr from) (setq from (car from)))
> (query-replace-read-to from prompt regexp-flag))))
> (or (and current-prefix-arg (not (eq current-prefix-arg '-)))
> (and (plist-member (text-properties-at 0 from)
> 'isearch-regexp-function)
> (get-text-property 0 'isearch-regexp-function from)))
> (list from to
> (and current-prefix-arg (not (eq current-prefix-arg '-)))
> (and current-prefix-arg (eq current-prefix-arg '-))))))
This function is very much messed up. Please try the function below:
(defun query-replace-read-args (prompt regexp-flag &optional noerror)
(unless noerror
(barf-if-buffer-read-only))
(save-mark-and-excursion
(let* ((from (query-replace-read-from prompt regexp-flag))
(to (if (consp from) (prog1 (cdr from) (setq from (car from)))
(query-replace-read-to from prompt regexp-flag))))
(list from to
(or (and current-prefix-arg (not (eq current-prefix-arg '-)))
(and (plist-member (text-properties-at 0 from) 'isearch-regexp-function)
(get-text-property 0 'isearch-regexp-function from)))
(and current-prefix-arg (eq current-prefix-arg '-))))))
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#45617
; Package
emacs
.
(Tue, 19 Jan 2021 18:00:03 GMT)
Full text and
rfc822 format available.
Message #65 received at 45617 <at> debbugs.gnu.org (full text, mbox):
>> The problem is that 'read-from-minibuffer' is implemented in C.
>> If it was implemented in Lisp, it would be easy to add just
>> 'save-mark-and-excursion', but in C this is impossible.
>
> You can do the equivalent of that in C, can't you?
Sorry, I can't. Because 'save-mark-and-excursion' is a Lisp macro,
but C doesn't have Lisp macros.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#45617
; Package
emacs
.
(Tue, 19 Jan 2021 18:41:01 GMT)
Full text and
rfc822 format available.
Message #68 received at 45617 <at> debbugs.gnu.org (full text, mbox):
> From: Juri Linkov <juri <at> linkov.net>
> Cc: bobfloyd <at> comcast.net, 45617 <at> debbugs.gnu.org
> Date: Tue, 19 Jan 2021 19:45:09 +0200
>
> >> The problem is that 'read-from-minibuffer' is implemented in C.
> >> If it was implemented in Lisp, it would be easy to add just
> >> 'save-mark-and-excursion', but in C this is impossible.
> >
> > You can do the equivalent of that in C, can't you?
>
> Sorry, I can't. Because 'save-mark-and-excursion' is a Lisp macro,
> but C doesn't have Lisp macros.
I didn't mean to suggest that you call a Lisp macro. My suggestion
was to perform all the steps 'save-mark-and-excursion' does in C,
inline. I don't see why would that be hard, let alone impossible.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#45617
; Package
emacs
.
(Wed, 20 Jan 2021 22:49:01 GMT)
Full text and
rfc822 format available.
Message #71 received at 45617 <at> debbugs.gnu.org (full text, mbox):
Ok, no surprise that I got the function messed up. What I am using now
appears to be working:
-------------------------------------------------------------------
(defun query-replace-read-args (prompt regexp-flag &optional noerror)
(unless noerror
(barf-if-buffer-read-only))
(save-mark-and-excursion
(let* ((from (query-replace-read-from prompt regexp-flag))
(to (if (consp from) (prog1 (cdr from) (setq from (car from)))
(query-replace-read-to from prompt regexp-flag))))
(or (and current-prefix-arg (not (eq current-prefix-arg '-)))
(and (plist-member (text-properties-at 0 from)
'isearch-regexp-function)
(get-text-property 0 'isearch-regexp-function from)))
(list from to
(and current-prefix-arg (not (eq current-prefix-arg '-)))
(and current-prefix-arg (eq current-prefix-arg '-))))))
----------------------------------------------------------------------
Not sure what I did at this time for it to not work, sorry.
"yank" -> <mouse-2> mapped to "mouse-yank-at-click"
-----Original Message-----
From: Juri Linkov [mailto:juri <at> linkov.net]
Sent: Tuesday, January 19, 2021 9:44 AM
To: Bob Floyd
Cc: 'Eli Zaretskii'; 45617 <at> debbugs.gnu.org
Subject: Re: bug#45617: <query-replace> loses the edit region. Works in
23.3, broke in 26.3
> I'm having an issue with the new patch. <query-replace> fails!
Sorry, I tried your test case, but can't reproduce the problem.
> 1. Select entire region by dragging mouse.
> 2. Begin <query-replace>
> In the command window: Query replace in region:
> 3. Enter RL using the keyboard
> In the command window: Query replace in region RL with:
> 4. Now, with the mouse, select RL at line 12 ...
> paramset P2 RL; <--- THIS ONE
> ... then yank it to the command window and with keyboard enter X:
The most important line of your test case is the line above,
but I don't understand what you mean by yanking the selected text.
I tried to drag the selected text "RL" to the minibuffer window,
as all other apps allow to do, but Emacs fails to do the same.
Please help to clarify how do you yank the selected text.
> In the command window: Query replace in region RL with: RLX
> 5. Enter
> Only one of the two RL's in the region are selected, depending on
> if the region was selected from top-to-bottom or bottom-to-top.
>
> It should select both RL's!
It selects both RL's when I tried.
> Just in case I misread the diff, this is the function as I have manually
> patched it:
>
> (defun query-replace-read-args (prompt regexp-flag &optional noerror)
> (unless noerror
> (barf-if-buffer-read-only))
> (save-mark-and-excursion
> (let* ((from (query-replace-read-from prompt regexp-flag))
> (to (if (consp from) (prog1 (cdr from) (setq from (car from)))
> (query-replace-read-to from prompt regexp-flag))))
> (or (and current-prefix-arg (not (eq current-prefix-arg '-)))
> (and (plist-member (text-properties-at 0 from)
> 'isearch-regexp-function)
> (get-text-property 0 'isearch-regexp-function from)))
> (list from to
> (and current-prefix-arg (not (eq current-prefix-arg '-)))
> (and current-prefix-arg (eq current-prefix-arg '-))))))
This function is very much messed up. Please try the function below:
(defun query-replace-read-args (prompt regexp-flag &optional noerror)
(unless noerror
(barf-if-buffer-read-only))
(save-mark-and-excursion
(let* ((from (query-replace-read-from prompt regexp-flag))
(to (if (consp from) (prog1 (cdr from) (setq from (car from)))
(query-replace-read-to from prompt regexp-flag))))
(list from to
(or (and current-prefix-arg (not (eq current-prefix-arg '-)))
(and (plist-member (text-properties-at 0 from)
'isearch-regexp-function)
(get-text-property 0 'isearch-regexp-function from)))
(and current-prefix-arg (eq current-prefix-arg '-))))))
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#45617
; Package
emacs
.
(Wed, 20 Jan 2021 23:24:02 GMT)
Full text and
rfc822 format available.
Message #74 received at 45617 <at> debbugs.gnu.org (full text, mbox):
Sorry, sorry, my bad. Ignore my last email!
I'm now using the last version:
----------------------------------------------------
(defun query-replace-read-args (prompt regexp-flag &optional noerror)
(unless noerror
(barf-if-buffer-read-only))
(save-mark-and-excursion
(let* ((from (query-replace-read-from prompt regexp-flag))
(to (if (consp from) (prog1 (cdr from) (setq from (car from)))
(query-replace-read-to from prompt regexp-flag))))
(list from to
(or (and current-prefix-arg (not (eq current-prefix-arg '-)))
(and (plist-member (text-properties-at 0 from)
'isearch-regexp-function)
(get-text-property 0 'isearch-regexp-function from)))
(and current-prefix-arg (eq current-prefix-arg '-))))))
----------------------------------------------------
And this test:
-----------------------------------------------------
void
DHroot::ModuleToGoverningParamsets::
Insert
(IObj<BDHdfnsScope> const& _iDfnGoverned, IObj<BDHscope> const&
_iBDHparamset)
{
std::pair<ModuleToGoverningParamsets::TIterator,bool> _pr
( TBase::Insert( _iDfnGoverned, ParamsetsGoverningModule() ) );
ParamsetsGoverningModule& _prmsets( (*_pr.first).second );
_prmsets.Insert( _iBDHparamset, Unused() );
}
----------------------------------------------------
Do this:
1. Select entire region by dragging left mouse down from the BOTTOM to the
TOP.
2. Begin <query-replace>
In the command window: Query replace in region:
3. Double left mouse click on "_iDfnGoverned" at line 4 to select it:
(IObj<BDHdfnsScope> const& _iDfnGoverned <---THIS ONE , IObj<BDHscope>
const& _iBDHparamset)
4. middle mouse click in the command window to insert, then enter:
Query replace in region: _iDfnGoverned with:
Notice the selection region changes to lines 1-4 and is never restored.
5. middle mouse click in the command window to insert it again and edit:
Query replace in region _iDfnGoverned with: _iBDHdfnGoverned
6. Enter
Nothing happens!
Middle mouse click: <mouse-2> mouse-yank-at-click
Hope you can reproduce this!!!
-----Original Message-----
From: Juri Linkov [mailto:juri <at> linkov.net]
Sent: Tuesday, January 19, 2021 9:44 AM
To: Bob Floyd
Cc: 'Eli Zaretskii'; 45617 <at> debbugs.gnu.org
Subject: Re: bug#45617: <query-replace> loses the edit region. Works in
23.3, broke in 26.3
> I'm having an issue with the new patch. <query-replace> fails!
Sorry, I tried your test case, but can't reproduce the problem.
> 1. Select entire region by dragging mouse.
> 2. Begin <query-replace>
> In the command window: Query replace in region:
> 3. Enter RL using the keyboard
> In the command window: Query replace in region RL with:
> 4. Now, with the mouse, select RL at line 12 ...
> paramset P2 RL; <--- THIS ONE
> ... then yank it to the command window and with keyboard enter X:
The most important line of your test case is the line above,
but I don't understand what you mean by yanking the selected text.
I tried to drag the selected text "RL" to the minibuffer window,
as all other apps allow to do, but Emacs fails to do the same.
Please help to clarify how do you yank the selected text.
> In the command window: Query replace in region RL with: RLX
> 5. Enter
> Only one of the two RL's in the region are selected, depending on
> if the region was selected from top-to-bottom or bottom-to-top.
>
> It should select both RL's!
It selects both RL's when I tried.
> Just in case I misread the diff, this is the function as I have manually
> patched it:
>
> (defun query-replace-read-args (prompt regexp-flag &optional noerror)
> (unless noerror
> (barf-if-buffer-read-only))
> (save-mark-and-excursion
> (let* ((from (query-replace-read-from prompt regexp-flag))
> (to (if (consp from) (prog1 (cdr from) (setq from (car from)))
> (query-replace-read-to from prompt regexp-flag))))
> (or (and current-prefix-arg (not (eq current-prefix-arg '-)))
> (and (plist-member (text-properties-at 0 from)
> 'isearch-regexp-function)
> (get-text-property 0 'isearch-regexp-function from)))
> (list from to
> (and current-prefix-arg (not (eq current-prefix-arg '-)))
> (and current-prefix-arg (eq current-prefix-arg '-))))))
This function is very much messed up. Please try the function below:
(defun query-replace-read-args (prompt regexp-flag &optional noerror)
(unless noerror
(barf-if-buffer-read-only))
(save-mark-and-excursion
(let* ((from (query-replace-read-from prompt regexp-flag))
(to (if (consp from) (prog1 (cdr from) (setq from (car from)))
(query-replace-read-to from prompt regexp-flag))))
(list from to
(or (and current-prefix-arg (not (eq current-prefix-arg '-)))
(and (plist-member (text-properties-at 0 from)
'isearch-regexp-function)
(get-text-property 0 'isearch-regexp-function from)))
(and current-prefix-arg (eq current-prefix-arg '-))))))
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#45617
; Package
emacs
.
(Thu, 21 Jan 2021 21:57:02 GMT)
Full text and
rfc822 format available.
Message #77 received at 45617 <at> debbugs.gnu.org (full text, mbox):
> Sorry, sorry, my bad. Ignore my last email!
Indeed, in your previous email the function was still messed up,
but the right function is below, hope you used it in your test:
> I'm now using the last version:
> ----------------------------------------------------
> (defun query-replace-read-args (prompt regexp-flag &optional noerror)
> (unless noerror
> (barf-if-buffer-read-only))
> (save-mark-and-excursion
> (let* ((from (query-replace-read-from prompt regexp-flag))
> (to (if (consp from) (prog1 (cdr from) (setq from (car from)))
> (query-replace-read-to from prompt regexp-flag))))
> (list from to
> (or (and current-prefix-arg (not (eq current-prefix-arg '-)))
> (and (plist-member (text-properties-at 0 from)
> 'isearch-regexp-function)
> (get-text-property 0 'isearch-regexp-function from)))
> (and current-prefix-arg (eq current-prefix-arg '-))))))
> ----------------------------------------------------
> Do this:
>
> 1. Select entire region by dragging left mouse down from the BOTTOM to the
> TOP.
> 2. Begin <query-replace>
> In the command window: Query replace in region:
> 3. Double left mouse click on "_iDfnGoverned" at line 4 to select it:
> (IObj<BDHdfnsScope> const& _iDfnGoverned <---THIS ONE , IObj<BDHscope>
> const& _iBDHparamset)
> 4. middle mouse click in the command window to insert, then enter:
> Query replace in region: _iDfnGoverned with:
> Notice the selection region changes to lines 1-4 and is never restored.
> 5. middle mouse click in the command window to insert it again and edit:
> Query replace in region _iDfnGoverned with: _iBDHdfnGoverned
> 6. Enter
> Nothing happens!
>
> Middle mouse click: <mouse-2> mouse-yank-at-click
>
> Hope you can reproduce this!!!
Still can't reproduce this, everything works fine, all matches are replaced.
But I don't understand this line:
"Notice the selection region changes to lines 1-4 and is never restored."
I don't see that the selection region changes to lines 1-4. I see only
that the selection region is deactivated after I yank the selection
using middle mouse click <mouse-2>.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#45617
; Package
emacs
.
(Fri, 22 Jan 2021 17:33:02 GMT)
Full text and
rfc822 format available.
Message #80 received at 45617 <at> debbugs.gnu.org (full text, mbox):
Yes, I'm using the function in my test.
Ah, I think I see why you do not see the issue:
When I start a fresh copy of emacs and follow the steps it works correctly.
When I repeat the steps a 2nd, 3rd ... time, then it breaks.
After the 1st time <query-replace> shows this in the command window:
Query replace in region (default _iDfnGoverned → _iBDHdfnGoverned):
> "Notice the selection region changes to lines 1-4 and is never restored."
> I don't see that the selection region changes to lines 1-4. I see only
> that the selection region is deactivated after I yank the selection
> using middle mouse click <mouse-2>.
I believe you will see the selection region change when repeating the steps.
At least I hope so! If not, am I able to embed a jpg in a reply to one of
these emails?
-----Original Message-----
From: Juri Linkov [mailto:juri <at> linkov.net]
Sent: Thursday, January 21, 2021 1:51 PM
To: Bob Floyd
Cc: 'Eli Zaretskii'; 45617 <at> debbugs.gnu.org
Subject: Re: bug#45617: <query-replace> loses the edit region. Works in
23.3, broke in 26.3
> Sorry, sorry, my bad. Ignore my last email!
Indeed, in your previous email the function was still messed up,
but the right function is below, hope you used it in your test:
> I'm now using the last version:
> ----------------------------------------------------
> (defun query-replace-read-args (prompt regexp-flag &optional noerror)
> (unless noerror
> (barf-if-buffer-read-only))
> (save-mark-and-excursion
> (let* ((from (query-replace-read-from prompt regexp-flag))
> (to (if (consp from) (prog1 (cdr from) (setq from (car from)))
> (query-replace-read-to from prompt regexp-flag))))
> (list from to
> (or (and current-prefix-arg (not (eq current-prefix-arg '-)))
> (and (plist-member (text-properties-at 0 from)
> 'isearch-regexp-function)
> (get-text-property 0 'isearch-regexp-function from)))
> (and current-prefix-arg (eq current-prefix-arg '-))))))
> ----------------------------------------------------
> Do this:
>
> 1. Select entire region by dragging left mouse down from the BOTTOM to the
> TOP.
> 2. Begin <query-replace>
> In the command window: Query replace in region:
> 3. Double left mouse click on "_iDfnGoverned" at line 4 to select it:
> (IObj<BDHdfnsScope> const& _iDfnGoverned <---THIS ONE , IObj<BDHscope>
> const& _iBDHparamset)
> 4. middle mouse click in the command window to insert, then enter:
> Query replace in region: _iDfnGoverned with:
> Notice the selection region changes to lines 1-4 and is never restored.
> 5. middle mouse click in the command window to insert it again and edit:
> Query replace in region _iDfnGoverned with: _iBDHdfnGoverned
> 6. Enter
> Nothing happens!
>
> Middle mouse click: <mouse-2> mouse-yank-at-click
>
> Hope you can reproduce this!!!
Still can't reproduce this, everything works fine, all matches are replaced.
But I don't understand this line:
"Notice the selection region changes to lines 1-4 and is never restored."
I don't see that the selection region changes to lines 1-4. I see only
that the selection region is deactivated after I yank the selection
using middle mouse click <mouse-2>.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#45617
; Package
emacs
.
(Sat, 23 Jan 2021 17:35:02 GMT)
Full text and
rfc822 format available.
Message #83 received at 45617 <at> debbugs.gnu.org (full text, mbox):
> Yes, I'm using the function in my test.
>
> Ah, I think I see why you do not see the issue:
>
> When I start a fresh copy of emacs and follow the steps it works correctly.
> When I repeat the steps a 2nd, 3rd ... time, then it breaks.
>
> After the 1st time <query-replace> shows this in the command window:
> Query replace in region (default _iDfnGoverned → _iBDHdfnGoverned):
>
>> "Notice the selection region changes to lines 1-4 and is never restored."
>> I don't see that the selection region changes to lines 1-4. I see only
>> that the selection region is deactivated after I yank the selection
>> using middle mouse click <mouse-2>.
>
> I believe you will see the selection region change when repeating the steps.
>
> At least I hope so! If not, am I able to embed a jpg in a reply to one of
> these emails?
Do you mean that the region is deactivated after finishing query-replace?
That's how it's supposed to work. Please always select entire region
before starting query-replace again.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#45617
; Package
emacs
.
(Sat, 23 Jan 2021 18:05:01 GMT)
Full text and
rfc822 format available.
Message #86 received at 45617 <at> debbugs.gnu.org (full text, mbox):
>Do you mean that the region is deactivated after finishing query-replace?
>That's how it's supposed to work. Please always select entire region
>before starting query-replace again.
No, I always select the region, then begin <query-replace>.
When I see the previous replacement in the command window:
Query replace in region (default _nmRoot → _nmDolRoot):
Instead of:
Query replace:
Then I get the bad behavior.
-----Original Message-----
From: Juri Linkov [mailto:juri <at> linkov.net]
Sent: Saturday, January 23, 2021 9:21 AM
To: Bob Floyd
Cc: 'Eli Zaretskii'; 45617 <at> debbugs.gnu.org
Subject: Re: bug#45617: <query-replace> loses the edit region. Works in 23.3, broke in 26.3
> Yes, I'm using the function in my test.
>
> Ah, I think I see why you do not see the issue:
>
> When I start a fresh copy of emacs and follow the steps it works correctly.
> When I repeat the steps a 2nd, 3rd ... time, then it breaks.
>
> After the 1st time <query-replace> shows this in the command window:
> Query replace in region (default _iDfnGoverned ? _iBDHdfnGoverned):
>
>> "Notice the selection region changes to lines 1-4 and is never restored."
>> I don't see that the selection region changes to lines 1-4. I see only
>> that the selection region is deactivated after I yank the selection
>> using middle mouse click <mouse-2>.
>
> I believe you will see the selection region change when repeating the steps.
>
> At least I hope so! If not, am I able to embed a jpg in a reply to one of
> these emails?
Do you mean that the region is deactivated after finishing query-replace?
That's how it's supposed to work. Please always select entire region
before starting query-replace again.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#45617
; Package
emacs
.
(Sat, 23 Jan 2021 18:42:02 GMT)
Full text and
rfc822 format available.
Message #89 received at 45617 <at> debbugs.gnu.org (full text, mbox):
>>Do you mean that the region is deactivated after finishing query-replace?
>>That's how it's supposed to work. Please always select entire region
>>before starting query-replace again.
>
> No, I always select the region, then begin <query-replace>.
>
> When I see the previous replacement in the command window:
> Query replace in region (default _nmRoot → _nmDolRoot):
> Instead of:
> Query replace:
>
> Then I get the bad behavior.
Maybe you use own customization, not starting with 'emacs -Q'?
This might explain that after middle mouse click
your selection region changes to lines 1-4 and is never restored.
Because with 'emacs -Q' I see that the selection is deactivated
after middle mouse click, even when the previous replacement is:
Query replace in region (default _nmRoot → _nmDolRoot):.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#45617
; Package
emacs
.
(Sun, 24 Jan 2021 20:41:02 GMT)
Full text and
rfc822 format available.
Message #92 received at 45617 <at> debbugs.gnu.org (full text, mbox):
I'm embarrassed to include my .emacs file - it's an accumulation over time of a lot of stuff from unix and windows not cleaned up. Here it is: Maybe something in it causing the issue/ maybe not.
------------------------------------------------------------------------------------------------------------------------------
; To see ^M or write the file without ^M
; M-X set-variable<RET>
; inhibit-eol-conversion<RET>
; t<RET>
;(set-face-font default "Lucida Console")
;(set-default-font "Lucida Console")
;; Added by Package.el. This must come before configurations of
;; installed packages. Don't delete this line. If you don't want it,
;; just comment it out by adding a semicolon to the start of the line.
;; You may delete these explanatory comments.
(package-initialize)
(setenv "PATH" (concat "c:/cygwin/bin;" (getenv "PATH")))
(setq exec-path (cons "c:/cygwin/bin/" exec-path))
; Set emacs path in ".bashrc"
; emacs 22.3 & 23.1 complains
;(require 'cygwin-mount)
;(cygwin-mount-activate)
;;; Without this env var setting, Cygwin causes `ediff-buffers', at least,
;; to raise an error.
;;; Making this setting here might have no effect, as the env var is checked
;; only by the first Cygwin process
;;; invoked during your Windows session. For best results, set this env
;; var globally, in Windows itself.
;;; An alternative might be to use `cygpath' to change from MS Windows file
;; names to POSIX.
;(setenv "CYGWIN" "nodosfilewarning")
; Replace DOS shell with Cygwin Bash Shell
; see https://www.emacswiki.org/emacs/setup-cygwin.el
(add-hook 'comint-output-filter-functions
'shell-strip-ctrl-m nil t)
(add-hook 'comint-output-filter-functions
'comint-watch-for-password-prompt nil t)
;
(setq explicit-shell-file-name "bash")
(setq shell-file-name explicit-shell-file-name)
(setq explicit-bash-args '("-i"))
;(setq explicit-bash-args '("--login" "-i"))
;(setq explicit-shell-file-name "bash.exe")
;; For subprocesses invoked via the shell
;; (e.g., "shell -c command")
;(setq shell-file-name explicit-shell-file-name)
; Key Binding for Previous Commands
; Some people like to use the up and down arrow keys to traverse through the previous commands. Here is the way to bind the keys.
(add-hook 'shell-mode-hook 'n-shell-mode-hook)
(defun n-shell-mode-hook ()
"12Jan2002 - bob, shell mode customizations."
(local-set-key '[up] 'comint-previous-input)
(local-set-key '[down] 'comint-next-input)
(local-set-key '[(shift tab)] 'comint-next-matching-input-from-input)
;; suspend shell, not emacs
(local-set-key "\C-z" 'self-insert-command )
)
; Gzip and Gunzip
;When viewing files using the Emacs dired utility, press Z should compress or uncompress a file. Since Cygwin is equiped with the gzip utility, you should be able to get this function working on your Windows Gnu Emacs. The lisp statement you need in your .emacs file is
(setq archive-zip-use-pkzip nil)
;
; make searches case sensitive
;
(setq default-case-fold-search nil)
(setq-default case-fold-search nil)
;(setq auto-mode-list '("\\.d$" . c-mode))
; Enter c++ mode for .h files on windows - even though the file ends
; in .H emacs seems to think it's a little h and otherwise enters c mode
(setq auto-mode-alist (cons '("\\.h$" . c++-mode) auto-mode-alist))
(setq auto-mode-alist (cons '("\\.HPP$" . c++-mode) auto-mode-alist))
(setq auto-mode-alist (cons '("\\.D$" . c++-mode) auto-mode-alist))
; C customizing
; Note these constants enforce the location of {}'s and indentation.
;
; C-h i Indentation Functions
(require 'cc-mode)
(add-hook `c-mode-common-hook (lambda () (c-toggle-auto-state 1)))
;(add-hook `c-mode-common-hook (lambda () (c-toggle-hungry-state 1)))
; left '{' not indented
(c-set-offset 'substatement-open 0)
; c-lineup-multi-inher
(c-set-offset 'inher-cont 0)
; c-lineup-streamop
(c-set-offset 'stream-op 0)
; c-lineup-arglist
(c-set-offset 'arglist-cont-nonempty 0)
; c-lineup-arglist
;(c-set-offset 'arglist-intro 0)
;(c-set-offset 'arglist-close 0)
; c-lineup-math
(c-set-offset 'statement-cont 0)
; <RET> does auto indentation, like C-n
;(define-key c-mode-base-map "\C-m" 'c-context-line-break)
; syntax coloring
(global-font-lock-mode 1)
;(setq c-auto-newline t)
(setq c-tab-always-indent nil)
;(setq c-indent-level 4)
;(setq c-continued-statement-offset 4)
;(setq c-brace-offset -4)
;(setq c-brace-imaginary-offset 0)
;(setq c-argdecl-indent 2)
;(setq c-label-offset -4)
;(setq comment-multi-line t)
;(setq comment-start-skip "/\\*+[ \\n\\t]*")
;(setq comment-start "/*")
;(setq comment-end "*/")
; Matching '{' '}' , '<' '>', '[' ']' are hilighted
(show-paren-mode)
;
; compilation command
;
;(setq compile-command "make" )
;
; prevent deletion of auto saved files when the file is written
;
(setq delete-auto-save-files t)
;
; allow recursive use of minibuffers
;
(setq enable-recursive-minibuffers t)
;
; establish search paths to look for for programs
;
;(setq exec-path '("." "/usr/local/bin" "/usr/ucb" "/usr/bin" "/bin" "/mimi/devel/bin" "/mimi/emacs/etc"))
;
; establish the imagen printer as the one to default to
;
;(setq lpr-switches "-Pim")
;
; Regexp used by Newline command in shell mode to match subshell prompts.
;
;(setq shell-prompt-pattern "^.\.[0-9]*[0-9]>")
;
; Let emacs know about my P and p macros
;
;(setq shell-pushd-regexp "pushd\\|p")
;(setq shell-popd-regexp "popd")
;
;
; Rebind ESC-r (move-to-window-line) to replace-string
;
(global-unset-key "\er")
(global-set-key "\er" 'replace-string)
; Get rid of the tool bar icons which take up screen space by toggleing
(tool-bar-mode -1)
; Choose visible flicker instead of auditable bell rings
;(setq visible-bell t)
; Or just silence the bell entirely
(set-message-beep 'silent)
; See http://www.emacswiki.org/emacs/PrintingPackage#toc5
; See printing.el
; Printer must be shared on CACHE
;(setq printer-name "//CACHE/HP Photosmart C7200 series")
;(setq printer-name "D:/Bob/PrintFile.ps") ; print postscript to a file
(require 'printing) ; load printing package
(setq pr-gv-command "c:/Program Files/Ghostgum/gsview/gsview64.exe")
(setq pr-gs-command "c:/Program Files/gs/gs8.64/bin/gswin32.exe")
(setq pr-print-using-ghostscript t) ; C7280 is not a postscript printer
(setq pr-faces-p t) ; print colors, fonts etc.
(pr-update-menus t) ; update now printer and utility menus
; Default scrolling of 5 lines at a time is too much. This sets it to 1 line
(setq mouse-wheel-scroll-amount '(1 ((shift) . 1) ((control) . nil)))
(setq mouse-wheel-progressive-speed nil)
;
; Bind 'goto-line'
;
(global-unset-key "\C-x\C-l")
(global-set-key "\C-x\C-l" 'goto-line)
(global-set-key [f2] 'grep)
(global-set-key [f3] 'tags-search)
;
; Bind 'query-replace-regexp'
;
(global-unset-key "\e$")
(global-set-key "\e$" 'query-replace-regexp)
(global-unset-key "\ee")
(global-set-key "\ee" 'replace-regexp)
;
; These re-maps are done to allow xon/xoff
;
;(global-unset-key "\C-s")
;(global-set-key "\es" 'isearch-forward)
;(global-unset-key "\C-q")
;(global-unset-key "\eq")
;(global-set-key "\eq" 'quoted-insert)
;(load-file "/usr/local/lib/emacs/19.19/lisp/hilit19.el")
; (cond (window-system
; (setq hilit-mode-enable-list '(not text-mode)
; hilit-auto-highlight-maxout 150000
; hilit-background-mode 'light
; hilit-inhibit-hooks nil
; hilit-inhibit-rebinding nil)
;
; (require 'hilit19)
; ))
;(setq explicit-shell-file-name "C:/Program Files/Hamilton Shell/bin/csh.exe")
;(load-file "d:/src/cooksrc/database/emacs-setup.el")
;(global-set-key "\ep" 'cooksrc-file-preamble)
;
; Easy mark.
;
;(global-set-key "\C- " 'set-mark-command)
;
; Easy way to clear screen and enter shell command
;
;(global-set-key "\e\r" 'cr-top)
;
; cr-top and freeze screen
;
;(global-set-key "\C-x\r" 'cr-top-freeze)
;(transient-mark-mode nil)
;(setq vc-make-backup-files 1)
;(setq vc-mistrust-permissions nil)
;
; Region hilite when mark is active
;
(transient-mark-mode t)
;(setq shell-file-name "c:/cygwin/bin/bash")
;(setq explicit-shell-file-name "c:/cygwin/bin/bash")
(shell)
;(eshell)
;(eshell-command-result "rm -f BROWSE; ebrowse *.h *.cpp *.xml")
;(shell-command "rm -f BROWSE; ebrowse smt2/maxflowsttest.cpp *.y *.l *.cpp *.xml")
;(rename-buffer "sh-cook")
;(shell-command "cd d:/bob")
;(shell)
;(rename-buffer "sh-endogLib")
;(shell-command "cd d:/endogLib; rm -f BROWSE; ebrowse */*.h")
;(shell-process-cd "d:/endogLib")
;(eshell)
;(rename-buffer "sh-endogLib")
;(make-frame-command)
;(find-file "BROWSE")
;(global-set-key "\C-x4." 'ebrowse-tags-find-definition-other-window)
;(global-set-key "\C-x." 'ebrowse-tags-find-definition)
;(global-set-key "," 'ebrowse-tags-loop-continue)
(put 'upcase-region 'disabled nil)
(put 'downcase-region 'disabled nil)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; gcc 4.3.4 does not understand greek variables, e.g. \alpha, coded in
; utf-8. Visual Studio 10 does.
;(prefer-coding-system 'utf-8)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; http://iris.math.aegean.gr/~atsol/emacs-unicode/
; This does not format tex - it only converts keyboard input sequences
; into special characters.
; C-x RET C-\ TeX RET to enter TeX input method
; C-\ (toggle-input-method) toggles between latin and greek
; (describe-input-method) in TeX input method (mode line indicator:\)
; reveals the characters displayed and their LaTeX-like nmonic sequences.
;(load-file "C:/Program Files (x86)/Emacs-24.0.91/emacs-24.0.91/lisp/language/greek.el")
;(setq default-input-method "el_GR")
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(load "auctex.el" nil t t)
;; FIND THIS
;(load "preview-latex.el" nil t t)
; Refer to auctex.pdf Pp 54
;(setq TeX-auto-save nil)
; Refer to auctex.pdf Pp 55
;(setq TeX-parse-self t)
; Refer to auctex.pdf Pp 54
;(setq-default TeX-master "~/AUCTeXmaster")
(setq-default TeX-master t)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(setq TeX-electric-sub-and-superscript t)
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(display-mm-dimensions-alist (quote (("" 384 . 240))))
'(package-selected-packages (quote (auctex)))
'(safe-local-variable-values
(quote
((Base . 10)
(Syntax . Common-Lisp)
(Package . Maxima)))))
(custom-set-faces
;; custom-set-faces was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
)
;; recursive delete using "x" in Dired window without asking for each directory
(setq dired-recursive-deletes "t" )
;; Like C "{" matching for verilog
(eval-after-load 'verilog-mode
'(define-key verilog-mode-map (kbd "C-{") 'verilog-beg-of-defun))
(eval-after-load 'verilog-mode
'(define-key verilog-mode-map (kbd "C-}") 'verilog-end-of-defun))
(load-file "C:/Program Files/Emacs-26.3/share/emacs/site-lisp/web-mode.el")
;;(require 'web-mode)
(add-to-list 'auto-mode-alist '("\\.phtml\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.tpl\\.php\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.[agj]sp\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.as[cp]x\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.erb\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.mustache\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.djhtml\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.html?\\'" . web-mode))
(setq web-mode-markup-indent-offset 2)
(setq web-mode-css-indent-offset 2)
(setq web-mode-code-indent-offset 2)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; emacs 25 changes behavior. Here we restore it.
;; emacs 25 etags uses xref that no longer opens files so we need this
;; `https://stackoverflow.com/questions/7667888/how-to-find-the-files-in-tags-file-in-emacs`
(load-file "C:/Program Files/Emacs-26.3/share/emacs/site-lisp/tags-find-file.el")
(global-set-key (read-kbd-macro "C-,") 'tags-extra-find-file)
;; copying from windows clipboard
;; emacs 25 no longer yanks clipboard
;; `https://stackoverflow.com/questions/13036155/how-to-combine-emacs-primary-clipboard-copy-and-paste-behavior-on-ms-windows`
(setq select-active-regions nil)
(setq mouse-drag-copy-region t)
(global-set-key [mouse-2] 'mouse-yank-at-click)
;;;;;;;;;;;; IGNORE THIS STUFF ON WINDOWS ;;;;;;;;;;;;;;;;;;;;;;;
;; See NEWS.24 "Selection changes"
;; Above changes + these:
;(setq x-select-enable-primary t)
;(setq x-select-enable-clipboard nil)
;(global-set-key (kbd "<mouse-2>") 'clipboard-yank)
;;;;;;;;;;;; IGNORE THIS STUFF ON WINDOWS ;;;;;;;;;;;;;;;;;;;;;;;
; newline now does what C-j used to do and C-j does what newline did
(global-unset-key "\C-j")
(global-set-key "\C-j" 'newline)
(global-unset-key "\C-M")
(global-set-key "\C-M" 'electric-newline-and-maybe-indent)
(global-unset-key "\M-,")
(global-set-key "\M-," 'tags-loop-continue)
; Don't like shell opening in another buffer, in doing makes whatever was in
; it go away.
(push (cons "\\*shell\\*" display-buffer--same-window-action) display-buffer-alist)
(defun my-insert-file-name (filename &optional args)
"Insert name of file FILENAME into buffer after point.
Prefixed with \\[universal-argument], expand the file name to
its fully canocalized path. See `expand-file-name'.
Prefixed with \\[negative-argument], use relative path to file
name from current directory, `default-directory'. See
`file-relative-name'.
The default with no prefix is to insert the file name exactly as
it appears in the minibuffer prompt."
;; Based on insert-file in Emacs -- ashawley 20080926
(interactive "*fInsert file name: \nP")
(cond ((eq '- args)
(insert (file-relative-name filename)))
((not (null args))
(insert (expand-file-name filename)))
(t
(insert filename))))
(global-set-key "\M-n" 'my-insert-file-name)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; https://stackoverflow.com/questions/13505113/how-to-open-the-native-cmd-exe-window-in-emacs
; M-x cmd opens a window running the windows developer cmd prompt in the
; directory of the emacs buffer.
(defun cmd () (interactive)
(let ((proc (start-process "cmd" nil "cmd.exe" "/C" "start" "cmd.exe"
"/K" "C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Professional\\Common7\\Tools\\VsDevCmd.bat")))
(set-process-query-on-exit-flag proc nil))
)
; M-x fiex opens the windows File Explorer in the directory of the emacs buffer.
(defun fiex () (interactive)
(let ((proc (start-process "cmd" nil "cmd.exe" "/K" "explorer .")))
(set-process-query-on-exit-flag proc nil))
)
;;
------------------------------------------------------------------------------------------------------------------------------
-----Original Message-----
From: Juri Linkov [mailto:juri <at> linkov.net]
Sent: Saturday, January 23, 2021 10:31 AM
To: Bob Floyd
Cc: 'Eli Zaretskii'; 45617 <at> debbugs.gnu.org
Subject: Re: bug#45617: <query-replace> loses the edit region. Works in 23.3, broke in 26.3
>>Do you mean that the region is deactivated after finishing query-replace?
>>That's how it's supposed to work. Please always select entire region
>>before starting query-replace again.
>
> No, I always select the region, then begin <query-replace>.
>
> When I see the previous replacement in the command window:
> Query replace in region (default _nmRoot ? _nmDolRoot):
> Instead of:
> Query replace:
>
> Then I get the bad behavior.
Maybe you use own customization, not starting with 'emacs -Q'?
This might explain that after middle mouse click
your selection region changes to lines 1-4 and is never restored.
Because with 'emacs -Q' I see that the selection is deactivated
after middle mouse click, even when the previous replacement is:
Query replace in region (default _nmRoot ? _nmDolRoot):.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#45617
; Package
emacs
.
(Mon, 25 Jan 2021 17:09:03 GMT)
Full text and
rfc822 format available.
Message #95 received at 45617 <at> debbugs.gnu.org (full text, mbox):
> I'm embarrassed to include my .emacs file - it's an accumulation over
> time of a lot of stuff from unix and windows not cleaned up. Here it
> is: Maybe something in it causing the issue/ maybe not.
This means you don't see the problem when you don't load your .emacs file?
So when you start with 'emacs -Q' there is no problem?
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#45617
; Package
emacs
.
(Mon, 25 Jan 2021 18:14:02 GMT)
Full text and
rfc822 format available.
Message #98 received at 45617 <at> debbugs.gnu.org (full text, mbox):
I tried, for the first time, 'emacs -Q', repeatedly doing
1. select region by dragging mouse-1, sometimes top-to-bottom, sometimes
bottom-to-top
2. start <query-replace>
3. double click mouse-1 on some text on a top line, always the same text
4. yank that text to the command example:
Query replace in region _xxx with:
5. with keyboard enter
Query replace in region _xxx with: _iSmbl
6. then keyboard <enter> to start.
It was doing the expected, correct, query replace, for the first, oh, maybe
six times, then got into the broken state and when I repeat the above
sequence it behaves as if there was no region selected and no replacements
are offered (Replaced 0 occurences).
It seems like something was not restored correctly. I cannot say I precisely
followed the above steps for the first times when it was working - I wanted
to vary the sequence a bit (sometimes entering from the keyboard, sometimes
selecting text from a lower line in the selection) to see if I could break
it. I cannot be more specific about exactly which sequence broke it, only
that now, when it's broken, it consistently does not work!
-----Original Message-----
From: Juri Linkov [mailto:juri <at> linkov.net]
Sent: Monday, January 25, 2021 9:07 AM
To: Bob Floyd
Cc: 'Eli Zaretskii'; 45617 <at> debbugs.gnu.org
Subject: Re: bug#45617: <query-replace> loses the edit region. Works in
23.3, broke in 26.3
> I'm embarrassed to include my .emacs file - it's an accumulation over
> time of a lot of stuff from unix and windows not cleaned up. Here it
> is: Maybe something in it causing the issue/ maybe not.
This means you don't see the problem when you don't load your .emacs file?
So when you start with 'emacs -Q' there is no problem?
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#45617
; Package
emacs
.
(Mon, 25 Jan 2021 18:56:02 GMT)
Full text and
rfc822 format available.
Message #101 received at 45617 <at> debbugs.gnu.org (full text, mbox):
> It was doing the expected, correct, query replace, for the first, oh, maybe
> six times, then got into the broken state and when I repeat the above
> sequence it behaves as if there was no region selected and no replacements
> are offered (Replaced 0 occurences).
This is strange because if there is no region selected, this means that
it should replace everywhere in the whole buffer (but only when point is
at the beginning of the buffer).
> It seems like something was not restored correctly. I cannot say I precisely
> followed the above steps for the first times when it was working - I wanted
> to vary the sequence a bit (sometimes entering from the keyboard, sometimes
> selecting text from a lower line in the selection) to see if I could break
> it. I cannot be more specific about exactly which sequence broke it, only
> that now, when it's broken, it consistently does not work!
It could help you to debug when you insert the following line
in 'query-replace' immediately before the 'perform-replace' call:
(message "region: %S %S" start end)
Then after query-replace you could check in the *Messages* buffer
and see the exact region boundaries used. If there are 'nil' values,
this might mean there is a bug in save-mark-and-excursion.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#45617
; Package
emacs
.
(Mon, 25 Jan 2021 19:35:02 GMT)
Full text and
rfc822 format available.
Message #104 received at 45617 <at> debbugs.gnu.org (full text, mbox):
>This is strange because if there is no region selected, this means that
>it should replace everywhere in the whole buffer (but only when point is
>at the beginning of the buffer).
Agreed, but that is what it does. Perhaps a clue?
I put the message in below as you suggest, but the result is as though no
region is selected - it replaces everywhere in the whole buffer:
(interactive
(let ((common
(query-replace-read-args
(concat "Query replace"
(if current-prefix-arg
(if (eq current-prefix-arg '-) " backward" " word")
"")
(if (use-region-p) " in region" ""))
nil)))
(list (nth 0 common) (nth 1 common) (nth 2 common)
;; These are done separately here
;; so that command-history will record these expressions
;; rather than the values they had this time.
(if (use-region-p) (region-beginning))
(if (use-region-p) (region-end))
(nth 3 common)
(if (use-region-p) (region-noncontiguous-p)))))
(message "region: %S %S" start end)
(perform-replace from-string to-string t nil delimited nil nil start end
backward region-noncontiguous-p))
And *Messages* only contains:
Mark saved where search started
Mark set [2 times]
Replaced 11 occurences
The region I selected contained only 3 occurences.
Have I put your message in the correct place?
-----Original Message-----
From: Juri Linkov [mailto:juri <at> linkov.net]
Sent: Monday, January 25, 2021 10:54 AM
To: Bob Floyd
Cc: 'Eli Zaretskii'; 45617 <at> debbugs.gnu.org
Subject: Re: bug#45617: <query-replace> loses the edit region. Works in
23.3, broke in 26.3
> It was doing the expected, correct, query replace, for the first, oh,
maybe
> six times, then got into the broken state and when I repeat the above
> sequence it behaves as if there was no region selected and no replacements
> are offered (Replaced 0 occurences).
This is strange because if there is no region selected, this means that
it should replace everywhere in the whole buffer (but only when point is
at the beginning of the buffer).
> It seems like something was not restored correctly. I cannot say I
precisely
> followed the above steps for the first times when it was working - I
wanted
> to vary the sequence a bit (sometimes entering from the keyboard,
sometimes
> selecting text from a lower line in the selection) to see if I could break
> it. I cannot be more specific about exactly which sequence broke it, only
> that now, when it's broken, it consistently does not work!
It could help you to debug when you insert the following line
in 'query-replace' immediately before the 'perform-replace' call:
(message "region: %S %S" start end)
Then after query-replace you could check in the *Messages* buffer
and see the exact region boundaries used. If there are 'nil' values,
this might mean there is a bug in save-mark-and-excursion.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#45617
; Package
emacs
.
(Mon, 25 Jan 2021 19:53:02 GMT)
Full text and
rfc822 format available.
Message #107 received at 45617 <at> debbugs.gnu.org (full text, mbox):
> I put the message in below as you suggest, but the result is as though no
> region is selected - it replaces everywhere in the whole buffer:
>
> And *Messages* only contains:
>
> Mark saved where search started
> Mark set [2 times]
> Replaced 11 occurences
>
> The region I selected contained only 3 occurences.
>
> Have I put your message in the correct place?
Yes, the correct place. Maybe you need to compile it or just evaluate.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#45617
; Package
emacs
.
(Tue, 26 Jan 2021 00:35:01 GMT)
Full text and
rfc822 format available.
Message #110 received at 45617 <at> debbugs.gnu.org (full text, mbox):
It looks like the `replace.elc` file I've been creating isn't being loaded:
I changed:
(message "Replaced %d occurrence%s%s"
To:
(message "Replaced XX %d occurrence%s%s"
And the *Messages* buffer still shows:
Replaced 3 occurences
I've verified the elc file is re-written each time I change and
byte-compile-file replace.el.
Is there a command that shows the paths to the elc files loaded? Or, does a
new instance of emacs share elc's from an existing running copy of emacs
(that would be pretty geeky!)? I'm doing my tests with an emacs running for
several days now, assuming it would not interfere.
-----Original Message-----
From: Juri Linkov [mailto:juri <at> linkov.net]
Sent: Monday, January 25, 2021 11:52 AM
To: Bob Floyd
Cc: 'Eli Zaretskii'; 45617 <at> debbugs.gnu.org
Subject: Re: bug#45617: <query-replace> loses the edit region. Works in
23.3, broke in 26.3
> I put the message in below as you suggest, but the result is as though no
> region is selected - it replaces everywhere in the whole buffer:
>
> And *Messages* only contains:
>
> Mark saved where search started
> Mark set [2 times]
> Replaced 11 occurences
>
> The region I selected contained only 3 occurences.
>
> Have I put your message in the correct place?
Yes, the correct place. Maybe you need to compile it or just evaluate.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#45617
; Package
emacs
.
(Wed, 27 Jan 2021 09:56:02 GMT)
Full text and
rfc822 format available.
Message #113 received at 45617 <at> debbugs.gnu.org (full text, mbox):
> It looks like the `replace.elc` file I've been creating isn't being loaded:
>
> I changed:
> (message "Replaced %d occurrence%s%s"
> To:
> (message "Replaced XX %d occurrence%s%s"
>
> And the *Messages* buffer still shows:
> Replaced 3 occurences
>
> I've verified the elc file is re-written each time I change and
> byte-compile-file replace.el.
>
> Is there a command that shows the paths to the elc files loaded? Or, does a
> new instance of emacs share elc's from an existing running copy of emacs
> (that would be pretty geeky!)? I'm doing my tests with an emacs running for
> several days now, assuming it would not interfere.
Maybe the simplest way is that you can temporarily copy redefined
functions to your .emacs file, and you can evaluate redefined functions
using C-M-x.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#45617
; Package
emacs
.
(Thu, 28 Jan 2021 16:33:02 GMT)
Full text and
rfc822 format available.
Message #116 received at 45617 <at> debbugs.gnu.org (full text, mbox):
Good idea. I placed this query-replaceX in my .emacs:
(defun query-replaceX (from-string to-string &optional delimited start end
backward region-noncontiguous-p)
(interactive
(let ((common
(query-replace-read-args
(concat "Query replace"
(if current-prefix-arg
(if (eq current-prefix-arg '-) " backward" " word")
"")
(if (use-region-p) " in region" ""))
nil)))
(list (nth 0 common) (nth 1 common) (nth 2 common)
;; These are done separately here
;; so that command-history will record these expressions
;; rather than the values they had this time.
(if (use-region-p) (region-beginning))
(if (use-region-p) (region-end))
(nth 3 common)
(if (use-region-p) (region-noncontiguous-p)))))
(message "region: %S %S" start end)
(perform-replace from-string to-string t nil delimited nil nil start end
backward region-noncontiguous-p))
1. Select region by dragging left mouse
2. ESC-x query-replaceX to start the above
3. double-mouse click on the last _xxx in the selected region
CompilationUnit::Elaborate::Setup::InitOrderKey::
Cmp( TThis const& _r ) const
{
int _xxx;
// Primary sort is by phase to group all symbols in a phase together.
if ( ( _xxx = phase - _r.phase ) != 0 )
return _cmp; <<<<------------ double mouse click on this (was _xxx)
4. keyboard enter _cmp, so the command window looks like:
Query replace in region (default _cmp → _xxx): _xxx with: _cmp
5. keyboard enter. The result is the above snippet of code, it incorrectly
replaced only 1 of the 3 _xxx's
Here is the *Messages* buffer beginning with the (1) select region:
Mark set
region: 6576 6582
Mark set
Replaced 1 occurrence
Auto-saving...done
Mark set
What would you like me to do next?
-----Original Message-----
From: Juri Linkov [mailto:juri <at> linkov.net]
Sent: Wednesday, January 27, 2021 1:44 AM
To: Bob Floyd
Cc: 'Eli Zaretskii'; 45617 <at> debbugs.gnu.org
Subject: Re: bug#45617: <query-replace> loses the edit region. Works in
23.3, broke in 26.3
> It looks like the `replace.elc` file I've been creating isn't being
loaded:
>
> I changed:
> (message "Replaced %d occurrence%s%s"
> To:
> (message "Replaced XX %d occurrence%s%s"
>
> And the *Messages* buffer still shows:
> Replaced 3 occurences
>
> I've verified the elc file is re-written each time I change and
> byte-compile-file replace.el.
>
> Is there a command that shows the paths to the elc files loaded? Or, does
a
> new instance of emacs share elc's from an existing running copy of emacs
> (that would be pretty geeky!)? I'm doing my tests with an emacs running
for
> several days now, assuming it would not interfere.
Maybe the simplest way is that you can temporarily copy redefined
functions to your .emacs file, and you can evaluate redefined functions
using C-M-x.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#45617
; Package
emacs
.
(Thu, 28 Jan 2021 18:58:01 GMT)
Full text and
rfc822 format available.
Message #119 received at 45617 <at> debbugs.gnu.org (full text, mbox):
> Good idea. I placed this query-replaceX in my .emacs:
Thanks.
> Here is the *Messages* buffer beginning with the (1) select region:
>
> Mark set
> region: 6576 6582
This means that the fixed function query-replace-read-args
is not loaded.
> Mark set
> Replaced 1 occurrence
> Auto-saving...done
> Mark set
>
> What would you like me to do next?
I'd recommend you to place the fixed function query-replace-read-args
in your .emacs the same way as you placed query-replaceX.
If you want, you can rename it, then the caller should be renamed as well.
Or you could try to place it in .emacs without renaming:
(defun query-replace-read-args (prompt regexp-flag &optional noerror)
(unless noerror
(barf-if-buffer-read-only))
(save-mark-and-excursion
(let* ((from (query-replace-read-from prompt regexp-flag))
(to (if (consp from) (prog1 (cdr from) (setq from (car from)))
(query-replace-read-to from prompt regexp-flag))))
(list from to
(or (and current-prefix-arg (not (eq current-prefix-arg '-)))
(and (plist-member (text-properties-at 0 from) 'isearch-regexp-function)
(get-text-property 0 'isearch-regexp-function from)))
(and current-prefix-arg (eq current-prefix-arg '-))))))
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#45617
; Package
emacs
.
(Thu, 28 Jan 2021 21:33:01 GMT)
Full text and
rfc822 format available.
Message #122 received at 45617 <at> debbugs.gnu.org (full text, mbox):
I added query-replace-read-argsX to my .emacs file and changed the caller.
Several trys and it appears to be working!
*Messages*:
Mark set
region: 6336 6582
Mark set
Replaced 3 occurrences
Mark set
region: 6337 6582
Mark set
Replaced 3 occurrences
Mark set
region: 6343 6582
Mark set
Replaced 3 occurrences
Mark set
region: 6336 6582
Mark set
Replaced 3 occurrences
So it looks to me like the problem has something to do with 'c:/Program
Files/Emacs-26.3/share/emacs/26.3/lisp/replace.elc' not being loaded, even
when I run '"C:\Program Files\Emacs-26.3\bin\runemacs.exe" -Q'.
Correct?
-----Original Message-----
From: Juri Linkov [mailto:juri <at> linkov.net]
Sent: Thursday, January 28, 2021 10:42 AM
To: Bob Floyd
Cc: 'Eli Zaretskii'; 45617 <at> debbugs.gnu.org
Subject: Re: bug#45617: <query-replace> loses the edit region. Works in
23.3, broke in 26.3
> Good idea. I placed this query-replaceX in my .emacs:
Thanks.
> Here is the *Messages* buffer beginning with the (1) select region:
>
> Mark set
> region: 6576 6582
This means that the fixed function query-replace-read-args
is not loaded.
> Mark set
> Replaced 1 occurrence
> Auto-saving...done
> Mark set
>
> What would you like me to do next?
I'd recommend you to place the fixed function query-replace-read-args
in your .emacs the same way as you placed query-replaceX.
If you want, you can rename it, then the caller should be renamed as well.
Or you could try to place it in .emacs without renaming:
(defun query-replace-read-args (prompt regexp-flag &optional noerror)
(unless noerror
(barf-if-buffer-read-only))
(save-mark-and-excursion
(let* ((from (query-replace-read-from prompt regexp-flag))
(to (if (consp from) (prog1 (cdr from) (setq from (car from)))
(query-replace-read-to from prompt regexp-flag))))
(list from to
(or (and current-prefix-arg (not (eq current-prefix-arg '-)))
(and (plist-member (text-properties-at 0 from)
'isearch-regexp-function)
(get-text-property 0 'isearch-regexp-function from)))
(and current-prefix-arg (eq current-prefix-arg '-))))))
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#45617
; Package
emacs
.
(Fri, 29 Jan 2021 09:00:02 GMT)
Full text and
rfc822 format available.
Message #125 received at 45617 <at> debbugs.gnu.org (full text, mbox):
tags 45617 fixed
close 45617 28.0.50
thanks
> I added query-replace-read-argsX to my .emacs file and changed the caller.
> Several trys and it appears to be working!
Thank you very much for testing. Now the fix is pushed to master,
and this bug report is closed.
> *Messages*:
> ...
>
> So it looks to me like the problem has something to do with 'c:/Program
> Files/Emacs-26.3/share/emacs/26.3/lisp/replace.elc' not being loaded, even
> when I run '"C:\Program Files\Emacs-26.3\bin\runemacs.exe" -Q'.
>
> Correct?
Indeed. There may be many reasons why replace.elc is not being loaded.
The default value of 'load-prefer-newer' is nil. That means after you edit
the file, it still loads an older version.
Added tag(s) fixed.
Request was from
Juri Linkov <juri <at> linkov.net>
to
control <at> debbugs.gnu.org
.
(Fri, 29 Jan 2021 09:00:03 GMT)
Full text and
rfc822 format available.
bug marked as fixed in version 28.0.50, send any further explanations to
45617 <at> debbugs.gnu.org and "Bob Floyd" <bobfloyd <at> comcast.net>
Request was from
Juri Linkov <juri <at> linkov.net>
to
control <at> debbugs.gnu.org
.
(Fri, 29 Jan 2021 09:00:03 GMT)
Full text and
rfc822 format available.
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Fri, 26 Feb 2021 12:24:06 GMT)
Full text and
rfc822 format available.
This bug report was last modified 3 years and 255 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.