Subject: bug#45607: 27.1; compiled replace-string breaks repeat-complex-command

From: Juri Linkov <[email-masked]>
Date: Wed, 06 Jul 2022 10:53:13 +0300

>> (defun replace-string (from-string to-string &optional delimited start end backward region-noncontiguous-p)
>> ...
>>   (declare (arg start (if (use-region-p) (region-beginning)))
>>            (arg end (if (use-region-p) (region-end))))
>>
>> and fix_command would pick them up from the symbol plist and use those
>> forms instead of the value for these arguments.
>
> If we do that, it would be impossible to explicitly specify START and
> END values that are different from an active region from ELisp code. If
> the region is active, those arguments would always just be ignored.

Indeed, some users might want to have numbers for START and END values
to repeat the command exactly on the same previous region, but other users
might want to repeat the command on a newly selected region with
(region-beginning)/(region-end) in the command history.

OTOH, keeping numbers in the history breaks replace-string for
rectangular regions, because the command history will contain
inconsistent numbers: some numbers from the previous replacement,
and other numbers from the new rectangular region.  For example:

  (replace-string "buffer" "foo" nil 1 2 nil '((3 . 4) (5 . 6)))

where 1 2 are the old region boundaries, and '((3 . 4) (5 . 6))
is a new rectangular region boundaries.