3

Two questions:

  1. Where does the result of eval-buffer get stored? How do I access it?
    For example:

    (+ 2 2)
    
  2. Functions like (forward-word) are executed by eval-buffer, but do not move the cursor? Why is that?

4

1 回答 1

7
  1. eval-buffer is usually used for side-effects, rather than return value. For example, in your .emacs file, eval-buffer will re-load all our config settings. By default, and when used interactively, it will always return nil. If you want to get the return value of code in a buffer, this is the wrong way to do it. eval-last-sexp, bound to C-x C-e, is one way to do so. Calling it with a prefix, C-u C-x C-e will insert the return value into the current buffer.

  2. eval-buffer preserves the value of point. So functions like forward-word will have no visible effect.

于 2012-12-05T20:17:57.800 回答