Node:save-excursion, Next:, Previous:Truth & Falsehood, Up:Writing Defuns



3.10 save-excursion

The save-excursion function is the fourth and final special form that we will discuss in this chapter.

In Emacs Lisp programs used for editing, the save-excursion function is very common. It saves the location of point and mark, executes the body of the function, and then restores point and mark to their previous positions if their locations were changed. Its primary purpose is to keep the user from being surprised and disturbed by unexpected movement of point or mark.