An Alfred Workflow for Drafts

Using Dr Drafts V1.5 - when I highlighted a paragraph of text in Safari, double tap my Ctrl key to pop up Alfred Universal Actions and click on “Create New Drafts”, the paragraph is sent to Drafts but it always have a one character space at the beginning of the text. Not a big deal but it is an inconvenience that I have to delete that space in Drafts. Is this a bug?

There’s a space before “Judge” in the screenshot below (this is taken on iPhone - it’s the same in the Mac)

I’ll try and take a look later today. It shouldn’t be adding an extra space. Hopefully just a typo somewhere.

Thanks for flagging it up.

1 Like

If I trigger the universal actions on some text, then I get the following list of Doctor Drafts universal actions. “Create Draft” is in the list and creates a new draft with the content, with no leading space. There is no “Create New Drafts” in the list.

The list of creation universal actions is listed on the website.

There is a “Create New Draft” (just missing the final “s” character from what you wrote) action, but this is not a Universal Action, and is not intended to be used as a universal action. It would only show up in your Universal Actions list if you had checked the Workflow keyword Inputs option in the Alfred settings (Alfred > Settings > Features > Universal Actions > Actions).

See note #2 on the Doctor Drafts Universal Actions page.

The only other option I can think of is if you have created your own custom flow workflow called “Create New Drafts”, but I imagine that is unlikely given just how close a name it is to that other action.

If I am not on the right track with the points above, could you share some more detail about what you are selecting within Alfred, and what your Alfred settings are with regards to Universal Actions, Actions settings?

I wrote the above on the phone and my poor memory thought that it was “Create New Drafts”. My apologies for misleading you.

Now that I am at the desk, it is “Create Draft”, as you rightly pointed out. I have Alfred UA sorted by usage.

And, the leading space still appear as below:

I didn’t do any customisation. My Alfred Universal Actions pane is as below, where I unchecked the last two options:

I finally got a decent block of uninterrupted time to sit down and look at this properly this morning. I managed to reproduce the issue, then tracked it down to something really obvious. It looks like there was a rogue space I’d introduced into a Perl script step 🤦🏻

v1.5.1 has the space removed and is now available for download.

2 Likes

Thank you! I really welcome this fix as needing to remove the trailing space can get tiresome. I appreciate it.

1 Like

Is anybody else having trouble getting the drfind command to work properly?

For me, I can type the command just fine, and Alfred sees it as the “Search for Draft” command, but upon typing my search text and hitting return, the Alfred window just stays there with a blinking cursor and nothing more happens. Hitting return again (and again) does nothing. If I hit tab instead of return, the text turns purple, but still nothing happens.

I’m sure I must be missing something basic. Any suggestions?

It is working fine for me currently. It should be populating a filter list for you to choose a matching draft from. Here is what I get if I search for something that there is a match for.

2021-11-09-08.41.35

Here is what I get if I search for something that there is no match for.

2021-11-09-08.43.03

What do you get as the output when you run drdiag?

Example Diagnostic Output

The filter is based on population by a Python script, so if there is an issue, my first guess would be something to do with your Python 3 installation. The diagnostic report should flag up if that’s the issue.

Thanks!

It was indeed a Python issue. I had checked that Python3 was installed, but it was not installed in the right place and/or my PATH hadn’t bee correctly configured. I used the links on your support site to install the latest python with pyenv and it’s working as expected now.

Thanks for the help and for the great tool!

1 Like

I’m glad you’re finding it useful, and that the diagnostic helped - that’s a relatively new addition :smiley:

I thought I would have a quick review on how the workflow has grown since public release about 6 months ago:

  • There have been seven releases post-beta, and the number of flows in the workflow has increased significantly.
  • Triggers now include file actions, universal actions and fallback searches, which greatly increased the usefulness and ways in which it could be used.
  • There are well over 100 pages of in-depth documentation on the web site ranging from installation, and the basics, through to extended use - building your own flows on top of this workflow, and the technical documentation to support doing that!
  • I still have a few things on the roadmap, and on my private to do list(s)/ideas drafts, but if anyone has any burning desires/great ideas, feel free to post them on this thread and, no promises on delivery, but I will definitely consider including them.

