Go to the first, previous, next, last section, table of contents.


Template for a save-excursion Expression

The template for code using save-excursion is simple:

(save-excursion
  body...)

The body of the function is one or more expressions that will be evaluated in sequence by the Lisp interpreter. If there is more than one expression in the body, the value of the last one will be returned as the value of the save-excursion function. The other expressions in the body are evaluated only for their side effects; and save-excursion itself is used only for its side effect (which is restoring the positions of point and mark).

In more detail, the template for a save-excursion expression looks like this:

(save-excursion
  first-expression-in-body
  second-expression-in-body
  third-expression-in-body
   ...
  last-expression-in-body)

An expression, of course, may be a symbol on its own or a list.

In Emacs Lisp code, a save-excursion expression often occurs within the body of a let expression. It looks like this:

(let varlist
  (save-excursion
    body...))


Go to the first, previous, next, last section, table of contents.