I would like to open and name a `pdf` plot device using a function; plot to it at the level that called the device opening function; and then close it using a `dev.off()` command given at that level -- is this possible in `R`? 

**Background**

I print a to `pdf` from R reqularly, and as such do a lot of:

```
pdf(file.path(plotPATH, pdfName), width = Wwidth, height = Hheight)
plot( ...)
dev.off()

```

To promote lazyness, I made a function to open the plot device and save me the `pdf(file.path(plotPATH ...))` boilerplate. 

The function i created is:

```
pdfMk <- function(pdfName, Wwidth = 480, Hheight = 480) 
{ 
    pdf(file.path(plotPATH, pdfName), width = Wwidth, height = Hheight)
}

```

Which I would like to call as follows: 

```
pdfMk("foo.pdf")
plot(...)
dev.off()

```

The problem is that this does not work ... the output is a `pdf` with the appropriate name and in the appropriate place, but it's always blank. 

I thought I may have a problem with closures (or something) so I tried stepping through the `pdfMk` function with `debug` and creating the plot before the function call ends, but the output remains a blank pdf (there are no error messages in either case). 

Is this possible? If so, how might i achieve my aim?