unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: David PONCE <david.ponce@wanadoo.fr>
Cc: emacs-devel@gnu.org
Subject: Re: `posn-at-point' and `posn-at-x-y' not in manual
Date: Mon,  7 Jun 2004 12:14:59 +0200 (CEST)	[thread overview]
Message-ID: <29405516.1086603299144.JavaMail.www@wwinf0303> (raw)

Richard Stallman wrote:
>     FYI, I noticed that the functions `posn-at-point' and `posn-at-x-y'
>     are not documented in the Emacs Lisp Reference Manual.
> 
> Would someone like to write text for the manual about them?
> 
> Explaining explicitly that using window-inside-pixel-edges
> is the way to turn this into frame-relative would be useful.

Hi,

Here is a text I wrote that could serve as a starting point.  I am not
sure in which file to add it.  Feel free to proof read it, and use a
better English than mine ;-)

Sincerely,
David

------------------------- [ cut here ] ------------------------------
These functions return position information similar to that returned
by @code{event-start}, from a visible position on the display.

@defun posn-at-point &optional pos window
Return position information for buffer @var{pos} in @var{window}.
@var{pos} defaults to point in @var{window}; @var{window} defaults to
the selected window.

Return @code{nil} if position is not visible in window.  Otherwise,
the return value is similar to that returned by @code{event-start} for
a mouse click at the upper left corner of the glyph corresponding to
the given buffer position:

@example
(@var{window} @var{area-or-pos} (@var{x} . @var{y}) @var{timestamp}
 @var{object} @var{text-pos} (@var{col} . @var{row})
 @var{image} (@var{dx} . @var{dy}) (@var{width} . @var{height}))
@end example

The @code{posn-} functions access elements of such lists.
@end defun

@defun posn-at-x-y x y &optional frame-or-window
Return position information for pixel coordinates @var{x} and @var{y}.
By default, @var{x} and @var{y} are relative to text area of the
selected window.  Optional third arg @var{frame_or_window}
non-@code{nil} specifies frame or window.

The return value is similar to a mouse click position:

@example
(@var{window} @var{area-or-pos} (@var{x} . @var{y}) @var{timestamp}
 @var{object} @var{text-pos} (@var{col} . @var{row})
 @var{image} (@var{dx} . @var{dy}) (@var{width} . @var{height}))
@end example

The @code{posn-} functions access elements of such lists.
@end defun

The following sample function illustrates how the function
@code{window-inside-pixel-edges} can be used to convert
window-relative coordinates, like those returned by the
@code{posn-at-} functions, into frame-relative coordinates:

@example
(defun frame-relative-coordinates (position)
  "Return frame-relative coordinates from POSITION."
  (let* ((x-y (posn-x-y position))
         (window (posn-window position))
         (edges (window-inside-pixel-edges window)))
    (cons (+ (car x-y) (car edges))
          (+ (cdr x-y) (cadr edges)))))
@end example
------------------------- [ cut here ] ------------------------------

             reply	other threads:[~2004-06-07 10:14 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-06-07 10:14 David PONCE [this message]
  -- strict thread matches above, loose matches on Subject: below --
2004-06-04 14:37 `posn-at-point' and `posn-at-x-y' not in manual David PONCE
2004-06-04 16:53 ` Masatake YAMATO
2004-06-04 17:11   ` Masatake YAMATO
2004-06-04 12:15 David PONCE
2004-06-04 12:23 ` Masatake YAMATO
2004-06-07 10:47 ` Kim F. Storm
2004-06-04 11:56 David PONCE
2004-06-04 12:10 ` David Kastrup
2004-06-05 13:49 ` Richard Stallman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=29405516.1086603299144.JavaMail.www@wwinf0303 \
    --to=david.ponce@wanadoo.fr \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).