The find-function-at-point command finds a function and displays its definition in the other window, while moving point to the other window as well.

I'd like to have a version of find-function-at-point that opens the function definition in the other window, but leaves point in the current window.

I thought I could accomplish this with save-excursion in a lambda expression as follows:

(lambda ()

However, this doesn't seem to work. Point remains in the other window.

My understanding of save-excursion is that it should restore point and mark after the body of save-excursion is evaluated. What am I missing here?

1 Answer 1


Your call to save-excursion has no body.

It is saving point, mark, and the current buffer, then doing nothing, and then 'restoring' those things to their saved values.

However that's the wrong macro. You want save-selected-window.

It sounds like you are under the misconception that there is a single point and mark which 'move' around between buffers. This is not the case -- each buffer has its own buffer-local point and mark values -- so "restoring point and mark" has nothing to do with changing the currently-selected window.

Nor indeed does "restoring the current buffer" -- that is simply the buffer (which is not necessarily visible in any window) which is current for the functions being called. "Restoring" this value has no bearing on whether/where that buffer is displayed.

In short, be aware that buffers are independent of the windows they can be displayed in. Mixing the two concepts in your mind will certainly lead to confusion.

  • Well put. Good way to make this clear.
    – Drew
    Nov 24, 2015 at 1:58
  • You're absolutely right that I've associated "buffers" with "windows" in my mind. Your explanation made this very clear! Nov 24, 2015 at 2:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.