From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Pierre Rouleau Newsgroups: gmane.emacs.help Subject: Re: Does code exist to check if a key sequence is valid for Emacs running in terminal mode? Date: Fri, 12 Jul 2024 10:41:00 -0400 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="7231"; mail-complaints-to="usenet@ciao.gmane.io" Cc: help-gnu-emacs To: Yuri Khan Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Fri Jul 12 16:41:53 2024 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1sSHT6-0001fu-G4 for geh-help-gnu-emacs@m.gmane-mx.org; Fri, 12 Jul 2024 16:41:52 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sSHSZ-0005rd-P8; Fri, 12 Jul 2024 10:41:19 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sSHSV-0005aE-Mo for help-gnu-emacs@gnu.org; Fri, 12 Jul 2024 10:41:15 -0400 Original-Received: from mail-vk1-xa2b.google.com ([2607:f8b0:4864:20::a2b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sSHSS-0002LX-IM for help-gnu-emacs@gnu.org; Fri, 12 Jul 2024 10:41:15 -0400 Original-Received: by mail-vk1-xa2b.google.com with SMTP id 71dfb90a1353d-4f2e1093abeso766192e0c.1 for ; Fri, 12 Jul 2024 07:41:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1720795271; x=1721400071; darn=gnu.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=W+oEWDMbn6/yyDwjez9dR1B0KNzCQKjdW7FSubV3XRM=; b=NwioeObC1VXPGP9QbH++GsCHETuJsq6EnIzOZJacQsamg9wEr18UJoozb1zDKatyTq c4BIKDXIwZ71Z3rDAulUH4G1ua031XC1J02SRpJ/zoAKqv2ZpqfMSdU1kWCeYB6g+gVr lwaRfoCGNMLf/jRyR8ibYvmxsCbD/zwaNGBT/9Bp7nSB2dx3MvdVwA3+Epd8P3ld2cuG bMvWP9hiJc1FtPWjA8uLS5p4V9h3qB15q/AUCR2pFqWZCdGfijFoqkIkeo+7bQqhtYll 0Xpaet/sn/lhDRZ2qmRa9W74uk/gTGBUPDoAqZ0owJSuKFa4zxTpPBARtUiG4lBlKH9B qrZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720795271; x=1721400071; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=W+oEWDMbn6/yyDwjez9dR1B0KNzCQKjdW7FSubV3XRM=; b=v6A18EOGgC9h2q2YOsdDMlDM3T2s6nXTdbrP1Bdn30VsNaqe841kw+D3xFfzzYiLVj GXZqpAHedCzI1C2VA+0qcO0YygSGMxKJq+OlYSrCtjMXBMXeLs0YExZ8Fdk6p/KdXjal 0yex5O3QJxrBFK7wPNi+LN2fMose0sSFvp53tGAXXMuFelF45pACeBv63Wl7N1wObFjf Hky5n7nYSEFA5BaBan2yVTjZe54M+imL2ArPBRyR9thbfdjvfhP6mhX8IhOwRm6Rg7BY Y3hU/pzdmPySnQ8vO4NwCJfaPrLVZK4hS6psFBKoJ/m74rb5+zZPaWrWXl4RqAh7ggV0 scVg== X-Gm-Message-State: AOJu0Ywh6DyQ0b5bWM3yR9K4RT7+dSTifZr4STjk983vFwz94bLSmkbj 5SdKlRQyAgbgopfu3qFDiNE7hZfqTgYbusqWUGEdAg1UN1xHKEFBmAdqTEtZiTPespWYaUhnmAC IsoO1aiGG7pPbDp93sA2pzSRP1HKtRg== X-Google-Smtp-Source: AGHT+IH206PY4nim2WqrEXIVI0qXdJhQUGWU6U5y1zD8SGENLFXrsAeTAbbvqu2HWAN+LDDH6JzvnRtXgxyN+TXHXUE= X-Received: by 2002:a05:6122:a0c:b0:4ef:5744:479 with SMTP id 71dfb90a1353d-4f33f207aebmr13846459e0c.1.1720795271351; Fri, 12 Jul 2024 07:41:11 -0700 (PDT) In-Reply-To: Received-SPF: pass client-ip=2607:f8b0:4864:20::a2b; envelope-from=prouleau001@gmail.com; helo=mail-vk1-xa2b.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Content-Filtered-By: Mailman/MimeDel 2.1.29 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.help:147164 Archived-At: On Fri, Jul 12, 2024 at 10:35=E2=80=AFAM Pierre Rouleau wrote: > > > On Fri, Jul 12, 2024 at 9:11=E2=80=AFAM Yuri Khan = wrote: > >> On Fri, 12 Jul 2024 at 19:15, Pierre Rouleau >> wrote: >> >> > Does Emacs already have a predicate function that can be used to check >> if >> > the specified key sequence is valid for Emacs running in terminal mode= ? >> > >> > For example, "C-;" is not accessible on Emacs running in terminal mode >> > because this is not an ASCII control character. It's available for Ema= cs >> > running in graphical environment, but not in terminal mode. >> >> This is probably not solvable because an advanced terminal can >> implement a protocol extension that represents arbitrary keys as >> escape sequences that can then be turned into Emacs key events using >> input-decode-map. >> >> You are correct, it depends on the terminal being used. > I was thinking of writing a function that would call describe-key > but setup the scope to output into a temporary buffer that it > would discard and catch error if the key described is not a > valid one. > > It would therefore like to distinguish the 3 potential cases: > - the key sequence is bound > - the key sequence is not defined. > Like "C-| is undefined" when tried in Emacs running in graphical mode. > - the key sequence is not defined, but reported via an error. > Like "C-;" when tried under Emacs running in terminal mode > inside a terminal that does not remap the C-; to some other escape > sequence. > > That sounds feasible. No? > > The code can determine if Emacs is running a GUI mode or in a terminal mode. In GUI mode it would assume that everything is possible. In terminal mode the issue is being able to distinguish whether the key sequence can be bound or not. The real reason I want to do that is to prevent reporting key binding clashes in code that tries to use the same key binding for 2 different global key bindings when that key binding is not even possible because Emacs will not be able to react to it. --=20 /Pierre