Hi Eli, Alan,
Here's a new patch incorporating all of Alan's feedback, with two notes:
1. This implementation is unable to differentiate between left and right
modifier keys, because it depends upon NSEventModifierFlags, which doesn't
differentiate between left and right.
2. hotkey_ids is a global variable, so it should not be released.
To address Eli's feedback, this patch is inspired by
create a launcher like Spotlight or Alfred. Since he's using GNU/Linux and i3 wm, he
simply assigned a global hotkey in his window manager config to run emacsclient
and run the launcher. I believe this is also easy to do in Windows.
In macOS this is much more difficult, because assigning a global hotkey can only
be done in code. So a user would have to rely on a utility like skhd or
Hammerspoon.
My proposal is to add this patch to emacs, so that a user can assign a global
hotkey in emacs without relying on a 3rd-party program.
I used w32-register-hot-key as an example of another instance where emacs added
an OS-specific feature in order to provide a consistent user experience across
platforms. Also, even though the behavior is totally different, the actual
implementation of that routine and mine are very similar.
Thanks for all of your time and feedback.