bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#45617: <query-replace> loses the edit region. Works in 23.3, broke i


From: Bob Floyd
Subject: bug#45617: <query-replace> loses the edit region. Works in 23.3, broke in 26.3
Date: Thu, 28 Jan 2021 08:31:54 -0800

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.






reply via email to

[Prev in Thread] Current Thread [Next in Thread]