-
-
Notifications
You must be signed in to change notification settings - Fork 56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Two issues with text properties in embark-consult #180
Comments
Okay this should be fixed. put-text-property mutates the original candidate. This is wrong. |
Oh, boy. The first problem is a fairly serious problem with the default action for several Consult commands that prefix their candidates with unicode tofu: namely, for Since most actions require the candidate without the tofu prefix, embark-consult strips the prefix. But the default action only works correctly with the prefix, so when it is stripped it gets stored in the But that commit you linked to makes this strategy fail, since it strips all properties from a candidate prior to injecting it in the minibuffer. I think that commit is a good idea generally speaking. When actions read their input via I forgot we actually depend on those text-properties in embark-consult. :P I'll think about the best way to fix this. One way, as you say, would be to revert that commit. |
Note that the first problem only appears if you use I think I should just extend that to With that change we could remove the |
Since the default action already gets special treatment, why not handle it differently and avoid stripping the properties for the default action? Maybe you could also special case the default action earlier? |
This sounds good. Goes in the direction I considered, but better. |
I hope we can get rid of the tofus at some point - see also radian-software/selectrum#479 (comment). But it will be a long time until then. |
This is part of fixing #180. Embark now runs the default action on the untransformed target, when the default action is the command that opened the minibuffer from which the target originally came. So we don't need to bother anymore with storing the Consult tofu to restore later.
I wound up not always running the default action on the original untransformed target, only in cases where the target originally came from minibuffer completion (i.e., we are in a minibuffer, or in an embark collect buffer created from a minibuffer or recursively from another embark collect buffer that ultimately came from a minibuffer) and the default action has not been overridden and is still the command that opened the minibuffer in the first place. That sounds complicated, but the code is almost shorter than that description. With that change the embark-consult package can strip tofu without storing it anywhere. As always, please test. |
Great, congrats, fixes both issues.
The only minor problem I see with the current approach is when mixing
two similar consult commands that aren't `eq`. Example:
From consult-buffer, use embark-act to consult-buffer-other-window to
open a recent file in another window.
This seems like it would be difficult to fix (we would have to treat
find-file-other-windw and consult-buffer-other-window differently
somehow) and I'm not really sure what my take on this problem is or
whether it is important enough to fix it at all.
Personally I'm not affected by it at all and the default embark setup
encourages using the simple "o" action for such use cases.
|
Oh, good point about |
The |
embark-default-action
doesn't work with consult-buffer's recent files.Reverting commit bf6158c seems to fix this,
but I haven't studied the code enough to claim that this is the appropriate
solution.
Another issue is that acting on recent files with embark-act can sometimes
cause an element of
recentf-list
to get anembark-consult-prefix
textproperty. Writing such a list to recentf's save file causes an error during a
subsequent emacs startup, because the text-property's value is a circular
structure.
For some reason this only happens to remote recent files and I haven't been
able to reproduce this with emacs -q. The following patch does seem to fix this
but, again, I'm not sure if this fix is correct or if it brakes anything.
The text was updated successfully, but these errors were encountered: