[comp.emacs] eval-last-sexp mystery

eric%yamada-sun@CSE.OGI.EDU (08/01/90)

If I have a buffer that looks like this:
	(delete-matching-lines "fred")
	ellen
	fred
	mary
	rose
and I put point after the right paren and do C-x C-e (eval-last-sexp),
why doesn't the line with `fred' on it disappear?? (Try it). If I do
`M-x delete-matching-lines fred', it does go away.  I suspect there's
something basic going on here that I don't understand.

Apologies if I mailed this message to the wrong place, but I can't
send or receive news.

       ------------------------------------------------------------------------
       |Eric Hanchrow		yamada-sun!eric@nosun.west.sun.com	      |
       |Phase III Logic, Inc.	yamada-sun!eric@cse.ogi.edu		      |
       |1600 N.W. 167th Place		Beaverton, OR 97006-4800 USA	      |
       |Voice: (503)-645-0313		Fax: (503)-645-0207    as of 13-Dec-89|
       --------------Crackling-noises-OK--do-not-correct!----------------------

sasdjb@unx.sas.com (David Biesack) (08/02/90)

In article <9007311707.AA08381@noname> eric%yamada-sun@CSE.OGI.EDU writes:
> If I have a buffer that looks like this:
> 	(delete-matching-lines "fred")
> 	ellen
> 	fred
> 	mary
> 	rose
> and I put point after the right paren and do C-x C-e (eval-last-sexp),
> why doesn't the line with `fred' on it disappear?? (Try it). If I do
> `M-x delete-matching-lines fred', it does go away.  I suspect there's
> something basic going on here that I don't understand.

When Emacs evaluates the expression, it first narrows
the region to (point-min) up to (point). Try eval-last-sexp 
on the following:

(sit-for 2)

and notice how the buffer is narrowed (see the "Narrow" in the mode line)
It appears that eval-region is doing this (eval-last-sexp calls eval-region).
I don't know why eval-region does a narrow, though. probably to keep
(read) from reading too far, since it is probably reading from the
buffer instead of a buffer-substring since reading more than one
expression from a string is pretty difficult.

>        ----------------------------------------------------------------------
>        |Eric Hanchrow		yamada-sun!eric@nosun.west.sun.com	      |
>        |Phase III Logic, Inc.	yamada-sun!eric@cse.ogi.edu		      |
>        |1600 N.W. 167th Place		Beaverton, OR 97006-4800 USA	      |
>        |Voice: (503)-645-0313		Fax: (503)-645-0207    as of 13-Dec-89|
>        --------------Crackling-noises-OK--do-not-correct!--------------------

djb

-- 
David J. Biesack			SAS Institute, Inc.     
Object Programming Technology           SAS Campus Drive        
sasdjb@dev.sas.com                      Cary, NC 27513-2414     
rti!sas!sasdjb                          (919) 677-8000 ext. 7771