DRAFT

7 Commands

7.1 Search Path

7.1.1 Required Commands

requiredCommands = (
    command = 'clang-format';
    variable = 'TM_CLANG_FORMAT';
    locations = ( '/usr/local/bin/clang-format' );
    moreInfoURL = 'http://clang.llvm.org/docs/ClangFormat.html';
);

7.2 Drag Commands

7.3 Writing Commands

7.3.1 Executor Commands

The command can read the document content via stdin, that will be the current state of the document.

Do you wish for the command to never save the document? There are a few options, but it depends on your goal.

For example, if you wish the command to fire after a save operation (how it is presently setup, although by overloading the ⌘S key, which we discourage) then you can set the semantic class to ‘callback.document.did-save’ then it is automatically called after each save, and can read the document via the TM_FILEPATH environment variable (note that if you do this, you should make sure that “Save” is set to “Nothing” to avoid a loop).

If you wish to run the command decoupled from any potential save, then you should read the document from stdin. We do have some ruby support code that most of the run commands use, it will save an untitled document to a temporary file and setup TM_FILEPATH accordingly, meaning that the command can be assert that TM_FILEPATH always points to an up-to-date file.

A simple example of this is:

#!/usr/bin/env ruby18 -wKU
require "#{ENV['TM_SUPPORT_PATH']}/lib/tm/save_current_document"

TextMate.save_if_untitled('js')
# use ENV['TM_FILEPATH']

The argument to TextMate.save_if_untitled is the extension to use for the temporary file (and can be left out).

When using TextMate.save_if_untitled the command should set “Save” to “