From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Olaf Rogalsky Newsgroups: gmane.emacs.bugs Subject: bug#29104: [PATCH]: xterm-mouse-mode clicks in the modeline dont use the keymap properties of the modeline strings Date: Tue, 07 Nov 2017 00:47:28 +0100 Message-ID: <877ev3nf5b.fsf@t-online.de> References: <87zi869koz.fsf@t-online.de> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: blaine.gmane.org 1510012160 17758 195.159.176.226 (6 Nov 2017 23:49:20 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 6 Nov 2017 23:49:20 +0000 (UTC) To: 29104@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Nov 07 00:49:13 2017 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eBr8j-0004Jp-AV for geb-bug-gnu-emacs@m.gmane.org; Tue, 07 Nov 2017 00:49:13 +0100 Original-Received: from localhost ([::1]:50738 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eBr8q-00028L-QX for geb-bug-gnu-emacs@m.gmane.org; Mon, 06 Nov 2017 18:49:20 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:59459) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eBr8d-00028C-CX for bug-gnu-emacs@gnu.org; Mon, 06 Nov 2017 18:49:11 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eBr8Y-0000Sa-F5 for bug-gnu-emacs@gnu.org; Mon, 06 Nov 2017 18:49:07 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:46213) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eBr8Y-0000ST-B1 for bug-gnu-emacs@gnu.org; Mon, 06 Nov 2017 18:49:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1eBr8Y-0000QC-2F for bug-gnu-emacs@gnu.org; Mon, 06 Nov 2017 18:49:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Olaf Rogalsky Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 06 Nov 2017 23:49:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 29104 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.15100120991562 (code B ref -1); Mon, 06 Nov 2017 23:49:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 6 Nov 2017 23:48:19 +0000 Original-Received: from localhost ([127.0.0.1]:54894 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eBr7r-0000P8-BG for submit@debbugs.gnu.org; Mon, 06 Nov 2017 18:48:19 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:40028) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eBr7o-0000Ou-Dp for submit@debbugs.gnu.org; Mon, 06 Nov 2017 18:48:16 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eBr7i-0000C0-93 for submit@debbugs.gnu.org; Mon, 06 Nov 2017 18:48:11 -0500 Original-Received: from lists.gnu.org ([2001:4830:134:3::11]:35393) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eBr7i-0000Bw-67 for submit@debbugs.gnu.org; Mon, 06 Nov 2017 18:48:10 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:59224) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eBr7g-00026O-MI for bug-gnu-emacs@gnu.org; Mon, 06 Nov 2017 18:48:09 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eBr7b-0000A4-Oz for bug-gnu-emacs@gnu.org; Mon, 06 Nov 2017 18:48:08 -0500 Original-Received: from mailout10.t-online.de ([194.25.134.21]:33976) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eBr7b-00009A-HV for bug-gnu-emacs@gnu.org; Mon, 06 Nov 2017 18:48:03 -0500 Original-Received: from fwd21.aul.t-online.de (fwd21.aul.t-online.de [172.20.27.66]) by mailout10.t-online.de (Postfix) with SMTP id F245741C2E5D for ; Tue, 7 Nov 2017 00:47:59 +0100 (CET) Original-Received: from blaubaer (rAQ4LUZ6QhBN2ER9XyqZxIVc6vq8GOrgDI10HBjaR5IST1PTIpfiAC4p+4T4fzlZGC@[84.57.184.143]) by fwd21.t-online.de with (TLSv1.2:DHE-RSA-AES256-SHA256 encrypted) esmtp id 1eBr7T-0DtWE40; Tue, 7 Nov 2017 00:47:55 +0100 In-reply-to: <87zi869koz.fsf@t-online.de> X-ID: rAQ4LUZ6QhBN2ER9XyqZxIVc6vq8GOrgDI10HBjaR5IST1PTIpfiAC4p+4T4fzlZGC X-TOI-MSGID: 1452233c-fb10-433c-a658-061bfe5838b5 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:139536 Archived-At: Hi, I would like to give some more details on the patch and which problem it tries to solve. Ultimately I try to get better support of the mouse under xterm. The following features currently do not work with the mouse under xterm: 1. Mouse clicks on menu-bar always brings up the left-most menu, but not the menu under the spot. =20 2. A mouse click on the mode-line activates the window, but does not trigger the local-map property on the spot. 3. When moving the mouse over some text with a mouse-face property or help-echo property nothing happens, because xterm-mouse-mode does not receive any mouse motion events from the controlling xterm (except during dragging operations). I haven't looked into (1), but I am testing a solution for (2) and (3). This patch (#29104) addresses (2). It does not implement a new feature, but tries to make a bugfix to keyboard.c:read_key_sequence. This function is a 900 lines nightmare of spaggheti code, full of global state and goto's. At least it is somehow documented. But here we go, this is what I understood so far: The function reads input characters until some keybinding is found or until the sequence does not form a prefix key sequence anymore. If the trailing characters, which have been read so far, form a sequence in a translation keymap (input-decode-map, key-translation-map, local-function-key-map), those trailing characters are replaced by the binding of the translation map. Thereafter a jump back close to the beginning of the function is made and all events up to the replacement event are reinterpreted again. Such jumps ("goto replay_sequence;") take place immediately after the lines, which I introduced in the patch. When replaying the sequence, the variable "first_event" will be used to select the currently active keymaps (line 9035). In case, that the first characters are bound in a key translation map, first_event still holds (incrorrectly, as I presume) the first character of the translation sequence and not its binding. My patch takes place after a key translation has been performed. It checks, that the key translation is not empty, (or more precisely, that the current event sequence is not empty), first_event =3D mock_input > 0 ? keybuf[0] : Qnil; =20 ^^^^^^^^^^^^^^ and if so, sets the variable first_event to the first event in the sequence. first_event =3D mock_input > 0 ? keybuf[0] : Qnil; =20 ^^^^^^^^^ Here, all key translations where allready replaced by their corresponding binding. If the current event sequence is empty, first_event is set to Qnil, which means that the default active keymaps should be used. This would be the case, if the raw key sequence was bound to an empty vector in a translation map. first_event =3D mock_input > 0 ? keybuf[0] : Qnil; =20 ^^^^ Now back to my original problem: mouse clicks in the mode line do not work correctly. xterm-mouse-mode uses the input-decode-map to translate special character sequences coming from xterm (starting with "\e[") into proper mouse events. Without the patch, first_event is set to ?\e. Therefore the esc-map is used to find a binding for the mouse event, which of cause does not work as intended. With the patch, first_event is set to the mouse event and the binding in the local-map property will be found. Et vola, mouse clicks in the mode line will work :-) Olaf PS: You might ask, why I check for empty key translations. I need those for (3). --=20 Olaf Rogalsky Schw=C3=B6rhausgasse 5 89073 Ulm Germany