emacs-pretest-bug
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: doc string of with-temp-file


From: Drew Adams
Subject: RE: doc string of with-temp-file
Date: Tue, 27 Dec 2005 09:10:51 -0800

    > The doc string of with-temp-file should mention that the new buffer
    > created is killed at the end.

    > I tried to do this:

    > (unwind-protect
    >     (with-temp-file "foo" (pp something (current-buffer)))
    >   (kill-buffer "foo"))

    You seem to also be confusing it with `with-temp-buffer'.

Why do I seem to be confusing it with `with-temp-buffer'? I'm familiar with
`with-temp-buffer'. What I tried to do in the above code was ensure that the
buffer is temporary. If I had confused `with-temp-file' with
`with-temp-buffer' then I certainly would not have tried to implement
`with-temp-buffer's behavior of killing the buffer as cleanup - I would have
assumed that behavior.

My point is that the doc string of `with-temp-file' says that a new buffer
is _created_, used to evaluate stuff, and then written to its file. It says
nothing about the buffer being _temporary_ (i.e., being deleted after being
saved).

My second point is that the name of the function `with-temp-file' suggests
that the _file_ is temporary, not the buffer. A better name would be
something like `with-temp-buffer-write' or `with-temp-buffer-saved'. I don't
suggest that those are great names either, but they make it clear that 1)
the buffer is temporary, 2) the file is not temporary, and 3) the buffer is
written (to its file). With such a name, even the current, bad doc string
would be less of a problem.

Here is the complete doc string of `with-temp-file', in case you are
"confusing it with `with-temp-buffer'" ;-).

  Create a new buffer, evaluate body there, and write the buffer to file.
  The value returned is the value of the last form in body.
  See also `with-temp-buffer'.






reply via email to

[Prev in Thread] Current Thread [Next in Thread]