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

From: Akib Azmain Turja <[email-masked]>
Date: Sat, 03 Dec 2022 21:10:52 +0600

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.

--8<---------------cut here---------------start------------->8---
(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)))
--8<---------------cut here---------------end--------------->8---

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.

-- 
Akib Azmain Turja, GPG key: 70018CE5819F17A3BBA666AFE74F0EFA922AE7F5
Fediverse: [email-masked]
Codeberg: akib
emailselfdefense.fsf.org | "Nothing can be secure without encryption."