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

From: Dmitry Gutov <[email-masked]>
Date: Tue, 21 May 2024 23:16:55 +0300

On 21/05/2024 09:08, Juri Linkov wrote:
>> Here's a patch using symbol properties that makes the prefix commands work
>> combined in arbitrary order. At least according to my limited testing - and
>> only the commands that have this property set, of course.
> 
> This works until I moved project-prompter to the beginning,
> then 'C-x 5 p p' doesn't work with this:
> 
>    (letrec ((root (funcall project-prompter))
>             (depth (minibuffer-depth))
>             (echofun (lambda () "[switch-project]"))
>             (around-fun
> 
> Maybe there is a better place?

Last I checked, the project-prompter can change the value of this-command.

Perhaps you can try a let-binding for this-command around the call to 
project-prompter, so that it's restored at the end.

Something to also be concerned about is having any of the display-buffer 
modifications, or other-project advices, get applied to one of the 
commands inside the project-prompter UI (if it's implemented using a 
sequence of commands). Perhaps I haven't triggered this case mostly by 
luck so far. How to guard against that? Maybe a dynamic variable of some 
sort. But then it'd also have to be checked uniformly in all such 
functions (hooks that prefix commands install).

>> Something to discuss:
>> - A better name for the property? Maybe something longer would be more
>>    obvious for an accidental reader.
> 
> If it makes sense to use it outside of project.el
> then 'prefix-command' is fine.
> 
>> - Applying it through 'declare' forms could be a more self-contained
>>    approach.
> 
> This could be added later as well.