From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: JD Smith Newsgroups: gmane.emacs.bugs Subject: bug#70576: [PATCH] `repeat-echo-message-string': support repeat keymap "hints" Date: Thu, 25 Apr 2024 18:31:17 -0400 Message-ID: <45C35B69-6DA8-4212-BD87-50B2A3959A86@gmail.com> Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3774.500.171.1.1\)) Content-Type: multipart/alternative; boundary="Apple-Mail=_6D883527-1EA0-4AB0-8546-FDB9C04B9D91" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="36325"; mail-complaints-to="usenet@ciao.gmane.io" To: 70576@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Apr 26 00:33:25 2024 Return-path: Envelope-to: geb-bug-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 1s07ee-0009K3-Uh for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 26 Apr 2024 00:33:25 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s07eD-0007lb-Nr; Thu, 25 Apr 2024 18:32:59 -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 1s07e7-0007jc-NZ for bug-gnu-emacs@gnu.org; Thu, 25 Apr 2024 18:32:51 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1s07e5-0005J0-MN for bug-gnu-emacs@gnu.org; Thu, 25 Apr 2024 18:32:51 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1s07eN-0003my-2Q for bug-gnu-emacs@gnu.org; Thu, 25 Apr 2024 18:33:07 -0400 X-Loop: help-debbugs@gnu.org Resent-From: JD Smith Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 25 Apr 2024 22:33:05 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 70576 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.171408434514078 (code B ref -1); Thu, 25 Apr 2024 22:33:05 +0000 Original-Received: (at submit) by debbugs.gnu.org; 25 Apr 2024 22:32:25 +0000 Original-Received: from localhost ([127.0.0.1]:33448 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s07dZ-0003eK-Iz for submit@debbugs.gnu.org; Thu, 25 Apr 2024 18:32:24 -0400 Original-Received: from lists.gnu.org ([2001:470:142::17]:35292) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s07dG-0003aI-Ek for submit@debbugs.gnu.org; Thu, 25 Apr 2024 18:32:09 -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 1s07cs-0007dK-HE for bug-gnu-emacs@gnu.org; Thu, 25 Apr 2024 18:31:34 -0400 Original-Received: from mail-il1-x131.google.com ([2607:f8b0:4864:20::131]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1s07cq-0004pk-9a for bug-gnu-emacs@gnu.org; Thu, 25 Apr 2024 18:31:34 -0400 Original-Received: by mail-il1-x131.google.com with SMTP id e9e14a558f8ab-36b1774e453so5620835ab.1 for ; Thu, 25 Apr 2024 15:31:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1714084289; x=1714689089; darn=gnu.org; h=to:date:message-id:subject:mime-version:from:from:to:cc:subject :date:message-id:reply-to; bh=0oOh1iZjh3BRUZv8Su+wl/j9+9vRwCaQIdvTS3ii3IY=; b=hnOygL3MKmYB80LxGqNiL82OJZmJ9iMj4brJoIeiFviXBT5jbLaSJn9BN7ea8k+rVk HY/e8ELWPdPrXBjFEstytT2pyGdBanWGpTcXFYUWM0vUa6nGCn0Inp0qK02yKKs9Zns/ +Rqoj7PdjmwMEkDcdgDknuqKXyuhsI9erWDqCAv1Sc5ZYYN0qM+aO7JAgYjQ2BOrJiHX sUAhMbi9B2jZsY+83NX0ibaMiLLXUVp6pc6e/eYSqO1wZCI0iLyXDMXx9aDC3e9mojEi F1H/efl+FAZyHQmjYCHi3Z4+1zs6PgYe4AzWW46XTSz5a8si5+T06d3upcOEGDfzcx8h SxHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714084289; x=1714689089; h=to:date:message-id:subject:mime-version:from:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=0oOh1iZjh3BRUZv8Su+wl/j9+9vRwCaQIdvTS3ii3IY=; b=tngLpcHCUEvYSb36TztRswkIXW8MiEp5753x7g6mERtzWhEMiGuu70KkLaWxUtblCg Rgbqtu9nth0IfY/tdyaKaQzO0YAKsE7Ei4JlL77tq3E5hnVlkL1xNQqbRrXGjOX5Q8ai 46RIn5Pci147ye0lTy3prtueOmGz8jRYZasAb51bB7RmmWtkB6/UHaBtng66RaQfHfzd HEj0e9p40RkhT5/T75MoQCdCAQzmPZh9JtlGzAh7TfqSG9e2XHQGohRYnGK8QFdswesA OgV9cabYHLgYy0+qlVEMQ1xDOmYbBjyueWKouX9r5AtUO06kJejSzLsIMhjSIzSmE6xq hVjQ== X-Gm-Message-State: AOJu0YzJRYmdCpah8bkArtz5xwk5uXxxM6j6CVdiY/nUVBjrVBwaJMui PaYyV0ziiCBNajND80A67JkpYjdCbHumbzYR/D/3PQVyMkvmW8m/sHVrPA== X-Google-Smtp-Source: AGHT+IFIS3E05/+TAi8NPhrklWTV1JRLlTfvXT6qtariDq5jJMeJ2DUU8MNXbnMqn9FmOb10jSknig== X-Received: by 2002:a05:6e02:160f:b0:36c:f61:7648 with SMTP id t15-20020a056e02160f00b0036c0f617648mr1374635ilu.13.1714084289025; Thu, 25 Apr 2024 15:31:29 -0700 (PDT) Original-Received: from smtpclient.apple (cm-24-53-187-34.buckeyecom.net. [24.53.187.34]) by smtp.gmail.com with ESMTPSA id x3-20020a92cc83000000b0036c03b1ee38sm2845306ilo.37.2024.04.25.15.31.27 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 25 Apr 2024 15:31:28 -0700 (PDT) X-Mailer: Apple Mail (2.3774.500.171.1.1) Received-SPF: pass client-ip=2607:f8b0:4864:20::131; envelope-from=jdtsmith@gmail.com; helo=mail-il1-x131.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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_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-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list 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-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:283959 Archived-At: --Apple-Mail=_6D883527-1EA0-4AB0-8546-FDB9C04B9D91 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii repeat-mode is excellent for informal and very lightweight modal = interfaces (great article = ). One limitation = it has compared to other such interfaces is it only mentions the keys = which can be repeated, without providing hints about what they do. =20 A simple patch to `repeat-echo-message-strings' to support displaying a = string for keymap definitions of form (STRING . DEFN) is below. It = works nicely to provide "hints" after each repeat key, if the keymap = includes them. Example usage: (defvar-keymap expreg-repeat-map :doc "Repeat map for `expreg' actions." :repeat t :name "expreg" "\\" (cons "expand" 'expreg-expand) "|" (cons "contract" 'expreg-contract)) Example prompt (after one invocation of `expreg-expand'):=20 Repeat with \:expand, |:contract It might also be useful to provide a custom variable by which a user can = disable hint strings, for the experts/minimalists.. Patch: --- repeat_old.el 2024-04-25 18:22:59 +++ repeat.el 2024-04-25 18:09:11 @@ -553,12 +553,20 @@ (defun repeat-echo-message-string (keymap) "Return a string with the list of repeating keys in KEYMAP." (let (keys) - (map-keymap (lambda (key cmd) (and cmd (push key keys))) keymap) + (map-keymap (lambda (key cmd) + (if (consp cmd) + (push (cons (car cmd) key) keys) + (when cmd (push key keys)))) + keymap) (format-message "Repeat with %s%s" (mapconcat (lambda (key) - (substitute-command-keys - (format "\\`%s'" - (key-description (vector = key))))) + (let* ((cmd (when (consp key) (format = ":%s" (car key))))) + (if (consp key) (setq key (cdr key))) + (concat + (substitute-command-keys + (format "\\`%s'" + (key-description (vector = key)))) + cmd))) keys ", ") (if repeat-exit-key (substitute-command-keys --Apple-Mail=_6D883527-1EA0-4AB0-8546-FDB9C04B9D91 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=us-ascii
repeat-mode is excellent for informal and very = lightweight modal interfaces (great = article).  One limitation it has compared to other such = interfaces is it only mentions the keys which can be repeated, without = providing hints about what they do.  

