Replace/Programmatically edit a Selected Action?

In some instances, I’d like to be able to do the following workflow, or some variant of it that would work:

  1. In the KM Editor, select an existing Action in a Macro.

  2. Programmatically modify some aspect of the action.

  • Example: Change an existing “Execute a Macro” action to point to a different action.

I don’t believe I can select it, copy it, and paste it, having the past replace the existing action.

If I try to cut and paste, I don’t believe I can guarantee that the paste goes in the same location as where the action that was cut was located.

I don’t think there’s a unique identifier for each action, so finding the action in a macro’s plist and modifying it is problematic.

Any thoughts?

No, there is no “Paste Replacing Selection” option for actions. Maybe there should be, but its kind of an odd usage case. That said, it would make “Engroup” a lot easier.

What you could do would be something like:

  • Cut
  • Modify the clipboard
  • If the Copy menu item is enabled
    • Command-Option-V (Paste Above)
  • Else
    • Paste

After cutting an item, the following action, if any, will be selected. So if the Copy menu is enabled, paste above works, and otherwise, paste will append to the end which is what you want if you cut the last item.

Should work.

Thanks. I could swear there are instances where this doesn’t work correctly (the pasted action went in the wrong place), but I can’t currently verify it. The instances had to do with whether the selected action was at the bottom a group or an IF statement.

But since I can’t duplicate it right now, I can’t be sure. I may try and experiment tomorrow.

And no, I wasn’t expecting you to change anything to make this easier, although you make a good point about “engroup” (great term).

I sometimes wish each action had its own UUID, and that there was a scriptable way to select/move to an action by its UUID (perhaps edit the macro first, then select the action by UUID). For instance, if I wrote a custom search, I could pinpoint the exact action that the search found. Also, it would make it trivial (sort-of) to modify the selected action, engroup it, etc.

But honestly, it’s not important enough to to make this a priority. I could give you a handful of things I’d rather have before this, so I’m really just thinking out loud.

I’ve considered adding a UUID for each action, but it would add a lot of storage space in the macro file which is not ideal, and then there are ever more places where I have to figure out if the UUID needs to be refreshed (option-draging, copy & paste, import, etc).

1 Like

@DanThomas, @peternlewis Perhaps a not too bad compromise can be a kind of Action of Interest bookmark: in the mid time we can survive using a dedicated comment labelled by a UUID as a simulated such bookmark…


Hey Peter,

It would make a number of things possible and more reliable.