* bug#45617: <query-replace> loses the edit region. Works in 23.3, broke in 26.3 @ 2021-01-03 1:05 Bob Floyd 2021-01-03 14:47 ` Eli Zaretskii 0 siblings, 1 reply; 41+ messages in thread From: Bob Floyd @ 2021-01-03 1:05 UTC (permalink / raw) To: 45617 [-- Attachment #1: Type: text/plain, Size: 873 bytes --] 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. [-- Attachment #2: Type: text/html, Size: 4054 bytes --] ^ permalink raw reply [flat|nested] 41+ messages in thread
* bug#45617: <query-replace> loses the edit region. Works in 23.3, broke in 26.3 2021-01-03 1:05 bug#45617: <query-replace> loses the edit region. Works in 23.3, broke in 26.3 Bob Floyd @ 2021-01-03 14:47 ` Eli Zaretskii 2021-01-03 19:18 ` Bob Floyd 2021-01-04 17:37 ` Juri Linkov 0 siblings, 2 replies; 41+ messages in thread From: Eli Zaretskii @ 2021-01-03 14:47 UTC (permalink / raw) To: Bob Floyd; +Cc: 45617 > From: "Bob Floyd" <bobfloyd@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. ^ permalink raw reply [flat|nested] 41+ messages in thread
* bug#45617: <query-replace> loses the edit region. Works in 23.3, broke in 26.3 2021-01-03 14:47 ` Eli Zaretskii @ 2021-01-03 19:18 ` Bob Floyd 2021-01-04 17:26 ` Eli Zaretskii 2021-01-04 17:37 ` Juri Linkov 1 sibling, 1 reply; 41+ messages in thread From: Bob Floyd @ 2021-01-03 19:18 UTC (permalink / raw) To: 'Eli Zaretskii'; +Cc: 45617 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@gnu.org] Sent: Sunday, January 3, 2021 6:48 AM To: Bob Floyd Cc: 45617@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@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. ^ permalink raw reply [flat|nested] 41+ messages in thread
* bug#45617: <query-replace> loses the edit region. Works in 23.3, broke in 26.3 2021-01-03 19:18 ` Bob Floyd @ 2021-01-04 17:26 ` Eli Zaretskii 0 siblings, 0 replies; 41+ messages in thread From: Eli Zaretskii @ 2021-01-04 17:26 UTC (permalink / raw) To: Bob Floyd; +Cc: 45617 > From: "Bob Floyd" <bobfloyd@comcast.net> > Cc: <45617@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. ^ permalink raw reply [flat|nested] 41+ messages in thread
* bug#45617: <query-replace> loses the edit region. Works in 23.3, broke in 26.3 2021-01-03 14:47 ` Eli Zaretskii 2021-01-03 19:18 ` Bob Floyd @ 2021-01-04 17:37 ` Juri Linkov 2021-01-04 22:40 ` Bob Floyd 1 sibling, 1 reply; 41+ messages in thread From: Juri Linkov @ 2021-01-04 17:37 UTC (permalink / raw) To: Eli Zaretskii; +Cc: Bob Floyd, 45617 [-- Attachment #1: Type: text/plain, Size: 551 bytes --] >> 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: [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #2: query-replace-region.patch --] [-- Type: text/x-diff, Size: 1119 bytes --] diff --git a/lisp/replace.el b/lisp/replace.el index 9765b2b5be..c5acf8fca7 100644 --- a/lisp/replace.el +++ b/lisp/replace.el @@ -395,7 +395,10 @@ query-replace To customize possible responses, change the bindings in `query-replace-map'." (interactive - (let ((common + (let ((start (if (use-region-p) (region-beginning))) + (end (if (use-region-p) (region-end))) + (region-noncontiguous-p (if (use-region-p) (region-noncontiguous-p))) + (common (query-replace-read-args (concat "Query replace" (if current-prefix-arg @@ -407,10 +410,7 @@ query-replace ;; 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))))) + start end (nth 3 common) region-noncontiguous-p))) (perform-replace from-string to-string t nil delimited nil nil start end backward region-noncontiguous-p)) (define-key esc-map "%" 'query-replace) [-- Attachment #3: Type: text/plain, Size: 831 bytes --] 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. ^ permalink raw reply related [flat|nested] 41+ messages in thread
* bug#45617: <query-replace> loses the edit region. Works in 23.3, broke in 26.3 2021-01-04 17:37 ` Juri Linkov @ 2021-01-04 22:40 ` Bob Floyd 2021-01-05 18:27 ` Juri Linkov 0 siblings, 1 reply; 41+ messages in thread From: Bob Floyd @ 2021-01-04 22:40 UTC (permalink / raw) To: 'Juri Linkov', 'Eli Zaretskii'; +Cc: 45617 Thanks! The patch has fixed the issue. -----Original Message----- From: Juri Linkov [mailto:juri@linkov.net] Sent: Monday, January 4, 2021 9:37 AM To: Eli Zaretskii Cc: Bob Floyd; 45617@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: ^ permalink raw reply [flat|nested] 41+ messages in thread
* bug#45617: <query-replace> loses the edit region. Works in 23.3, broke in 26.3 2021-01-04 22:40 ` Bob Floyd @ 2021-01-05 18:27 ` Juri Linkov 2021-01-05 19:45 ` Bob Floyd 0 siblings, 1 reply; 41+ messages in thread From: Juri Linkov @ 2021-01-05 18:27 UTC (permalink / raw) To: Bob Floyd; +Cc: 45617 > 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). ^ permalink raw reply [flat|nested] 41+ messages in thread
* bug#45617: <query-replace> loses the edit region. Works in 23.3, broke in 26.3 2021-01-05 18:27 ` Juri Linkov @ 2021-01-05 19:45 ` Bob Floyd 2021-01-06 17:44 ` Juri Linkov 0 siblings, 1 reply; 41+ messages in thread From: Bob Floyd @ 2021-01-05 19:45 UTC (permalink / raw) To: 'Juri Linkov'; +Cc: 45617 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@linkov.net] Sent: Tuesday, January 5, 2021 10:27 AM To: Bob Floyd Cc: 'Eli Zaretskii'; 45617@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). ^ permalink raw reply [flat|nested] 41+ messages in thread
* bug#45617: <query-replace> loses the edit region. Works in 23.3, broke in 26.3 2021-01-05 19:45 ` Bob Floyd @ 2021-01-06 17:44 ` Juri Linkov 2021-01-06 18:19 ` Eli Zaretskii 0 siblings, 1 reply; 41+ messages in thread From: Juri Linkov @ 2021-01-06 17:44 UTC (permalink / raw) To: Bob Floyd; +Cc: 45617 > 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. ^ permalink raw reply [flat|nested] 41+ messages in thread
* bug#45617: <query-replace> loses the edit region. Works in 23.3, broke in 26.3 2021-01-06 17:44 ` Juri Linkov @ 2021-01-06 18:19 ` Eli Zaretskii 2021-01-06 22:10 ` Bob Floyd 2021-01-07 18:46 ` Juri Linkov 0 siblings, 2 replies; 41+ messages in thread From: Eli Zaretskii @ 2021-01-06 18:19 UTC (permalink / raw) To: Juri Linkov; +Cc: bobfloyd, 45617 > From: Juri Linkov <juri@linkov.net> > Cc: "'Eli Zaretskii'" <eliz@gnu.org>, <45617@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. ^ permalink raw reply [flat|nested] 41+ messages in thread
* bug#45617: <query-replace> loses the edit region. Works in 23.3, broke in 26.3 2021-01-06 18:19 ` Eli Zaretskii @ 2021-01-06 22:10 ` Bob Floyd 2021-01-13 18:53 ` Juri Linkov 2021-01-07 18:46 ` Juri Linkov 1 sibling, 1 reply; 41+ messages in thread From: Bob Floyd @ 2021-01-06 22:10 UTC (permalink / raw) To: 'Eli Zaretskii', 'Juri Linkov'; +Cc: 45617 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@gnu.org] Sent: Wednesday, January 6, 2021 10:19 AM To: Juri Linkov Cc: bobfloyd@comcast.net; 45617@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@linkov.net> > Cc: "'Eli Zaretskii'" <eliz@gnu.org>, <45617@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. ^ permalink raw reply [flat|nested] 41+ messages in thread
* bug#45617: <query-replace> loses the edit region. Works in 23.3, broke in 26.3 2021-01-06 22:10 ` Bob Floyd @ 2021-01-13 18:53 ` Juri Linkov 2021-01-15 1:22 ` Bob Floyd 2021-01-15 18:09 ` Bob Floyd 0 siblings, 2 replies; 41+ messages in thread From: Juri Linkov @ 2021-01-13 18:53 UTC (permalink / raw) To: Bob Floyd; +Cc: 45617 > 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. ^ permalink raw reply related [flat|nested] 41+ messages in thread
* bug#45617: <query-replace> loses the edit region. Works in 23.3, broke in 26.3 2021-01-13 18:53 ` Juri Linkov @ 2021-01-15 1:22 ` Bob Floyd 2021-01-15 8:54 ` Juri Linkov 2021-01-15 18:09 ` Bob Floyd 1 sibling, 1 reply; 41+ messages in thread From: Bob Floyd @ 2021-01-15 1:22 UTC (permalink / raw) To: 'Juri Linkov'; +Cc: 45617 I've removed the earlier patch and installed these changes. Now testing it! Thanks. -----Original Message----- From: Juri Linkov [mailto:juri@linkov.net] Sent: Wednesday, January 13, 2021 10:54 AM To: Bob Floyd Cc: 'Eli Zaretskii'; 45617@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. ^ permalink raw reply related [flat|nested] 41+ messages in thread
* bug#45617: <query-replace> loses the edit region. Works in 23.3, broke in 26.3 2021-01-15 1:22 ` Bob Floyd @ 2021-01-15 8:54 ` Juri Linkov 2021-01-15 11:23 ` Eli Zaretskii 2021-01-15 18:05 ` Bob Floyd 0 siblings, 2 replies; 41+ messages in thread From: Juri Linkov @ 2021-01-15 8:54 UTC (permalink / raw) To: Bob Floyd; +Cc: 45617 > 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. ^ permalink raw reply [flat|nested] 41+ messages in thread
* bug#45617: <query-replace> loses the edit region. Works in 23.3, broke in 26.3 2021-01-15 8:54 ` Juri Linkov @ 2021-01-15 11:23 ` Eli Zaretskii 2021-01-19 17:45 ` Juri Linkov 2021-01-15 18:05 ` Bob Floyd 1 sibling, 1 reply; 41+ messages in thread From: Eli Zaretskii @ 2021-01-15 11:23 UTC (permalink / raw) To: Juri Linkov; +Cc: bobfloyd, 45617 > From: Juri Linkov <juri@linkov.net> > Cc: "'Eli Zaretskii'" <eliz@gnu.org>, <45617@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? ^ permalink raw reply [flat|nested] 41+ messages in thread
* bug#45617: <query-replace> loses the edit region. Works in 23.3, broke in 26.3 2021-01-15 11:23 ` Eli Zaretskii @ 2021-01-19 17:45 ` Juri Linkov 2021-01-19 18:39 ` Eli Zaretskii 0 siblings, 1 reply; 41+ messages in thread From: Juri Linkov @ 2021-01-19 17:45 UTC (permalink / raw) To: Eli Zaretskii; +Cc: bobfloyd, 45617 >> 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. ^ permalink raw reply [flat|nested] 41+ messages in thread
* bug#45617: <query-replace> loses the edit region. Works in 23.3, broke in 26.3 2021-01-19 17:45 ` Juri Linkov @ 2021-01-19 18:39 ` Eli Zaretskii 0 siblings, 0 replies; 41+ messages in thread From: Eli Zaretskii @ 2021-01-19 18:39 UTC (permalink / raw) To: Juri Linkov; +Cc: bobfloyd, 45617 > From: Juri Linkov <juri@linkov.net> > Cc: bobfloyd@comcast.net, 45617@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. ^ permalink raw reply [flat|nested] 41+ messages in thread
* bug#45617: <query-replace> loses the edit region. Works in 23.3, broke in 26.3 2021-01-15 8:54 ` Juri Linkov 2021-01-15 11:23 ` Eli Zaretskii @ 2021-01-15 18:05 ` Bob Floyd 2021-01-19 17:43 ` Juri Linkov 1 sibling, 1 reply; 41+ messages in thread From: Bob Floyd @ 2021-01-15 18:05 UTC (permalink / raw) To: 'Juri Linkov'; +Cc: 45617 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@linkov.net] Sent: Friday, January 15, 2021 12:55 AM To: Bob Floyd Cc: 'Eli Zaretskii'; 45617@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. ^ permalink raw reply [flat|nested] 41+ messages in thread
* bug#45617: <query-replace> loses the edit region. Works in 23.3, broke in 26.3 2021-01-15 18:05 ` Bob Floyd @ 2021-01-19 17:43 ` Juri Linkov 2021-01-20 22:48 ` Bob Floyd 2021-01-20 23:23 ` Bob Floyd 0 siblings, 2 replies; 41+ messages in thread From: Juri Linkov @ 2021-01-19 17:43 UTC (permalink / raw) To: Bob Floyd; +Cc: 45617 > 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 '-)))))) ^ permalink raw reply [flat|nested] 41+ messages in thread
* bug#45617: <query-replace> loses the edit region. Works in 23.3, broke in 26.3 2021-01-19 17:43 ` Juri Linkov @ 2021-01-20 22:48 ` Bob Floyd 2021-01-20 23:23 ` Bob Floyd 1 sibling, 0 replies; 41+ messages in thread From: Bob Floyd @ 2021-01-20 22:48 UTC (permalink / raw) To: 'Juri Linkov'; +Cc: 45617 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@linkov.net] Sent: Tuesday, January 19, 2021 9:44 AM To: Bob Floyd Cc: 'Eli Zaretskii'; 45617@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 '-)))))) ^ permalink raw reply [flat|nested] 41+ messages in thread
* bug#45617: <query-replace> loses the edit region. Works in 23.3, broke in 26.3 2021-01-19 17:43 ` Juri Linkov 2021-01-20 22:48 ` Bob Floyd @ 2021-01-20 23:23 ` Bob Floyd 2021-01-21 21:50 ` Juri Linkov 1 sibling, 1 reply; 41+ messages in thread From: Bob Floyd @ 2021-01-20 23:23 UTC (permalink / raw) To: 'Juri Linkov'; +Cc: 45617 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@linkov.net] Sent: Tuesday, January 19, 2021 9:44 AM To: Bob Floyd Cc: 'Eli Zaretskii'; 45617@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 '-)))))) ^ permalink raw reply [flat|nested] 41+ messages in thread
* bug#45617: <query-replace> loses the edit region. Works in 23.3, broke in 26.3 2021-01-20 23:23 ` Bob Floyd @ 2021-01-21 21:50 ` Juri Linkov 2021-01-22 17:31 ` Bob Floyd 0 siblings, 1 reply; 41+ messages in thread From: Juri Linkov @ 2021-01-21 21:50 UTC (permalink / raw) To: Bob Floyd; +Cc: 45617 > 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>. ^ permalink raw reply [flat|nested] 41+ messages in thread
* bug#45617: <query-replace> loses the edit region. Works in 23.3, broke in 26.3 2021-01-21 21:50 ` Juri Linkov @ 2021-01-22 17:31 ` Bob Floyd 2021-01-23 17:20 ` Juri Linkov 0 siblings, 1 reply; 41+ messages in thread From: Bob Floyd @ 2021-01-22 17:31 UTC (permalink / raw) To: 'Juri Linkov'; +Cc: 45617 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@linkov.net] Sent: Thursday, January 21, 2021 1:51 PM To: Bob Floyd Cc: 'Eli Zaretskii'; 45617@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>. ^ permalink raw reply [flat|nested] 41+ messages in thread
* bug#45617: <query-replace> loses the edit region. Works in 23.3, broke in 26.3 2021-01-22 17:31 ` Bob Floyd @ 2021-01-23 17:20 ` Juri Linkov 2021-01-23 18:03 ` Bob Floyd 0 siblings, 1 reply; 41+ messages in thread From: Juri Linkov @ 2021-01-23 17:20 UTC (permalink / raw) To: Bob Floyd; +Cc: 45617 > 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. ^ permalink raw reply [flat|nested] 41+ messages in thread
* bug#45617: <query-replace> loses the edit region. Works in 23.3, broke in 26.3 2021-01-23 17:20 ` Juri Linkov @ 2021-01-23 18:03 ` Bob Floyd 2021-01-23 18:31 ` Juri Linkov 0 siblings, 1 reply; 41+ messages in thread From: Bob Floyd @ 2021-01-23 18:03 UTC (permalink / raw) To: 'Juri Linkov'; +Cc: 45617 >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@linkov.net] Sent: Saturday, January 23, 2021 9:21 AM To: Bob Floyd Cc: 'Eli Zaretskii'; 45617@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. ^ permalink raw reply [flat|nested] 41+ messages in thread
* bug#45617: <query-replace> loses the edit region. Works in 23.3, broke in 26.3 2021-01-23 18:03 ` Bob Floyd @ 2021-01-23 18:31 ` Juri Linkov 2021-01-24 20:40 ` Bob Floyd 0 siblings, 1 reply; 41+ messages in thread From: Juri Linkov @ 2021-01-23 18:31 UTC (permalink / raw) To: Bob Floyd; +Cc: 45617 >>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):. ^ permalink raw reply [flat|nested] 41+ messages in thread
* bug#45617: <query-replace> loses the edit region. Works in 23.3, broke in 26.3 2021-01-23 18:31 ` Juri Linkov @ 2021-01-24 20:40 ` Bob Floyd 2021-01-25 17:07 ` Juri Linkov 0 siblings, 1 reply; 41+ messages in thread From: Bob Floyd @ 2021-01-24 20:40 UTC (permalink / raw) To: 'Juri Linkov'; +Cc: 45617 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@linkov.net] Sent: Saturday, January 23, 2021 10:31 AM To: Bob Floyd Cc: 'Eli Zaretskii'; 45617@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):. ^ permalink raw reply [flat|nested] 41+ messages in thread
* bug#45617: <query-replace> loses the edit region. Works in 23.3, broke in 26.3 2021-01-24 20:40 ` Bob Floyd @ 2021-01-25 17:07 ` Juri Linkov 2021-01-25 18:13 ` Bob Floyd 0 siblings, 1 reply; 41+ messages in thread From: Juri Linkov @ 2021-01-25 17:07 UTC (permalink / raw) To: Bob Floyd; +Cc: 45617 > 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? ^ permalink raw reply [flat|nested] 41+ messages in thread
* bug#45617: <query-replace> loses the edit region. Works in 23.3, broke in 26.3 2021-01-25 17:07 ` Juri Linkov @ 2021-01-25 18:13 ` Bob Floyd 2021-01-25 18:54 ` Juri Linkov 0 siblings, 1 reply; 41+ messages in thread From: Bob Floyd @ 2021-01-25 18:13 UTC (permalink / raw) To: 'Juri Linkov'; +Cc: 45617 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@linkov.net] Sent: Monday, January 25, 2021 9:07 AM To: Bob Floyd Cc: 'Eli Zaretskii'; 45617@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? ^ permalink raw reply [flat|nested] 41+ messages in thread
* bug#45617: <query-replace> loses the edit region. Works in 23.3, broke in 26.3 2021-01-25 18:13 ` Bob Floyd @ 2021-01-25 18:54 ` Juri Linkov 2021-01-25 19:34 ` Bob Floyd 0 siblings, 1 reply; 41+ messages in thread From: Juri Linkov @ 2021-01-25 18:54 UTC (permalink / raw) To: Bob Floyd; +Cc: 45617 > 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. ^ permalink raw reply [flat|nested] 41+ messages in thread
* bug#45617: <query-replace> loses the edit region. Works in 23.3, broke in 26.3 2021-01-25 18:54 ` Juri Linkov @ 2021-01-25 19:34 ` Bob Floyd 2021-01-25 19:51 ` Juri Linkov 0 siblings, 1 reply; 41+ messages in thread From: Bob Floyd @ 2021-01-25 19:34 UTC (permalink / raw) To: 'Juri Linkov'; +Cc: 45617 >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@linkov.net] Sent: Monday, January 25, 2021 10:54 AM To: Bob Floyd Cc: 'Eli Zaretskii'; 45617@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. ^ permalink raw reply [flat|nested] 41+ messages in thread
* bug#45617: <query-replace> loses the edit region. Works in 23.3, broke in 26.3 2021-01-25 19:34 ` Bob Floyd @ 2021-01-25 19:51 ` Juri Linkov 2021-01-26 0:34 ` Bob Floyd 0 siblings, 1 reply; 41+ messages in thread From: Juri Linkov @ 2021-01-25 19:51 UTC (permalink / raw) To: Bob Floyd; +Cc: 45617 > 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. ^ permalink raw reply [flat|nested] 41+ messages in thread
* bug#45617: <query-replace> loses the edit region. Works in 23.3, broke in 26.3 2021-01-25 19:51 ` Juri Linkov @ 2021-01-26 0:34 ` Bob Floyd 2021-01-27 9:43 ` Juri Linkov 0 siblings, 1 reply; 41+ messages in thread From: Bob Floyd @ 2021-01-26 0:34 UTC (permalink / raw) To: 'Juri Linkov'; +Cc: 45617 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@linkov.net] Sent: Monday, January 25, 2021 11:52 AM To: Bob Floyd Cc: 'Eli Zaretskii'; 45617@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. ^ permalink raw reply [flat|nested] 41+ messages in thread
* bug#45617: <query-replace> loses the edit region. Works in 23.3, broke in 26.3 2021-01-26 0:34 ` Bob Floyd @ 2021-01-27 9:43 ` Juri Linkov 2021-01-28 16:31 ` Bob Floyd 0 siblings, 1 reply; 41+ messages in thread From: Juri Linkov @ 2021-01-27 9:43 UTC (permalink / raw) To: Bob Floyd; +Cc: 45617 > 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. ^ permalink raw reply [flat|nested] 41+ messages in thread
* bug#45617: <query-replace> loses the edit region. Works in 23.3, broke in 26.3 2021-01-27 9:43 ` Juri Linkov @ 2021-01-28 16:31 ` Bob Floyd 2021-01-28 18:42 ` Juri Linkov 0 siblings, 1 reply; 41+ messages in thread From: Bob Floyd @ 2021-01-28 16:31 UTC (permalink / raw) To: 'Juri Linkov'; +Cc: 45617 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@linkov.net] Sent: Wednesday, January 27, 2021 1:44 AM To: Bob Floyd Cc: 'Eli Zaretskii'; 45617@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. ^ permalink raw reply [flat|nested] 41+ messages in thread
* bug#45617: <query-replace> loses the edit region. Works in 23.3, broke in 26.3 2021-01-28 16:31 ` Bob Floyd @ 2021-01-28 18:42 ` Juri Linkov 2021-01-28 21:32 ` Bob Floyd 0 siblings, 1 reply; 41+ messages in thread From: Juri Linkov @ 2021-01-28 18:42 UTC (permalink / raw) To: Bob Floyd; +Cc: 45617 > 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 '-)))))) ^ permalink raw reply [flat|nested] 41+ messages in thread
* bug#45617: <query-replace> loses the edit region. Works in 23.3, broke in 26.3 2021-01-28 18:42 ` Juri Linkov @ 2021-01-28 21:32 ` Bob Floyd 2021-01-29 8:56 ` Juri Linkov 0 siblings, 1 reply; 41+ messages in thread From: Bob Floyd @ 2021-01-28 21:32 UTC (permalink / raw) To: 'Juri Linkov'; +Cc: 45617 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@linkov.net] Sent: Thursday, January 28, 2021 10:42 AM To: Bob Floyd Cc: 'Eli Zaretskii'; 45617@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 '-)))))) ^ permalink raw reply [flat|nested] 41+ messages in thread
* bug#45617: <query-replace> loses the edit region. Works in 23.3, broke in 26.3 2021-01-28 21:32 ` Bob Floyd @ 2021-01-29 8:56 ` Juri Linkov 0 siblings, 0 replies; 41+ messages in thread From: Juri Linkov @ 2021-01-29 8:56 UTC (permalink / raw) To: Bob Floyd; +Cc: 45617 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. ^ permalink raw reply [flat|nested] 41+ messages in thread
* bug#45617: <query-replace> loses the edit region. Works in 23.3, broke in 26.3 2021-01-13 18:53 ` Juri Linkov 2021-01-15 1:22 ` Bob Floyd @ 2021-01-15 18:09 ` Bob Floyd 1 sibling, 0 replies; 41+ messages in thread From: Bob Floyd @ 2021-01-15 18:09 UTC (permalink / raw) To: 'Juri Linkov'; +Cc: 45617 PS: The 1st patch has the same wrong behavior also! -----Original Message----- From: Juri Linkov [mailto:juri@linkov.net] Sent: Wednesday, January 13, 2021 10:54 AM To: Bob Floyd Cc: 'Eli Zaretskii'; 45617@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. ^ permalink raw reply related [flat|nested] 41+ messages in thread
* bug#45617: <query-replace> loses the edit region. Works in 23.3, broke in 26.3 2021-01-06 18:19 ` Eli Zaretskii 2021-01-06 22:10 ` Bob Floyd @ 2021-01-07 18:46 ` Juri Linkov 2021-01-07 19:36 ` Eli Zaretskii 1 sibling, 1 reply; 41+ messages in thread From: Juri Linkov @ 2021-01-07 18:46 UTC (permalink / raw) To: Eli Zaretskii; +Cc: bobfloyd, 45617 >> 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? ^ permalink raw reply [flat|nested] 41+ messages in thread
* bug#45617: <query-replace> loses the edit region. Works in 23.3, broke in 26.3 2021-01-07 18:46 ` Juri Linkov @ 2021-01-07 19:36 ` Eli Zaretskii 0 siblings, 0 replies; 41+ messages in thread From: Eli Zaretskii @ 2021-01-07 19:36 UTC (permalink / raw) To: Juri Linkov; +Cc: bobfloyd, 45617 > From: Juri Linkov <juri@linkov.net> > Cc: bobfloyd@comcast.net, 45617@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. ^ permalink raw reply [flat|nested] 41+ messages in thread
end of thread, other threads:[~2021-01-29 8:56 UTC | newest] Thread overview: 41+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2021-01-03 1:05 bug#45617: <query-replace> loses the edit region. Works in 23.3, broke in 26.3 Bob Floyd 2021-01-03 14:47 ` Eli Zaretskii 2021-01-03 19:18 ` Bob Floyd 2021-01-04 17:26 ` Eli Zaretskii 2021-01-04 17:37 ` Juri Linkov 2021-01-04 22:40 ` Bob Floyd 2021-01-05 18:27 ` Juri Linkov 2021-01-05 19:45 ` Bob Floyd 2021-01-06 17:44 ` Juri Linkov 2021-01-06 18:19 ` Eli Zaretskii 2021-01-06 22:10 ` Bob Floyd 2021-01-13 18:53 ` Juri Linkov 2021-01-15 1:22 ` Bob Floyd 2021-01-15 8:54 ` Juri Linkov 2021-01-15 11:23 ` Eli Zaretskii 2021-01-19 17:45 ` Juri Linkov 2021-01-19 18:39 ` Eli Zaretskii 2021-01-15 18:05 ` Bob Floyd 2021-01-19 17:43 ` Juri Linkov 2021-01-20 22:48 ` Bob Floyd 2021-01-20 23:23 ` Bob Floyd 2021-01-21 21:50 ` Juri Linkov 2021-01-22 17:31 ` Bob Floyd 2021-01-23 17:20 ` Juri Linkov 2021-01-23 18:03 ` Bob Floyd 2021-01-23 18:31 ` Juri Linkov 2021-01-24 20:40 ` Bob Floyd 2021-01-25 17:07 ` Juri Linkov 2021-01-25 18:13 ` Bob Floyd 2021-01-25 18:54 ` Juri Linkov 2021-01-25 19:34 ` Bob Floyd 2021-01-25 19:51 ` Juri Linkov 2021-01-26 0:34 ` Bob Floyd 2021-01-27 9:43 ` Juri Linkov 2021-01-28 16:31 ` Bob Floyd 2021-01-28 18:42 ` Juri Linkov 2021-01-28 21:32 ` Bob Floyd 2021-01-29 8:56 ` Juri Linkov 2021-01-15 18:09 ` Bob Floyd 2021-01-07 18:46 ` Juri Linkov 2021-01-07 19:36 ` Eli Zaretskii
Code repositories for project(s) associated with this public inbox https://git.savannah.gnu.org/cgit/emacs.git This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).