-- twdesigns.com
-- AppleScript: Open User_Library_Services_Folder.scpt -- 2024-12-13_v1
-- make it easy to add a macOS Service
set User_Home_Folder_Path to path to home folder
set User_Library_Services_Folder_Path to User_Home_Folder_Path & "Library:Services:" as string
tell application "Finder"
activate
open folder User_Library_Services_Folder_Path
end tell
-- twdesigns.com
-- 2024-01-13_v1
-- replaces the default Let ( {[} var1 = expression1 {; var2 = expression2...]} ; calculation )
on run {input}
set input to replace_selection_with_Let_Function(input as string)
return input
end run
on replace_selection_with_Let_Function(text_in)
set text_out to "Let (
[
~var1 = $expression1 ;
~var2 = $expression2 ;
~result = List (~var1 ; ~var2)
];
~result // result
)"
return text_out
end replace_selection_with_Let_Function
Oh goodness, I had no idea you did this. That's very cool. As I have the same needs that you mention below (to do calculation formatting using a macOS Service from anywhere you can type text), and as I wanted to learn Swift, I just recently wrote an app to do just that. It's available for free on the (Mac) App Store, has 12 custom formatting options, and includes a shortcut action and starter shortcut such that you can format your calculations from anywhere you like -- by Service menu or keyboard shortcut. And for those not on Mac, my web site's Perl script has been updated, too. The app is called FMIndent and it's here.
2 Likes
Hi Debi,
Welcome to The Soup. I'm interested in FMIndent. I've downloaded it and downloaded the shortcut. I began by opening a set variable calculation. I was having trouble getting any input into the shortcut. The menu item showed a message "waiting for input". Changing the settings in the shortcut to accept input from Clipboard didn't help. It was only after switching into my web browser to send this message that I found a clue. I selected a piece of text from my response and try to apply the service to it. A security dialog appeared saying "allow format calculation to pass data to FMIndent?" I clicked "allow" and now everything works.
Did I overlook this step in the set-up instructions? If not, it's probably a good thing to add to the list of things to do to get started.
Also, we'd love to help get the word out. Please consider adding a promo post over in resources that describes FMIndent and includes a screen shot or two.
Hi Debi,
Welcome to the Soup. I am so very glad to see you are here!
Thanks, Steve and Malcolm.
I realized my post wasn't very clear. In saying "I had no idea you did this. That's very cool" I was referring to the MacOS service Michael Kupietz made from my decades-old perl code. I recently revamped that old Perl code, myself, in my case to add a bunch of command-line style options, and at that time I, too made it work as a service. I should probably post that new perl code on GitHub, soon. (I was going to, but the app as a MacOS service is much more user-friendly, so once I switched gears to a Shortcut/intent donating actual macOS app I decided to put the perl stuff on hold and to concentrate on the app for a while).
Regarding MBS: I like that my FMIndent app's shortcut doesn't interfere with it. MBS and my app's shortcut mutually enhance one another, in my opinion, and I didn't find myself plagued with nag dialogs from MBS even before I paid for it.
In answer to your question, Malcolm: No, you didn't miss anything, and you're the second one to report that issue, so it's clearly something I need to clarify. Thanks for reporting. I didn't realize it would be an issue, as I got that security dialog right away. I will add some more text to my next release so others don't have the same problem. It is not clear to me what prompts that security dialog and what doesn't, though, so if any one knows that would be great.
the new blurb so far:
Note: The shortcut's privacy tab needs to show permissions both for accessing the clipboard and for passing its data to FMIndent. If the shortcut is not working, and these permissions aren't showing, try quitting both FMIndent and the Shortcuts app so as to spark the appropriate macOS permissions dialog upon the shortcut's next use.
@aptworks I can't see a setting for "Leading Semicolon".
Leading semicolon is considered to be a desirable code attribute in our team.
Is this a possibility?
It is not there. It may be a possibility in the future...