4

When programming, I often switch from emacs to Xcode and viceversa. When I switch to Xcode, it automatically updates the current file when I focus Xcode window, if it detects that there are some external changes.

In emacs I have to press C-x C-v (but I lose the cursor position) or I have to press something and then insert r (reload?) in the minibuffer when emacs asks me what to do.

How to make emacs automatically reload the file (without losing the cursor position), it when I select back a buffer it corresponds to a modified file?

Thank you.

5

This isn't specific to focus in/out but rather to just updating buffers when the underlying file changes. Emacs calls this "reverting" the buffer and has the functions revert-buffer to do it manually and auto-revert-mode to revert automatically when the file changes on disk. auto-revert-mode can be added to the hook for whatever mode your using or you turn on global-auto-revert-mode (by adding (global-auto-revert-mode) to your .emacs).

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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