From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: David Reitter Newsgroups: gmane.emacs.bugs Subject: bug#2044: posn-point wrong when face-remapping-alist used Date: Sun, 25 Jan 2009 09:39:08 -0500 Message-ID: <33CE239F-C1F7-49E1-8678-29AE916EBDB8@gmail.com> Reply-To: David Reitter , 2044@emacsbugs.donarmstrong.com NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 (Apple Message framework v930.3) Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1232900194 5940 80.91.229.12 (25 Jan 2009 16:16:34 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 25 Jan 2009 16:16:34 +0000 (UTC) To: emacs-pretest-bug@gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Jan 25 16:04:56 2009 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1LR6Xf-0000op-6A for geb-bug-gnu-emacs@m.gmane.org; Sun, 25 Jan 2009 16:04:56 +0100 Original-Received: from localhost ([127.0.0.1]:52353 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LR6WN-0000g5-K5 for geb-bug-gnu-emacs@m.gmane.org; Sun, 25 Jan 2009 10:03:35 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LR6WL-0000fE-G4 for bug-gnu-emacs@gnu.org; Sun, 25 Jan 2009 10:03:33 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LR6WJ-0000ex-V6 for bug-gnu-emacs@gnu.org; Sun, 25 Jan 2009 10:03:33 -0500 Original-Received: from [199.232.76.173] (port=53258 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LR6WJ-0000eu-T7 for bug-gnu-emacs@gnu.org; Sun, 25 Jan 2009 10:03:31 -0500 Original-Received: from rzlab.ucr.edu ([138.23.92.77]:49384) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1LR6WJ-0006Q3-47 for bug-gnu-emacs@gnu.org; Sun, 25 Jan 2009 10:03:31 -0500 Original-Received: from rzlab.ucr.edu (rzlab.ucr.edu [127.0.0.1]) by rzlab.ucr.edu (8.13.8/8.13.8/Debian-3) with ESMTP id n0PF3Ton022184; Sun, 25 Jan 2009 07:03:29 -0800 Original-Received: (from debbugs@localhost) by rzlab.ucr.edu (8.13.8/8.13.8/Submit) id n0PEj3DC017615; Sun, 25 Jan 2009 06:45:03 -0800 X-Loop: owner@emacsbugs.donarmstrong.com Resent-From: David Reitter Resent-To: bug-submit-list@donarmstrong.com Resent-CC: Emacs Bugs Resent-Date: Sun, 25 Jan 2009 14:45:03 +0000 Resent-Message-ID: Resent-Sender: owner@emacsbugs.donarmstrong.com X-Emacs-PR-Message: report 2044 X-Emacs-PR-Package: emacs X-Emacs-PR-Keywords: Original-Received: via spool by submit@emacsbugs.donarmstrong.com id=B.123289435816219 (code B ref -1); Sun, 25 Jan 2009 14:45:03 +0000 Original-Received: (at submit) by emacsbugs.donarmstrong.com; 25 Jan 2009 14:39:18 +0000 X-Spam-Bayes: score:0.5 Bayes not run. spammytokens:Tokens not available. hammytokens:Tokens not available. Original-Received: from fencepost.gnu.org (fencepost.gnu.org [140.186.70.10]) by rzlab.ucr.edu (8.13.8/8.13.8/Debian-3) with ESMTP id n0PEdE8K016213 for ; Sun, 25 Jan 2009 06:39:15 -0800 Original-Received: from mail.gnu.org ([199.232.76.166]:34058 helo=mx10.gnu.org) by fencepost.gnu.org with esmtp (Exim 4.67) (envelope-from ) id 1LR67G-0002zp-R1 for emacs-pretest-bug@gnu.org; Sun, 25 Jan 2009 09:37:38 -0500 Original-Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim 4.60) (envelope-from ) id 1LR68m-000324-Tb for emacs-pretest-bug@gnu.org; Sun, 25 Jan 2009 09:39:13 -0500 Original-Received: from qw-out-1920.google.com ([74.125.92.144]:54016) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1LR68m-000320-Ji for emacs-pretest-bug@gnu.org; Sun, 25 Jan 2009 09:39:12 -0500 Original-Received: by qw-out-1920.google.com with SMTP id 4so1122817qwk.24 for ; Sun, 25 Jan 2009 06:39:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:from:to :content-type:content-transfer-encoding:mime-version:subject:date :x-mailer; bh=T1PbpMHPOnNM1KcEuOgIRhQ40zZwXd5XlEQV7DzYyvE=; b=niKC8Zd7qW1kJ1hPKzj53V5CG/VZJ3+sN41uV9d/mlBUuVRD7INLooDNKfugjlpL60 RqUFVetO5BWeIwxC3ysP4TMI0Jbm4sDqLpRXW4V1/pErdkSZ8Ym6Jm9ogBBGEAkVXICw 2K+E4sNdvtbt8bDn84yAF9Xn19V5gclm6Ly7o= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:from:to:content-type:content-transfer-encoding :mime-version:subject:date:x-mailer; b=ijybOCM41xuuT9jT+Rkhv8Gk7AXYkBncoZGie9jnDmg4iQfFVNTkmWPcGxLcr/chPK 0jh+l61aPu70IK76HJ1q7htWm5SR0ADfPWOMsMGeTkbt4jtX6fVWQkqMXgbzY4+XAuC1 2Uh7cFBCdgtq0KBxCtzTDjbrk5QnHW6Pcdst4= Original-Received: by 10.214.148.5 with SMTP id v5mr7063982qad.312.1232894351634; Sun, 25 Jan 2009 06:39:11 -0800 (PST) Original-Received: from scarlett.local (pool-71-162-19-14.pitbpa.east.verizon.net [71.162.19.14]) by mx.google.com with ESMTPS id 7sm15607092ywo.30.2009.01.25.06.39.09 (version=TLSv1/SSLv3 cipher=RC4-MD5); Sun, 25 Jan 2009 06:39:10 -0800 (PST) X-Mailer: Apple Mail (2.930.3) X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2) X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 3) Resent-Date: Sun, 25 Jan 2009 10:03:33 -0500 X-BeenThere: bug-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:24505 Demonstration first: emacs -Q (split-window) (find-file "~/.emacs") ;; any file will do, or switch to another buffer (set (make-local-variable 'face-remapping-alist) '((default . variable- pitch))) The two buffers should now be shown in different faces. Now click (don't drag) into the windows, alternating between the two of them. You will see that various regions are marked, each of them between some seemingly arbitrary point near the mouse click (=mark), and the the point under the mouse. This shouldn't be. Instead, we would expect to only set the point, as is the case without the `face- remapping-alist' use above. This seems to happen whenever a click into a non-selected window is evaluated, and the faces differ in the two windows due to an entry in `face-remapping-alist'. Some analysis: The problem is that (posn-point (event-start start-event)) in mouse- drag-region does not give us the correct location; in fact, the xy coordinates in the event are wrong. My guess is that whatever algorithm determines the character position under the mouse cursor forgets to switch to the appropriate window buffer before looking up the faces when iterating over the window contents. I could probably fix this myself if I knew where this bit of code is... remember_mouse_glyph() probably doesn't have a part in this (because that one should work as is). For what its worth, I am using the code below (in xfaces.c) in some time-critical places to lookup a face in a buffer without having to make this buffer temporarily current. This may come in handy in order to fix this. int lookup_basic_face_for_buffer (f, face_id, buffer) struct frame *f; int face_id; Lisp_Object buffer; { Lisp_Object name, mapping; int remapped_face_id; Lisp_Object Vlocal_remapping_alist = Fbuffer_local_value (intern("face-remapping-alist"), buffer); if (NILP (Vlocal_remapping_alist)) return face_id; /* Nothing to do. */ switch (face_id) { case DEFAULT_FACE_ID: name = Qdefault; break; case MODE_LINE_FACE_ID: name = Qmode_line; break; case MODE_LINE_INACTIVE_FACE_ID: name = Qmode_line_inactive; break; case HEADER_LINE_FACE_ID: name = Qheader_line; break; case TOOL_BAR_FACE_ID: name = Qtool_bar; break; case FRINGE_FACE_ID: name = Qfringe; break; case SCROLL_BAR_FACE_ID: name = Qscroll_bar; break; case BORDER_FACE_ID: name = Qborder; break; case CURSOR_FACE_ID: name = Qcursor; break; case MOUSE_FACE_ID: name = Qmouse; break; case MENU_FACE_ID: name = Qmenu; break; default: abort (); /* the caller is supposed to pass us a basic face id */ } /* Do a quick scan through Vface_remapping_alist, and return immediately if there is no remapping for face NAME. This is just an optimization for the very common no-remapping case. */ mapping = assq_no_quit (name, Vlocal_remapping_alist); if (NILP (mapping)) return face_id; /* Give up. */ /* If there is a remapping entry, lookup the face using NAME, which will handle the remapping too. Avoid setting current buffer (slow). */ Lisp_Object old_face_remapping_alist = Vface_remapping_alist; Vface_remapping_alist = Vlocal_remapping_alist; remapped_face_id = lookup_named_face (f, name, 0, 0); Vface_remapping_alist = old_face_remapping_alist; if (remapped_face_id < 0) return face_id; /* Give up. */ return remapped_face_id; }