Subject: bug#70577: [PATCH] New command other-project-prefix

From: Juri Linkov <[email-masked]>
Date: Sun, 26 May 2024 09:52:37 +0300

>>> -		     (eq this-command command))
>>> +		     (eq this-original-command command)
>> Actually the real problem is that in project--other-place-prefix
>> prefix-command-preserve-state changes this-command to last-command.
>
> This one might not be so bad (the idea, as documented, seems sensible).
>
> Changing this-read-command seems more suspect.
>
> But I guess it really means more checks would need to be done on
> this-original-command instead. :-/
>
> The (eq this-original-command command) check could probably be dropped, but
> otherwise your addition looks good (I don't know any cases where
> this-original-command would be wrong, though apparently there might be some
> -- remappings of the prefix commands? seems an odd thing to do).
>
> It might also be possible to rewrite display-buffer-override-next-command
> in a way that the installation of the "advice" (not actual advice in its
> case) happens in pre-command-hook - then at that point the current command
> hasn't had a chance to alter this-command.
>
> prefun would check whether it needs to be applied, if yet, add the cleanup
> function to post-command-hook, and run the setup. The modification of
> display-buffer-overriding-action might also be better done there, so it
> doesn't alter any prompter UI in the next prefix command that might be
> invoked.
>
> Not an urgent change, just something to consider.
>
> Have you had a chance to run with the modified patch a little? Any edge new
> edge cases crop up?

I tried to use the patch for a while, with and without this-original-command,
but it often leaves the postfun hook in display-buffer-override-next-command
active infinitely, thus needed to restart Emacs too often, so I just
removed the patch without debugging what part causes this.