Selection-storing companion command to `Select RESELECT`

DOpus has the command Select RESELECT. Docs:

Reselects all files and folders that were used (and deselected) by the previously executed command.

There's the older thread "Is there a way to undo a deselect?", in which Leo said:

the more I think that through the trickier it is to define a good rule for which selection events can be undone, and which events overwrite the saved selection you'd go back to, which could become quite a fragile piece of state, such as if one file was selected and then another.

How about letting the script writer store the selection explicitly, though? I had a use case where I wanted to do this in the context of showing the folder context menu, but had to accept the selection as cleared after calling Select NONE, because I found no way to restore it.

If a selection-storing companion command to Select RESELECT would exist, I'd call it in my use case, then Select NONE, then let Talon simulate the menu key, and finally call Select RESELECT.

I don't know, however, if this tampers too much with the reasons Select RESELECT was made available in the first place, so that technical use cases like mine and more user-involved command execution would be mixed inappropriately. If that distinction is reasonable, a technical use case could leave traces of state in the user-involved realm by overwriting the last selection undo information. But that's just a cautious thought and could well be irrelavant.

You can use the Select FROMSCRIPT command to select files from a script using the files in a Command object. You can retrieve a list of selected files at any time from the Tab object.

1 Like

This works when running cmd.AddFiles(clickData.func.sourcetab.selected_files) before the Select NONE command. However, there's again the problem that it doesn't work in the recycle bin folder (see also this post).

Very few commands do, currently. Select RESELECT won't do anything there either.