# libtmux.control:with-connection

- **Package:** libtmux/control
- **Language:** Common Lisp
- **Kind:** function
- **Source:** https://github.com/libtmux/libtmux-lisp/blob/c2e5fc4ed3befda21f45dfa5d5868c38fd138311/src/control.lisp#L236
- **Public owner:** libtmux.control
- **Page:** https://libtmux.org/en/lisp/latest/reference/libtmux-control-with-connection/

```
(with-connection (name client session &rest options) &body body)
```

Bind NAME to a control connection and close the original resource on exit.
Evaluate CLIENT, SESSION and OPEN-CONNECTION options once. BODY accepts
declarations and returns all its values. Rebinding NAME cannot redirect cleanup.
After normal return, propagate cleanup failure; during an error or nonlocal
exit, preserve that exit and record cleanup failure on the connection.

See also: `libtmux.control:close-connection`, `libtmux.control:connection-cleanup-failures`, `libtmux.control:open-connection`.

## Parameters

- `(name client session &rest options)`
- `body`
