From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Masatake YAMATO Newsgroups: gmane.emacs.devel Subject: Re: `posn-at-point' and `posn-at-x-y' not in manual Date: Sat, 05 Jun 2004 01:53:18 +0900 (JST) Sender: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Message-ID: <20040605.015318.205310889.jet@gyve.org> References: <6581542.1086359828010.JavaMail.www@wwinf0603> NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1086368077 22102 80.91.224.253 (4 Jun 2004 16:54:37 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Fri, 4 Jun 2004 16:54:37 +0000 (UTC) Cc: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Fri Jun 04 18:54:28 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 1BWHxb-0007wF-00 for ; Fri, 04 Jun 2004 18:54:27 +0200 Original-Received: from lists.gnu.org ([199.232.76.165]) by quimby.gnus.org with esmtp (Exim 3.35 #1 (Debian)) id 1BWHxb-0000FA-00 for ; Fri, 04 Jun 2004 18:54:27 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1BWHxz-0005EE-PJ for emacs-devel@quimby.gnus.org; Fri, 04 Jun 2004 12:54:51 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.33) id 1BWHxx-0005DV-FO for emacs-devel@gnu.org; Fri, 04 Jun 2004 12:54:49 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.33) id 1BWHxv-0005Ci-NY for emacs-devel@gnu.org; Fri, 04 Jun 2004 12:54:49 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1BWHxv-0005Cf-KO for emacs-devel@gnu.org; Fri, 04 Jun 2004 12:54:47 -0400 Original-Received: from [210.130.136.40] (helo=r-maa.spacetown.ne.jp) by monty-python.gnu.org with esmtp (Exim 4.34) id 1BWHx6-0004yq-M7 for emacs-devel@gnu.org; Fri, 04 Jun 2004 12:53:57 -0400 Original-Received: from localhost (h219-110-074-001.catv01.itscom.jp [219.110.74.1]) by r-maa.spacetown.ne.jp (8.11.6) with ESMTP id i54GroR28576; Sat, 5 Jun 2004 01:53:51 +0900 (JST) Original-To: david.ponce@wanadoo.fr In-Reply-To: <6581542.1086359828010.JavaMail.www@wwinf0603> X-Mailer: Mew version 4.0.62 on Emacs 21.3.50 / Mule 5.0 (SAKAKI) 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:24537 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:24537 > >>Of course! Thanks! > >>As an example, here is an implementation of a `set-mouse-at-point' > >>function that seems to work very well :-) > > > > > > How about tooltip? > > Doctor, please show a sample. People wish your epiphany:-) > > > > Here it is: Thank you, sir. However, I'd like not to move the mouse cursor if possible. I've implemented `point-pixel-position' based on your code. Maybe this code is applicable to popup menu. (defun point-pixel-position () "Same as `mouse-pixel-position' but for point." (let* ((pos (posn-at-point)) (x-y (posn-x-y pos)) (wnd (posn-window pos)) (frm (window-frame wnd)) (edg (window-pixel-edges wnd))) (cons frm (cons (+ (car x-y) (car edg) (frame-char-width frm)) (+ (cdr x-y) (cadr edg) (/ (frame-char-height frm) 2)))))) (defun tooltip-show-at-point (text) "Display a tooltip with TEXT near cursor without moving mouse cursor." (let* ((oP (mouse-pixel-position)) (nP (point-pixel-position)) (tooltip-x-offset tooltip-x-offset) (tooltip-y-offset tooltip-y-offset)) ;; The current mouse position is out of range. ;; Do dirty thing here. (if (or (null (cadr oP)) (null (cddr oP))) (set-mouse-pixel-position (nth 0 nP) (nth 1 nP) (nthcdr 2 nP)) (setq tooltip-x-offset (+ (if tooltip-x-offset tooltip-x-offset 5) (- (cadr nP) (cadr oP))) tooltip-y-offset (+ (if tooltip-y-offset tooltip-y-offset -10) (- (cddr nP)(cddr oP))))) (tooltip-show text) ))