From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Yuri Khan Newsgroups: gmane.emacs.devel Subject: Re: input-decode-map: Silently ignore certain sequences Date: Sun, 16 Dec 2018 21:35:00 +0700 Message-ID: References: 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 1544970806 16213 195.159.176.226 (16 Dec 2018 14:33:26 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 16 Dec 2018 14:33:26 +0000 (UTC) Cc: Emacs developers To: andlind@gmail.com Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Dec 16 15:33:22 2018 Return-path: Envelope-to: ged-emacs-devel@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 1gYXTt-000487-CD for ged-emacs-devel@m.gmane.org; Sun, 16 Dec 2018 15:33:21 +0100 Original-Received: from localhost ([::1]:42680 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gYXW0-0004eR-4e for ged-emacs-devel@m.gmane.org; Sun, 16 Dec 2018 09:35:32 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:38116) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gYXVs-0004di-V5 for emacs-devel@gnu.org; Sun, 16 Dec 2018 09:35:25 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gYXVr-0002Z7-19 for emacs-devel@gnu.org; Sun, 16 Dec 2018 09:35:24 -0500 Original-Received: from mail-ot1-x330.google.com ([2607:f8b0:4864:20::330]:39134) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gYXVp-0002Lh-Vi for emacs-devel@gnu.org; Sun, 16 Dec 2018 09:35:22 -0500 Original-Received: by mail-ot1-x330.google.com with SMTP id n8so9866700otl.6 for ; Sun, 16 Dec 2018 06:35:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=tGWEC76N1aEAHsfkIg3WB4COSgg0joOpnA3Su1C8UfM=; b=KlVmb0v2fyZE61QxlJ5B5vY5+7V/UcW1WaAnt8P9IMFT4tJ3ybU1LCpFhQCXqzz+Rx wh61GVl/ms8pozmi/QlC5Q3yCmuFmaqCmbkCtwPTMU1GHj1tsGEVqG7ocsgkQ3eeimbe REuzVdysX7EdvH+1KGdQFfBaDA4e/NvQhi5AhFKv4rl9Kuz/v2uz2t6CAKxFwHlS5p6T /mdBt8qQJkuqbZ+tNW/KF6l9T2y12IJRWs5ClawOCI1pcuyWdlFT7J3XNcOZks5aQUpX 4N3fsSTjXQiuvWJ37nQu/+gk+yvMmGMDbSrfYCBlFceSlsv36cD4z4kH0EFRgwZ7ZR7k cU2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=tGWEC76N1aEAHsfkIg3WB4COSgg0joOpnA3Su1C8UfM=; b=hkVJs6T15YmFt8U0LDlSfV9VUbKeIKr5s/eZrLNj9fny+1VJ8uWdH2fHYYtXY+dtwn bU2zwAxrI069AbAGZUNvJCMPStKh1IxzYTlsMMqhwmILD3+T0niXDpGTtQKYhhlDL2I6 J+G8dZYq8uyCRy3jKY8M5iUfF25eJuE8m3iAZmYmSWAMMsmfkVwF3va4WHzdQVmKgHbK B6yBX1ILNTbWL1pzpxfwqQYSVN57RvkbsxJOhm5pQuL2IwGddnfxtLFTA3hJjHqjoFjB S5LQTHCyJveZvtDJ0mY+jfpSDdzsHnz6e3sPI72LVOHh6bnJjOX8EISJ6/ot/jg15aFz iwgg== X-Gm-Message-State: AA+aEWbaI3yxK1Vk4j79dXkjZsPs1pDXUdweypOFJrh+2F8YRHjrglQz xFf7eBSwiX3Ayjeu7QirfX6rbWQdvqixgWdSZEY= X-Google-Smtp-Source: AFSGD/Vg077wfEZgAHyMDl8aq6TiDbUwTWsJon8nO3AUftwcv/Qk9Yu6joJ8H2FQM0s0IbUtS6+OwA8D93fEzawf6UY= X-Received: by 2002:a9d:4a87:: with SMTP id i7mr7411310otf.178.1544970913713; Sun, 16 Dec 2018 06:35:13 -0800 (PST) In-Reply-To: X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::330 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:231851 Archived-At: On Sun, Dec 16, 2018 at 7:20 PM Anders Lindgren wrote: > I found myself in a similar situation with an experimental package I've b= een working on, mode-line-keyboard [1]. In this package I need to ignore ev= ent, like key down, all together. My solution is to bind functions to input= -event-map that calls `read-key` recursively, as I found that returning nil= breaks a key sequence. I just realised that I haven't tried [] so I might = need to revisit this. I did not consider calling =E2=80=98read-key=E2=80=99 from a function bound= in =E2=80=98input-event-map=E2=80=99. Instinctively, I=E2=80=99d try to avoid = side effects and especially recursion in any of the key translation maps. Too complicated for me :) I had tried binding nil and #'ignore; neither worked. So I dived into reading C code to get some superficial understanding how =E2=80=98input-event-map=E2=80=99 operates. The short gist of it is that: * A nil binding is treated, as usual in keymaps, equivalently to no binding at all. That is, the sequence is not remapped. * A function gets called with one argument (optional text of the prompt) and its return value is used as if it was the binding (except that if it=E2=80=99s again a function, it will not be called). * A string is treated the same way as a vector of characters. * The ultimate resolution of input-decode-map is a vector of keys, which are stuffed in place of the original subsequence and the resulting sequence is re-interpreted. > Anyway, I found the key map handing in Emacs really confusing. To help me= out I put together a companion package, keymap-logger [2], that logs most = things that is passed to and transformed by the various keymaps like input-= key-map and key-translation-map. Maybe it can help you to gain some insight= of what is going on. That is interesting, although not directly leading to a solution to my case= . I wanted to know when and why the echo area gets cleared, and I found out that it happens when any prefix key is pressed and it=E2=80=99s pretty much a feature. So my current idea of a solution is to save and restore the echo area at appropriate times. I drafted a patch to that effect: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D33749#17