From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: David PONCE Newsgroups: gmane.emacs.devel Subject: Re: `posn-at-point' and `posn-at-x-y' not in manual Date: Mon, 7 Jun 2004 12:14:59 +0200 (CEST) Sender: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Message-ID: <29405516.1086603299144.JavaMail.www@wwinf0303> Reply-To: david.ponce@wanadoo.fr NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1086603348 8523 80.91.224.253 (7 Jun 2004 10:15:48 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Mon, 7 Jun 2004 10:15:48 +0000 (UTC) Cc: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Mon Jun 07 12:15:39 2004 Return-path: Original-Received: from quimby.gnus.org ([80.91.224.244]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1BXHAJ-0000pQ-00 for ; Mon, 07 Jun 2004 12:15:39 +0200 Original-Received: from lists.gnu.org ([199.232.76.165]) by quimby.gnus.org with esmtp (Exim 3.35 #1 (Debian)) id 1BXHAJ-0001un-00 for ; Mon, 07 Jun 2004 12:15:39 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1BXHAq-0000XQ-6r for emacs-devel@quimby.gnus.org; Mon, 07 Jun 2004 06:16:12 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.33) id 1BXHAj-0000XL-OA for emacs-devel@gnu.org; Mon, 07 Jun 2004 06:16:05 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.33) id 1BXHAh-0000X5-W7 for emacs-devel@gnu.org; Mon, 07 Jun 2004 06:16:05 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1BXHAh-0000X1-Rr for emacs-devel@gnu.org; Mon, 07 Jun 2004 06:16:03 -0400 Original-Received: from [193.252.22.28] (helo=mwinf0304.wanadoo.fr) by monty-python.gnu.org with esmtp (Exim 4.34) id 1BXH9g-0004c6-D1; Mon, 07 Jun 2004 06:15:00 -0400 Original-Received: from wwinf0303 (wwinf0303 [172.22.134.30]) by mwinf0304.wanadoo.fr (SMTP Server) with ESMTP id 2684BA803E31; Mon, 7 Jun 2004 12:14:59 +0200 (CEST) Original-To: rms@gnu.org X-Originating-IP: [194.2.245.141] X-WUM-FROM: |~| X-WUM-TO: |~| X-WUM-CC: |~| X-WUM-REPLYTO: |~| X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.4 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Xref: main.gmane.org gmane.emacs.devel:24656 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:24656 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 ] ------------------------------