April 2021

The images above and below are the same size, with the grey area representing additional flows. But some of the flows have also been expanded as well with additional functionality.

November 2021

Hi thanks for this wonderful workflow @sylumer

Is there an example of how to use the variables to add a tag to drnew?

Thanks

There’s this one in the use cases.

Thanks @sylumer. I was hoping to be able to add a tag = blah, diblah on the end of the query rather than using variables. But this is a great start until get round to trying to work that out

Using a separator and an external call to drnew makes it relatively straight forward to do.

Here’s a quick example you can use as is or develop further to meet your needs.

2021-11-30-14.53.29

Summary

This workflow requires the Doctor Drafts workflow -
https://doctordrafts.thoughtasylum.com

The workflow creates a new draft with tags in Drafts. The new draft is not automatically opened; rather it is created in the background.

The workflow uses a variable called splitter, which is a text string that defines the separation between the new content and the tags. By default this is two vertical pipe characters (“||”), but you can change this to any string you like (e.g. “tags=”).

After triggering the workflow using the keyword, enter the text you wish to create a new draft from, followed by the splitter string, and finally by a comma separated list of tags.

Note: The workflow is set to trim whitespace at the start and end of the two splits - the content and the list of tags

Then you can enter a request into Alfred and get a tagged draft as shown below:

Hopefully that’s the sort of thing you were after. Let me know, and if it is, I’ll try and find some time to add it as another use case to the web site. I’m always open to suggestions for more use cases.

This is EXACTLY what I wanted. Thanks so much @sylumer

@nickwild I had a thought today that gives you another option, a little different to what you first suggested, but perhaps a little easier to use?

If you download the workflow from the same link above, it should now be at version 1.1.0, and include an additional flow.

With this one, open Alfred, type dntd followed by a space and then the content for your new draft. Press return and then you should be presented with the Alfred input dialog window again, this time for tag entry. Enter your comma-separated list of tags, and on pressing return, a new draft will be created.

There is no need to remember a splitter string for using this one, the return key does the splitting, and unless you modified the splitter to be a single character and ignore the (optional) spaces around it, it should be fewer key presses to run through, so fractionally faster. But I think the not having to remember the splitter string is what swings it for me - if yoiu are not using it all the time, it would be easy to forget.

Hope that helps.

1 Like

Thanks @sylumer. This gets better and better. The gift that keeps giving! :blush:cheers

Thank you so much for sharing these workflows! Both your website and blog are valuable resources of information and knowledge.

1 Like

Version 1.6.0 of Doctor Drafts is now available. It includes some revisions around Alfred actions for some new config that’s available (and was I believe inspired by some of the hoops I jumped through regarding Doctor Drafts’ original implementation for actions), but the big update is around the availability of Drafts actions search within some of the flows; hopefully the ones where it makes most sense to include them as an option.

When you create a new draft using drnew for example, if you then hold down ⌘ as you press return, you will then be able to filter and choose from a list of all available actions, and then once the draft is created, the draft will be loaded and the action run against it.

For example, here’s the search when I filter my list of actions for “journal”.

The action group an action belongs to is shown underneath.

This should help with disambiguation, but I would strongly recommend unique names for actions as when the resulting action name is passed on to Drafts, it is only the name (via the URL scheme) and not the group, and so Drafts cannot tell which you wish to use if there are multiple matches.

Similarly, searching by content or title and pressing ⇧⌘ will give the same option (⌘ on its own was already taken for these as a way to copy the content of the draft).

This action search functionality was something that I wanted to incorporate into Doctor Drafts since the very first beta of the workflow, but it took me a while to figure out one final piece of the puzzle. but, now it’s done, and hopefully it will work well for everyone, but as always, please do flag up any issues that you come across.

A use case for adding a new draft with any tag(s) has also been added to the website. This is effectively a walkthrough of the example above.

1 Like