MACRO: Abbreviation-Based Web Searches

This is how I did it already :stuck_out_tongue_winking_eye:

Version 3.1 is out now; check for updates within the Shortcut Manager, or download via the link in the first post above.

This fixes the "can't modify without changing the shortcut" bug, and makes a couple other minor changes.


1 Like

So, now I had the opportunity to install the update and: it works like a charm. Thanks a lot, Rob!



3.2 is out now (linked above, and check for updates in the macro). I found a couple glitches in the remove and modify routines; those have hopefully been squashed.


1 Like

And ... 3.3 is out, sorry!

The fix I made in 3.2 had unintended consequences and broke stuff elsewhere (specifically when modifying and/or removing built-in shortcuts). This release both fixes the bug and repairs any damage that 3.2 might have done to your ws_deletes.txt file. Please let me know if you have issues with this version!

As a related note, this is (hopefully!) the final release in the 3.x series. As I was writing the 3.0 version, with the in-macro shortcut manager, the amount of regular expression manipulation I had to do to make some things work was just so complicated. Even as I was writing it, I was worried about maintainability. And both of the recent bugs were directly related to the regular expressions not doing exactly what I thought they would be doing.

As just one example, this is just part of the code needed to display a list of disabled built-in shortcuts:

And the 3.x macro is littered with probably 100+ sections like this, all needed to split and deal with the various shortcut types (built in, optional list, or user added). Version 4 migrates the entire back-end of the macro into a sqlite3 database—sqlite3 is built into macOS, and it's really fast and supports SQL queries. So I'm able to replace the gibberish above with something like this:

select shortcut, descrip, url from TheShortcuts where
(source='DEFAULT' and status='INACTIVE');

This is so much easier and more maintainable ... yet again, it's how I should have written it in the first place. No more text file manipulation, either; records get read from and written to the database itself.

To keep the speed up, the database is only accessed when necessary—once to set a global variable with the active shortcut list, and then when you make any changes to your shortcuts. Just using the macro, though, the database is never touched, so this version is just as fast as the prior—and actually faster when changing things, because there's so much less text manipulation to do.

The macro itself is done; I'm writing the converter that will migrate the 3.x files into the database, so you won't have any work to do when you upgrade.