Is there a utility, script, or something that would allow me to easily use DTP as a source code snippet collector? There are some standalone apps that do this, like Snippets and Codebox, but I want to use DTP. Seems like I could achieve the same functionality, or at least the functionality I want.
I’ve already created a Code template, which works for what it does. What I want to do is select some code anywhere, right click, choose Save to Code Snippets, and have it land in an new doc using my template. I can later tag, and otherwise complete the items in the doc (language, notes, etc.)
Seems like someone might have already done this…
A simple approach would be to add the placeholder %clipboard% (or %styledClipboard%) to the template. Afterwards you could just copy the code and create a new document via the template.
A more sophisticated approach would be a service based on a workflow.
OK, I’ve got a service, but there doesn’t seem to be a way to tell DTP which template to use. I can set the group, create a new text record, set the record attributes. There’s no place to specify the template in this workflow.
This adds extra steps to the process, when I want fewer.
I do have placeholders in my template, and that’s certainly useful.
Am I thinking about this all wrong? It is entirely possible (probable) that I’m going about this the wrong way.
The workflow service has to execute a tiny script like this one:
on run {input, parameters}
tell application "DEVONthink Pro"
import "/path/to/myTemplate.rtf" placeholders {|%clipboard%|:(item 1 of input)}
end
end run
This little script works nicely!
Thanks!