A = simple patch to `repeat-echo-message-strings' to support displaying a = string for keymap definitions of form (STRING . DEFN) is below. =  It works nicely to provide "hints" after each repeat key, if the = keymap includes them.

Example = usage:

(defvar-keymap = expreg-repeat-map

    :doc "Repeat map for `expreg' = actions."

    :repeat t

    :name = "expreg"

    "\\" (cons "expand" = 'expreg-expand)

    "|"  (cons "contract" =  'expreg-contract))


Example prompt (after one invocation of = `expreg-expand'): 

 Repeat with \:expand, = |:contract


It might also = be useful to provide a custom variable by which a user can disable hint = strings, for the = experts/minimalists..

Patch:

--- = repeat_old.el = 2024-04-25 18:22:59

+++ repeat.el = 2024-04-25 18:09:11

@@ -553,12 +553,20 = @@

 (defun = repeat-echo-message-string (keymap)

   = "Return a string with the list of repeating keys in = KEYMAP."

   (let = (keys)

-    = (map-keymap (lambda (key cmd) (and cmd (push key keys))) = keymap)

+    = (map-keymap (lambda (key cmd)

+ =   (if (consp cmd)

+ =       (push (cons (car cmd) key) = keys)

+ =     (when cmd (push key = keys))))

+ = keymap)

   =   (format-message "Repeat with %s%s"

   =                   = (mapconcat (lambda (key)

-     =                     =         = (substitute-command-keys

-    =                     =           (format = "\\`%s'"

-    =                     =                   = (key-description (vector key)))))

+ = (let* ((cmd (when (consp key) (format ":%s" (car = key)))))

+ =   (if (consp key) (setq key (cdr = key)))

+ =   (concat

+ =     (substitute-command-keys

+ =     (format "\\`%s'"

+ =     (key-description (vector = key))))

+ =     cmd)))

    =                     =         keys ", ")

   =                   (if = repeat-exit-key

   =                     =   (substitute-command-keys


= --Apple-Mail=_6D883527-1EA0-4AB0-8546-FDB9C04B9D91--