A Hammerspoon "Spoon" that mimics Plan 9's Acme editor mouse chords for cut, paste, and "snarf" operations.
Acme's mouse chords become second nature. Though I am also a vi person (nvi in particlar), it's hard to beat the flow of working inside Acme, and a big part of that is its use of the mouse.
This Spoon brings a few text manipulation mouse chords to macOS, eliminating a tiny bit of mental context switching when using Acme on macOS.
After installing and setting up Hammerspoon:
- Download and unzip NineMouseChords.spoon.zip.
- Install using one of these methods:
- Double-click
NineMouseChords.spoon
to let Hammerspoon handle installation, or - Copy
NineMouseChords.spoon
to your Spoons directory
- Double-click
- Add this line to your Hammerspoon config:
hs.loadSpoon("NineMouseChords"):start()
- Reload your Hammerspoon configuration
For more details about Spoons installation and configuration paths, see the Hammerspoon Spoon Documentation.
Mouse chording in NineMouseChords works similarly to Plan 9's Acme editor:
- Select text by pressing the left mouse button down. You may already have text highlighted, but you can also drag the mouse to create a highlight, or hold the end of a double-click to create a highlight.
- While holding the left button down:
- Click the middle button to cut the selected text
- Click the right button to paste previously cut text
- Release the left button to complete the operation
Note: To copy text ("snarf" in Plan 9 parlance), while the left mouse button is down, you cut (middle button) and paste (right button) the same text back. You can then release the left mouse button, and use the paste chord to paste the "snarfed" text elsewhere.
Here is a crappy gif demo of chording outside of Acme:
You can find a helpful diagram at http://acme.cat-v.org/mouse.
Since the Acme editor handles mouse chords itself (and richer set than are implmented in this Spoon), we don't handle chording when Acme is focused; the app is "blacklisted". You can blacklist other apps using the :excludeApps()
method:
hs.loadSpoon("NineMouseChords")
:excludeApps({"Finder", "Photoshop"})
:start()
Beesides allowing specialized apps to handle mouse events themselves, please see the note on implementation below for other reasons you may want to blacklist certain apps.
We generate macOS key strokes (CMD-C, DEL, CMD-V) under the hood to perform cut and paste operations. While this is simple and reliable, it means the DEL key stroke is generated during cut operations. Exercise caution in apps where an unexpected delete key stroke could be problematic.
This Spoon has been tested primarily with standard macOS desktop apps and the Acme editor.
I have no idea whether this (or Hammerspoon in general) works with games and more specialized apps (e.g. CAD software).
You can create a symbolic link from your Spoons directory to the NineMouseChords.spoon package:
$ cd $HOME/.hammerspoon/Spoons && ln -s /path/to/NineMouseChords.spoon
Hammerspoon seems to handle this fine, but it is not one of the documented installation methods.
Please see LICENSE file.