Subject: Re: bug#59793: 29.0.60; subr.elc is not compiled correctly

From: Feng Shu <[email-masked]>
Date: Sun, 04 Dec 2022 05:50:33 +0800

Akib Azmain Turja <[email-masked]> writes:

> Eli Zaretskii <[email-masked]> writes:
>
>>> From: Feng Shu <[email-masked]>
>>> Date: Sat, 03 Dec 2022 15:24:55 +0800
>>> 
>>> This week, I faced an issue about emacs-eat: 
>>> 
>>> 
>>>     eat-yank not work well: https://codeberg.org/akib/emacs-eat/issues/9
>>> 
>>> 
>>> -------------
>>> (defun eat-yank (&optional arg)
>>>   "Same as `yank', but for Eat.
>>> 
>>> ARG is passed to `yank', which see."
>>>   (interactive "*P")
>>>   (when eat--terminal
>>>     (funcall eat--synchronize-scroll-function)
>>>     (cl-letf* ((inhibit-read-only t)
>>>                (insert-for-yank (symbol-function #'insert-for-yank))
>>>                ((symbol-function #'insert-for-yank)
>>>                 (lambda (&rest args)
>>>                   (cl-letf (((symbol-function #'insert)
>>>                              (lambda (&rest args)
>>>                                (eat-send-string-as-yank
>>>                                 eat--terminal
>>>                                 (mapconcat (lambda (arg)
>>>                                              (if (stringp arg)
>>>                                                  arg
>>>                                                (string arg)))
>>>                                            args "")))))
>>>                     (apply insert-for-yank args)))))
>>>       (yank arg))))
>>> ---------
>>> 
>>> 
>>> After some test with author of emacs-eat, we find that config
>>> 
>>>     (require 'eat)
>>>     (load "subr.el")
>>> 
>>> work, while the below config do not work.
>>> 
>>>     (require 'eat)
>>>     (load "subr.elc") 
>>> 
>>> 
>>> we find that C-x C-e insert-for-yank and insert-for-yank-1 works too.
>>> 
>>> 
>>> so we think subr.elc is not compiled correctly, I use the below 
>>> script to compile emacs, do not install and run ~/emacs/emacs29/src/emacs directly
>>
>> Thanks, but what exactly "does not work" in the byte-compiled version of
>> subr.el?  Do you have a recipe to reproduce the problem you see without
>> using emacs-eat?  If so, please post such a recipe.  Because from your
>> report, I don't see how to reproduce the problem and how to investigate it.
>>
>>
>>
>
> I have figured out a simpler reproduction method, but since I don't have
> the much information other than the subr.elc file, Feng should verify
> it.
>
> 1. Save the following in a file.
>
> (require 'cl-lib)
> (defun bug59593-yank (&optional arg)
>   (interactive "*P")
>   (cl-letf* ((inhibit-read-only t)
>              (insert-for-yank (symbol-function #'insert-for-yank))
>              ((symbol-function #'insert-for-yank)
>               (lambda (&rest args)
>                 (cl-letf (((symbol-function #'insert)
>                            (lambda (&rest args)
>                              (message
>                               "%S"
>                               (mapconcat (lambda (arg)
>                                            (if (stringp arg)
>                                                arg
>                                              (string arg)))
>                                          args "")))))
>                   (apply insert-for-yank args)))))
>     (yank arg)))
>
> 2. emacs -nw -Q -l FILE-FROM-STEP-1 -l PATH/TO/YOUR/SUBR.EL.GZ
> 3. Kill something.
> 4. M-x bug59593-yank.  Now you should see the yank text in echo area.
> 5. emacs -nw -Q -l FILE-FROM-STEP-1 -l PATH/TO/ATTACHED/SUBR.ELC
> 6. Kill something.
> 7. M-x bug59593-yank.  The yank text got unexpectedly inserted.
>
> Feng, can you precisely specify the commit you're building from?  It'll
> allow to reproducing your problem more easily and precisely.

The step is work to show this issue, and I use the below commit to test.

commit f6e2f30f394a270c2eca9a9a14be46876d2a86e5 (HEAD -> emacs-29, origin/emacs-29)
Author: Stefan Kangas <[email-masked]>
Date:   Sat Dec 3 15:31:07 2022 +0100

    ; Fix typos

--