[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Keeping the point at the same position in multiple buffers
From: |
martin rudalics |
Subject: |
Re: Keeping the point at the same position in multiple buffers |
Date: |
Fri, 22 Aug 2008 07:57:46 +0200 |
User-agent: |
Thunderbird 2.0.0.16 (Windows/20080708) |
> When editing several files in Emacs, each in its own buffer, each buffer
> has its own point location. I have Emacs displaying two buffers, each in
> it's own window. I was wondering if there's an easy way to make it so
> that each of these buffers will keep the point at the same place in both
> buffers (or at least on the same line) even though this is not the
> default behavior.
You can try to add the untested snippet below to your .emacs.
martin
(defun synchronize-windows ()
(save-selected-window
(condition-case nil
(let ((pos (window-point))
(sel (selected-window))
(buf (window-buffer (selected-window))))
(dolist (frame (frame-list))
(dolist (window (window-list frame))
(when (and (eq (window-buffer window) buf)
(not (eq window sel))
(/= (window-point window) pos))
(set-window-point window pos)))))
(error nil))))
(add-hook 'post-command-hook 'synchronize-windows t)