[Solved] Get position in an other window

Discussion of Emacs Lisp

[Solved] Get position in an other window

Postby chep » Wed Nov 02, 2011 7:41 am

Hi
I want to know the line number corresponding to the point of a window which is not the current one.
I tried
(window-point my-window)
but I got the point and not the line number.
Unfortunately, line-number-at-pos is only working for current buffer. Is there a line-number-at-pos function working with other windows?

Thanks
Last edited by chep on Wed Nov 02, 2011 11:40 am, edited 1 time in total.
chep
 
Posts: 2
Joined: Wed Nov 02, 2011 7:31 am

Re: Get position in an other window

Postby Ramarren » Wed Nov 02, 2011 10:42 am

You can temporarily make a buffer current using with-current-buffer macro, so something like this:

Code: Select all
(with-current-buffer (window-buffer my-window)
  (line-number-at-pos))
Ramarren
 
Posts: 613
Joined: Sun Jun 29, 2008 4:02 am
Location: Warsaw, Poland

Re: Get position in an other window

Postby chep » Wed Nov 02, 2011 11:40 am

Exactly what I was looking for.
Thank you very much.
chep
 
Posts: 2
Joined: Wed Nov 02, 2011 7:31 am


Return to Emacs Lisp

Who is online

Users browsing this forum: No registered users and 0 guests

cron