help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: (read (current-buffer)) returns an integer in a buffer full of text?


From: Kevin Rodgers
Subject: Re: (read (current-buffer)) returns an integer in a buffer full of text?
Date: Mon, 27 Nov 2006 09:44:03 -0700
User-agent: Thunderbird 1.5.0.8 (Windows/20061025)

Robert Thorpe wrote:
Sebastian Tennant wrote:
Hi everyone,

If I execute the following code in *scratch* there's no problem:

  (with-temp-buffer
    (insert "hello")
    (backward-word)
    (read (current-buffer)))
  => hello

The function with-temp-buffer creates a temp buffer for the duration of
it's body.  It does _not_ select that buffer as the current buffer.

Why would that matter?  The (read (current-buffer)) form is evaluated
while the temp buffer is current.  Nothing depends on the temp buffer
still being current after that.

You must use set-buffer or save-excursion too.

All AFAIK.

--
Kevin





reply via email to

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