Maybe define it as a method for lm objects?

Code:

```
segments.lm <- function(coef, xlim, ...) {
a <- coef[1]
b <- coef[2]
x0 <- xlim[1]
x1 <- xlim[2]
y0 <- a + b*x0
y1 <- a + b*x1
segments(x0 = x0, y0 = y0, x1 = x1, y1 = y1, ...)
}
```

Code:

```
segments.lm <- function(lm, xlim, ...) {
a <- coef(lm)[1]
b <- coef(lm)[2]
x0 <- xlim[1]
x1 <- xlim[2]
y0 <- a + b*x0
y1 <- a + b*x1
segments(x0 = x0, y0 = y0, x1 = x1, y1 = y1, ...)
}
```