coteditor / CotEditor

Lightweight Plain-Text Editor for macOS
https://coteditor.com
Other
6.44k stars 431 forks source link

Run scripts on events #513

Open jeffmikels opened 8 years ago

jeffmikels commented 8 years ago

My previous request was to remove trailing whitespace from text when the document is saved. I implemented the feature using a simple applescript to apply a regular expression replace to the document, but then I realized how great it would be for my script to be called whenever my document was manually saved.

Thinking more abstractly, it would be really cool if we could associate scripts not only with hotkeys but also with events.

Some event examples:

Implementation suggestion:

Does this sound like a good idea to anyone else?

1024jp commented 8 years ago

I've thought so for a long time how I can implement such script callback on CotEditor and it's still pending. It is definitely true that this feature makes a lot of users incl. me happy.

Your approach seems in some respects good. Though there are some another blockers to be resolved in order to realize this feature, I'll gradually make a start on it.

ricardobeat commented 7 years ago

Have hotkeys for scripts been implemented? Can't find any info.

1024jp commented 7 years ago

@ricardobeat You can set shortcut keys for scripts adding specific characters to the script file name. For details, see "File naming rules for CotEditor scripts" page in CotEditor's help. You can reach to the help page from the main menu > Help.

screen shot 2016-12-06 at 1 38 13