Stephen_C Posted October 13, 2022 Share Posted October 13, 2022 I am the author of this workflow and the forum link is here. This is the link to the Github main page for the workflow. The workflow has no dependencies. It may be used either as a Universal Action on selected text: or, with a user configurable keyword, on text already on the clipboard: The amended text is copied to the clipboard and may optionally be saved to a temporary file (in a user configurable location). Stephen JJJJ and pontus 2 Link to comment Share on other sites More sharing options...
vitor Posted February 9 Share Posted February 9 I’m working on adding this, but bumped into an issue: the Universal Action does not work. You’re discarding its input in the second object (Arg & Vars) and later on always use the most recent clipboard text, so while it is possible to trigger with an Universal Action, the result is unexpected. There are a few ways to fix that if you want to keep all functionality, but I’ll leave the choice to you. Though do ask if you need specific guidance. Personally I’d do away with the clipboard method altogether and keep just the Universal Action, because it can also act on Clipboard History. I’d also have it paste directly to the frontmost app (perhaps with a dialog asking first, since you seem to be partial to those), because it’s a great way to replace the selected text. For reference, that’s how MarkdownTransform works (it replaces the text directly) and I don’t recall anyone ever asking for it to work differently. But again, specific functionality is up to you and your needs. Link to comment Share on other sites More sharing options...
Stephen_C Posted February 9 Author Share Posted February 9 Thanks for the comments, Vitor. I'll work on this over the next 24 hours or so taking account of your comments. I already have a simplified working version which uses only the Universal Action and pastes to the frontmost app but I'd like to look at it again tomorrow to see if there are any improvements I can make. Stephen vitor 1 Link to comment Share on other sites More sharing options...
Stephen_C Posted February 10 Author Share Posted February 10 I have released version 2.0 on GitHub. I have changed the name of the workflow and made substantial revisions removing the keyword and providing the ability to replace the selected text with the revised text. The Readme has been updated. Note: I did include at the end an option to copy the revised text to the clipboard (in addition to the default option to overwrite the selected text). That is because I sometimes need to work with documents that are not writeable—but I still need to amend the copied text. Because of the introduction of the dialog at the end of the workflow it was necessary to ensure that the original app containing the selected text was the active app when pasting to the frontmost app (the dialog removes the focus)—hence a couple of new Automation Tasks. Stephen Link to comment Share on other sites More sharing options...
vitor Posted February 10 Share Posted February 10 5 hours ago, Stephen_C said: That is because I sometimes need to work with documents that are not writeable—but I still need to amend the copied text. Note that even if you can’t overwrite the text in the document, it will still be copied to your clipboard. So you may not need the extra steps. I do enjoy seeing how you’re solving problems, though. I imagine you’re significantly faster than you were in your first workflows. I think it’s working better, but it’s still working only on the current clipboard text, instead of on the text retrieved by the Universal Action. To solve that you’d save it to a variable right after the Universal Action, then use that variable instead of {clipboard} later on. Link to comment Share on other sites More sharing options...
Stephen_C Posted February 10 Author Share Posted February 10 1 minute ago, vitor said: I think it’s working better, but it’s still working only on the current clipboard text, instead of on the text retrieved by the Universal Action. To solve that you’d save it to a variable right after the Universal Action, then use that variable instead of {clipboard} later on. Yes, it was silly of me to overlook that. I did notice it at one stage when developing the new workflow but then completely overlooked it <sigh>. Urgent rectification under way. (Yes, things are quicker now but still making silly mistakes.) Stephen Link to comment Share on other sites More sharing options...
vitor Posted February 10 Share Posted February 10 Just now, Stephen_C said: (Yes, things are quicker now but still making silly mistakes.) The fact that you consider the mistake silly speaks volumes! I even considered not adding the longer explanation because I’m pretty sure you know what the fix is (but it may still be beneficial to spell it out for others bumping into the thread). Link to comment Share on other sites More sharing options...
Stephen_C Posted February 10 Author Share Posted February 10 One further attempt: version 2.1. 30 minutes ago, vitor said: Note that even if you can’t overwrite the text in the document, it will still be copied to your clipboard. So you may not need the extra steps. The only reasons I have retained the additional steps are: When the revised text is pasted over the original text it's marked as transient in the clipboard—simply because it didn't seem to make sense to have it in two places. You know how I like those Dialogs Conditional—and I have placed your favoured option as the default in the dialog. 😀 Stephen Link to comment Share on other sites More sharing options...
vitor Posted February 10 Share Posted February 10 Thank you for the fast changes. Will be live soon at http://alfred.app/workflows/stephenc/find-and-replace-text/. But I’ve noticed this too: You’re passing {clipboard} on the first one which is then being overwritten in the second one. Not that it would cause a problem, but it would be simpler and faster to have a single Arg & Vars. Link to comment Share on other sites More sharing options...
Stephen_C Posted February 11 Author Share Posted February 11 Corrected in version 2.2. I am sorry for taking so much of your time in the battle to get this workflow as it should be. Stephen Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now