From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Chong Yidong Newsgroups: gmane.emacs.devel Subject: Re: local keymap patch for key-binding Date: Sun, 10 Sep 2006 08:44:19 -0400 Message-ID: <87zmd7yjq4.fsf@furball.mit.edu> References: <87slj1hybl.fsf@stupidchicken.com> <85pse5cbqw.fsf@lola.goethe.zz> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1157892310 3950 80.91.229.2 (10 Sep 2006 12:45:10 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sun, 10 Sep 2006 12:45:10 +0000 (UTC) Cc: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Sep 10 14:45:08 2006 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1GMOgI-0000sP-KT for ged-emacs-devel@m.gmane.org; Sun, 10 Sep 2006 14:45:02 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GMOgI-0001X4-1p for ged-emacs-devel@m.gmane.org; Sun, 10 Sep 2006 08:45:02 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1GMOfm-0001Tf-Tf for emacs-devel@gnu.org; Sun, 10 Sep 2006 08:44:30 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GMOfj-0001Pw-5s for emacs-devel@gnu.org; Sun, 10 Sep 2006 08:44:27 -0400 Original-Received: from [18.72.1.2] (helo=south-station-annex.mit.edu) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA:32) (Exim 4.52) id 1GMOgl-0007S6-Pe; Sun, 10 Sep 2006 08:45:31 -0400 Original-Received: from central-city-carrier-station.mit.edu (CENTRAL-CITY-CARRIER-STATION.MIT.EDU [18.7.7.72]) by south-station-annex.mit.edu (8.13.6/8.9.2) with ESMTP id k8ACiPYt022820; Sun, 10 Sep 2006 08:44:25 -0400 (EDT) Original-Received: from outgoing-legacy.mit.edu (OUTGOING-LEGACY.MIT.EDU [18.7.22.104]) by central-city-carrier-station.mit.edu (8.13.6/8.9.2) with ESMTP id k8ACiPoa014886; Sun, 10 Sep 2006 08:44:25 -0400 (EDT) Original-Received: from furball.mit.edu (SYDNEYPACIFIC-THREE-FORTY-THREE.MIT.EDU [18.95.6.88]) ) by outgoing-legacy.mit.edu (8.13.6/8.12.4) with ESMTP id k8ACiIYa002583; Sun, 10 Sep 2006 08:44:18 -0400 (EDT) Original-Received: from cyd by furball.mit.edu with local (Exim 3.36 #1 (Debian)) id 1GMOfb-0000fi-00; Sun, 10 Sep 2006 08:44:19 -0400 Original-To: David Kastrup In-Reply-To: <85pse5cbqw.fsf@lola.goethe.zz> (David Kastrup's message of "Sat\, 09 Sep 2006 17\:15\:19 +0200") User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux) X-Spam-Score: 1.217 X-Scanned-By: MIMEDefang 2.42 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:59620 Archived-At: David Kastrup writes: > It does too little. Check out what read-key-sequence (defined in > keyboard.c) does with regard to mouse events (EVENT_HAS_PARAMETERS). > The problem is that read-key-sequence does such a load of other stuff > that it is hard to extract the material and transfer it to > key-binding. > > The problem is that keymaps may be provided by text properties and > overlays, and by keymap properties on strings that display as the > display or before-string or after-string properties of text properties > or overlays. I just verified that my patch truly works for keymaps on display strings, text properties, and overlays. For example, with (with-output-to-temp-buffer "Testo" (set-buffer "Testo") (erase-buffer) (let* ((map (make-sparse-keymap)) (str (propertize "foostring" 'keymap map 'mouse-face 'highlight)) ovr) (define-key map [mouse-1] 'delete-window) (insert "1234567890") (setq ovr (make-overlay 2 3)) (overlay-put ovr 'keymap map) (overlay-put ovr 'mouse-face 'highlight) (put-text-property 5 6 'display str) (put-text-property 8 9 'keymap map) (put-text-property 8 9 'mouse-face 'highlight))) C-h k followed by mouse-1 on the overlay, display string, or text propertized region all report the correct action for the given local keymap. The reason is that the mouse event passed to `key-binding' contains all the information you need to reconstruct the binding directly (including whether or not the object we are looking at is a buffer position or a string.) So it seems like there's no problem.