oantolin / embark

Emacs Mini-Buffer Actions Rooted in Keymaps

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Tips on integration with new package projection-compile-multi

mohkale opened this issue · comments

Hi there,

I maintain a project called projection. It's basically projectile. One of the features from it is sourcing completion candidates from multiple build frameworks like CMake or Makefiles and letting you select one to run interactively.

Screenshot_20230821_194937

I'd like to figure out a way to integrate this into embark somehow. Right now there's 2 features I'd like.

  1. The ability to copy a completion target which will actually copy the command that target invokes (make test) instead of what's shown in the minibuffer make:test.
  2. The ability to save the command instead of the minibuffer target as the next command to run for project building or testing.

Both of these require some way to map from the candidate in the minibuffer to what the completion function is supposed to return. I'd like this to work through embark-act but also happy to have something similar to embark-become where I have a common function to read these targets and generic ones to save them to some command-type that I can add as embark-become helpers. Just wanted to get your thoughts on recommended ways to integrate the two here :-).

Embark has the notion of transformer, which let's you replace the target with a function of the target prior to any non-default action. It sounds like maybe that's what you need here: you probably want all actions to treat minibuffer candidates as standing for the associated command instead. A transformer is a function taking a symbol denoting the target type and a string target, and returning a cons of a symbol and a string, the new type and new target. It's OK if the new type is equal to the old type, this doesn't lead to a loop since only one round of transformation is done. To register a transformer add it to embark-transformer-alist.

Now, I don't know if the command string really is just a function of your candidate strings. If you need an extra information to compute that command string, you need to stick it in a text property on the candidate. You could, for example, put the command string itself in a text property.

I'm closing this issue because I think it requires no changes to embark, but we can continue the conversation here anyway. Let me know if you have any further questions.

Embark has the notion of transformer, which let's you replace the target with a function of the target prior to any non-default action.

This is amazing. Thanks. I got it working with this + the text-property suggestion you made.