# _M.textadept.run

Compile and run/execute source files with Textadept.
Typically, [language-specific modules][] populate the `compile_command`,
`run_command`, and `error_detail` tables for a particular language's file
extension.

[language-specific modules]: _M.html#Compile.and.Run

- - -

## Fields

- - -

<a id="MARK_ERROR_BACK"></a>
### `MARK_ERROR_BACK` (number)

The background color, in "0xBBGGRR" format, used for a line containing a
  recognized run or compile error.

- - -

<a id="_G.events.COMPILE_OUTPUT"></a>
### `_G.events.COMPILE_OUTPUT` (string)

Emitted after executing a language's compile command.
  By default, compiler output is printed to the message buffer. To override
  this behavior, connect to the event with an index of `1` and return `true`.
  Arguments:

  * `lexer`: The lexer language name.
  * `output`: The string output from the command.

- - -

<a id="_G.events.RUN_OUTPUT"></a>
### `_G.events.RUN_OUTPUT` (string)

Emitted after executing a language's run command.
  By default, output is printed to the message buffer. To override this
  behavior, connect to the event with an index of `1` and return `true`.
  Arguments:

  * `lexer`: The lexer language name.
  * `output`: The string output from the command.

- - -

<a id="cwd"></a>
### `cwd` (string, Read-only)

The working directory for the most recently executed compile or run
  command.
  It is used for going to error messages with relative file paths.

- - -


## Functions

- - -

<a id="compile"></a>
### `compile`()

Compiles the file based on its extension using the command from the
`compile_command` table.
Emits a `COMPILE_OUTPUT` event.

See also:

* [`compile_command`](#compile_command)
* [`events`](events.html)

- - -

<a id="goto_error"></a>
### `goto_error`(*line, next*)

Goes to the source of the recognized compile/run error on line number *line*
in the message buffer or the next or previous recognized error depending on
boolean *next*.
Displays an annotation with the error message, if available.

Parameters:

* *`line`*: The line number in the message buffer that contains the
  compile/run error to go to.
* *`next`*: Optional flag indicating whether to go to the next recognized
  error or the previous one. Only applicable when *line* is `nil` or `false`.

See also:

* [`error_detail`](#error_detail)
* [`cwd`](#cwd)

- - -

<a id="run"></a>
### `run`()

Runs/executes the file based on its extension using the command from the
`run_command` table.
Emits a `RUN_OUTPUT` event.

See also:

* [`run_command`](#run_command)
* [`events`](events.html)

- - -


## Tables

- - -

<a id="compile_command"></a>
### `compile_command`

Map of file extensions (excluding the leading '.') to their associated
"compile" shell command line strings or functions returning such strings.
Command line strings may have the following macros:

  + `%(filepath)`: The full path of the current file.
  + `%(filedir)`: The current file's directory path.
  + `%(filename)`: The name of the file, including its extension.
  + `%(filename_noext)`: The name of the file, excluding its extension.

This table is typically populated by [language-specific modules][].

[language-specific modules]: _M.html#Compile.and.Run

- - -

<a id="error_detail"></a>
### `error_detail`

Map of lexer names to their error string details, tables containing the
following fields:

  + `pattern`: A Lua pattern that matches the language's error string,
    capturing the filename the error occurs in, the line number the error
    occurred on, and optionally the error message.
  + `filename`: The numeric index of the Lua capture containing the filename
     the error occurred in.
  + `line`: The numeric index of the Lua capture containing the line number
     the error occurred on.
  + `message`: (Optional) The numeric index of the Lua capture containing the
    error's message. An annotation will be displayed if a message was
    captured.

When an error message is double-clicked, the user is taken to the point of
error.
This table is usually populated by [language-specific modules][].

[language-specific modules]: _M.html#Compile.and.Run

- - -

<a id="run_command"></a>
### `run_command`

Map of file extensions (excluding the leading '.') to their associated
"run" shell command line strings or functions returning such strings.
Command line strings may have the following macros:

  + `%(filepath)`: The full path of the current file.
  + `%(filedir)`: The current file's directory path.
  + `%(filename)`: The name of the file, including its extension.
  + `%(filename_noext)`: The name of the file, excluding its extension.

This table is typically populated by [language-specific modules][].

[language-specific modules]: _M.html#Compile.and.Run

- - -

