Subject: Re: bug#75840: 31.0.50; epg

From: Daiki Ueno <[email-masked]>
Date: Fri, 21 Mar 2025 09:47:44 +0900

Hello Eli, Richard,

Eli Zaretskii <[email-masked]> writes:

>> From: Richard Stallman <[email-masked]>
>> Cc: [email-masked]
>> Date: Wed, 19 Mar 2025 23:18:42 -0400
>> 
>>   > Richard, can you please answer my questions below:
>> 
>> Please forgive the delay.  I will try.
>> 
>>   > > Please tell which command you invoked.  If you happen to know which
>>   > > function checks the trustdb and hung, that would be even more helpful.
>> 
>> It was either `rmail-epa-decrypt' or `epa-mail-encrypt'.
>> 
>> I don't know EPA much, but I think it is GPG that decides to
>> regenerate the trustdn, _not_ code in Emacs itself.  And that's
>> how it should be.
>> 
>> GPG outputs messages on the tty to tell the user that it is
>> regeneraing the trustdb.  If the user sees those messages, perse
>> will understand why the pause.
>> 
>> THe problem is, when GPG is running under Emacs, those messages come
>> out on a pty and the user does not see them.
>> 
>>  To fix this problem, code in Emacs needs to detect these messages
>> coming out on the pty, and inform the Emacs user somehow of the reason
>> for the pause.
>> 
>> I tried once to understand the Elisp code that runs GPG and recognizes
>> its status messages, but I could not figure it out.  Can you reach the
>> expert on this code?
>
> Let's try.  Daiki, could you please help us out?  Let me know if you
> need a summary of the problem, but you could find the previous
> discussion of this issue here:
>
>   https://debbugs.gnu.org/cgi/bugreport.cgi?bug=75840

I haven't touched the code for a long time, so my answer could be
outdated, but the best I can suggest is to add (setq epg-debug t) in
~/.emacs, repeat the command, then inspect the " *epg-debug*" buffer, as
mentioned in:
https://www.gnu.org/software/emacs/manual/html_node/epa/Bug-Reports.html

The buffer should contain the status messages, such as "TRU":
https://git.gnupg.org/cgi-bin/gitweb.cgi?p=gnupg.git;a=blob;f=doc/DETAILS;h=e064c9d214506b4b9cea95448677afb2f885caee;hb=refs/heads/STABLE-BRANCH-2-2#l304

I don't remember epg handles that status message, but it should be easy
to add support for it, by defining a function named epg--status-TRU.

Regards,
-- 
Daiki Ueno