all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Keeping the point at the same position in multiple buffers
@ 2008-08-21 14:39 Corey Foote
  2008-08-21 16:04 ` Alex Bennee
  0 siblings, 1 reply; 5+ messages in thread
From: Corey Foote @ 2008-08-21 14:39 UTC (permalink / raw)
  To: help-gnu-emacs

[-- Attachment #1: Type: text/plain, Size: 773 bytes --]


Hi everybody,

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.

So, for example, when I press C-n in the current buffer, the other buffer will also move it's point to the next line.

Any suggestions?

Thanks!

Corey Foote

_________________________________________________________________
See what people are saying about Windows Live.  Check out featured posts.
http://www.windowslive.com/connect?ocid=TXT_TAGLM_WL_connect2_082008

[-- Attachment #2: Type: text/html, Size: 969 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Keeping the point at the same position in multiple buffers
  2008-08-21 14:39 Keeping the point at the same position in multiple buffers Corey Foote
@ 2008-08-21 16:04 ` Alex Bennee
  0 siblings, 0 replies; 5+ messages in thread
From: Alex Bennee @ 2008-08-21 16:04 UTC (permalink / raw)
  To: Corey Foote; +Cc: help-gnu-emacs

On Thu, 2008-08-21 at 10:39 -0400, Corey Foote wrote:
> Hi everybody,
> 
> 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.
> 
> So, for example, when I press C-n in the current buffer, the other
> buffer will also move it's point to the next line.

ediff-mode does roughly that when comparing 2 or 3 files. However I
suspect that's not quite what you want.

> 
> Any suggestions?
> 
> Thanks!
> 
> Corey Foote
> 
> 
> ______________________________________________________________________
> See what people are saying about Windows Live. Check out featured
> posts. Check It Out!
-- 
Alex Bennee, Software Engineer
[End of diatribe. We now return you to your regularly scheduled
programming...] -- Larry Wall in Configure from the perl distribution





^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Keeping the point at the same position in multiple buffers
       [not found] <mailman.17246.1219329568.18990.help-gnu-emacs@gnu.org>
@ 2008-08-21 21:47 ` Xah
  2008-08-21 23:03   ` Andreas Politz
  0 siblings, 1 reply; 5+ messages in thread
From: Xah @ 2008-08-21 21:47 UTC (permalink / raw)
  To: help-gnu-emacs

On Aug 21, 7:39 am, Corey Foote <coreyfo...@hotmail.com> wrote:
> Hi everybody,
>
> 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.
>
> So, for example, when I press C-n in the current buffer, the other buffer will also move it's point to the next line.

You can try “Alt+x 2C-two-columns” (shortuct Ctrl+x 6 2). This split a
window into 2 vertical columns. Page up/down one will also page up/
down the other. However, cursor doesn't follow.

related is a Alt+x follow-mode, which is for viewing one long file in
2 verticle frames as if you have a long monitor.

i'm pretty sure what you want is already implemented somewhere.

  Xah
∑ http://xahlee.org/^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Keeping the point at the same position in multiple buffers
  2008-08-21 21:47 ` Xah
@ 2008-08-21 23:03   ` Andreas Politz
  0 siblings, 0 replies; 5+ messages in thread
From: Andreas Politz @ 2008-08-21 23:03 UTC (permalink / raw)
  To: help-gnu-emacs

Xah wrote:
> On Aug 21, 7:39 am, Corey Foote <coreyfo...@hotmail.com> wrote:
>> Hi everybody,
>>
>> 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.
>>
>> So, for example, when I press C-n in the current buffer, the other buffer will also move it's point to the next line.
> 
> You can try “Alt+x 2C-two-columns” (shortuct Ctrl+x 6 2). This split a
> window into 2 vertical columns. Page up/down one will also page up/
> down the other. However, cursor doesn't follow.
> 
> related is a Alt+x follow-mode, which is for viewing one long file in
> 2 verticle frames as if you have a long monitor.
> 
> i'm pretty sure what you want is already implemented somewhere.
> 
>   Xah
> ∑ http://xahlee.org/
> 
> ☄

Here it is :

---
scroll-all-mode is an interactive compiled Lisp function in `scroll-all.el'.
(scroll-all-mode &optional arg)

Toggle Scroll-All minor mode.
With arg, turn Scroll-All minor mode on if arg is positive, off otherwise.
When Scroll-All mode is on, scrolling commands entered in one window
apply to all visible windows in the same frame.
---

Looking at the code it should be easy to extend this to other commands
(like forward-char).


-ap



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Keeping the point at the same position in multiple buffers
@ 2008-08-22  5:57 martin rudalics
  0 siblings, 0 replies; 5+ messages in thread
From: martin rudalics @ 2008-08-22  5:57 UTC (permalink / raw)
  To: coreyfoote; +Cc: help-gnu-emacs

 > 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)





^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2008-08-22  5:57 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-08-21 14:39 Keeping the point at the same position in multiple buffers Corey Foote
2008-08-21 16:04 ` Alex Bennee
     [not found] <mailman.17246.1219329568.18990.help-gnu-emacs@gnu.org>
2008-08-21 21:47 ` Xah
2008-08-21 23:03   ` Andreas Politz
  -- strict thread matches above, loose matches on Subject: below --
2008-08-22  5:57 martin rudalics

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.