From: Stefan Monnier<monnier@iro.umontreal.ca>
Date: Fri, 11 Mar 2011 10:52:14 -0500
So (save-excursion (goto-char BAR)) is pretty much a no-op.
But (save-excursion (set-buffer FOO) (goto-char BAR)) is either:
- the same as (save-excursion (goto-char BAR)), in case FOO is already current.
- an inefficient form of (with-current-buffer FOO (goto-char BAR)).
I still haven't found any code out there where this behavior is what
is actually wanted and expected by the programmer.
In more than 90% of the cases, the intended meaning is
(with-current-buffer FOO (goto-char BAR)) and the behavior if FOO is
current (to additionally preserve point) is harmless, so the warning
simply points out an inefficiency.
In the remaining cases, FOO is almost always current, but when it's not
the resulting behavior is a bug. I.e. the intended code is
(with-current-buffer FOO (save-excursion (goto-char BAR))).