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:35:49 -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="15888"; 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:36:42 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 1sSHO5-0003ty-D5 for geh-help-gnu-emacs@m.gmane-mx.org; Fri, 12 Jul 2024 16:36:41 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sSHNV-0005wb-1D; Fri, 12 Jul 2024 10:36:05 -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 1sSHNT-0005vA-ID for help-gnu-emacs@gnu.org; Fri, 12 Jul 2024 10:36:03 -0400 Original-Received: from mail-vs1-xe2e.google.com ([2607:f8b0:4864:20::e2e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sSHNR-0000co-Kq for help-gnu-emacs@gnu.org; Fri, 12 Jul 2024 10:36:03 -0400 Original-Received: by mail-vs1-xe2e.google.com with SMTP id ada2fe7eead31-48c2d353b01so753136137.2 for ; Fri, 12 Jul 2024 07:36:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1720794960; x=1721399760; 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=7Udr6qslmKt9zRiIp9GB6hCiXka9K9ngyP/Voo6aStY=; b=g1vvQyT2wdMIoOriNkhhN7Q/HosIBvZNVBTIYIuCJgDllGtSJCYvEn+A52uUbU+Puk QMIwnPcVmR80kuDDXKZsanfJdMi+iIaml1sLGBKHCy0iZRtwt6RyLDP190cuvTDabe3T NGLJVz0R61zbpgLqpkuve12pAVxKpLg6uipz7pa+uyAiBNhpd6QYBx99QWxfb2twKeWw 8gBtTfpmwxien93OcXdf9Ui+J8Ng4Ipn80tqwn0yHIgrwhZAcZlGH+fkxnPcX/mjSJBX R9U/xWdElz4IIkCXYr3sDFjlc9fvJWaEveFRr1MpA/bReTt70ymYjSXF1nLmovyROo11 2F5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720794960; x=1721399760; 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=7Udr6qslmKt9zRiIp9GB6hCiXka9K9ngyP/Voo6aStY=; b=JYzHAq6oUHPqN+5OP7KfzhhnRu/UeD3BpjQ91eqPQ2YFVxLNWKgJjjpqbF5eRrAwie Pr5qWeex4+BkdI97WjgXZdV0oZ43JM1uio4k5n75/B9wfyFTyLxPo45rNFwl2LgWcrIp TeFn3lm7rMPQKwbc9k1xN1SEUX6ZW3KjcOnJXefb4hTKON3pzywTVUoC9+dA418YFtZ+ GIqJAhJ6e5CoKmqG13546pg0ExD+tOaBkLvjrkDyNOjJxlOHXkyT5EicRRHODvU7dZ2O 5WnUYRjbsiisBGaSvEAY6IIbybtdB/nQv8onp6FHIYIJRyiX98KBGi75G3Gi9yi1y2hk 9ybA== X-Gm-Message-State: AOJu0Yyzq9ZGLLtzuDd2uRhVxJV6sn09BPFd96+r5WNt82akjzdstZXa m+GEY0g3g87yVu16Q1F8wX4YBRq9MQdNWTWsvzkPs2XyIf1Xn8KF1cILBOBfkDeDs0nMdI31gNo uTRK7b+w0363/vlaYWdhf4EfKXssv+add X-Google-Smtp-Source: AGHT+IEzZpiW8zKDnNAH6ShJlCtZmkQQHas6k2syR8zUm0qtiX6SPMg+mZ9xYlRxirySsY+WlouUWvadNmvEDzpunEQ= X-Received: by 2002:a05:6102:2b8a:b0:48c:3e33:998f with SMTP id ada2fe7eead31-4903221f439mr14604074137.31.1720794960542; Fri, 12 Jul 2024 07:36:00 -0700 (PDT) In-Reply-To: Received-SPF: pass client-ip=2607:f8b0:4864:20::e2e; envelope-from=prouleau001@gmail.com; helo=mail-vs1-xe2e.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:147163 Archived-At: On Fri, Jul 12, 2024 at 9:11=E2=80=AFAM Yuri Khan w= rote: > 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 Emac= s > > 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? (sent again, forgot to cc. the list). --=20 /Pierre