(It writes out text files with an .scpt extension – Script Editor often seems puzzled by them – reading but declining to resave/rewrite them, and is less puzzled or unprepared if they come back in with an .applescript extension)
Uh, this stopped working. Changing .currentApplication() to ("System Events") got it working again, but that it didn't work anymore is very disturbing.
The code above is working fine here – you may have to give me more context.
Note that if you don't enclose it in a module wrapper (as below), there can be collisions arising from pollution of the global namespace, including by successive runs of your own script.
Thanks to your enthusiasm for Atom and instructions for getting up and running, I have been using Atom more and more lately. I just want to note a few general difficulties I am having:
Discovering packages — even thinking to look for some particular feature — is difficult.
Many packages do similar things, and it isn’t clear which ones to load to get a useful and non-conflicting set.
The most frustrating so far is the random assignment of keystrokes by packages. They:
are difficult to learn
difficult to discover
conflict with many of my existing global KM keystrokes
override or just don't support fundamental OS X keybindings such as End for end of page
conflict with fundamental Emacs-based text editing commands built into the OS X Text Editing System which I have been using for more decades than I care to admit to
conflict with other packages
I have been putting off spending the time to sort out all bindings and start pruning packages and customizing them until I had a good sense of which packages I want to use, but it is making me crazy. (The worst offender is ⌃B, which someone decided should insert a pair of braces, but to hundreds of thousands, if not millions, of developers — especially in Unix environments — means “back 1 character”.)
I don't even know how to find commands or their bindings (I don't think there is an apropos feature, nor a way to find out what a key is bound to and by which package.) I am hungry for suggestions about how to deal with all of this.
None of this is reason to give up Atom, but I am finding it very awkward to use and feel like I am dancing around it more than taking advantage of what it offers.
I can‘t see myself going around binding every standard key that some package overrides, nor in many cases would I know how to find what package is binding the key so that I can bind something else to it. I must be missing something about using Atom. Then again, I don’t think I’ve read any of the documentation.
The problem is, overriding those key bindings doesn't always work.
It's not like that. You just start using the editor. When a key doesn't do what you want it to, you redefine it in KM. It's no different than redefining it in Atom's preferences, other than that you can be sure it will work.
Do whatever you want. If you get lucky, you may have no issues with Atom's key bindings. But that wasn't my experience. When I quit messing around with them and used KM instead, I wondered why I wasted so much time doing something else.
That’s if you know the package. How do I find what package is binding a key? Something in my setup is binding ⌘W to do something that is apparently worthless and certainly not what I want. It splits the editor and shows this on the right:
I found where to see all the keybindings: Preferences > Keybindings!. I missed using this in the first place because I had looked at it before loading any packages, and I made the assumption that package keybindings wouldn't show here. Not only do they show, but the package is shown along with the keybinding. Here’s ⌘W: