From unknown Wed Jun 18 23:11:46 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#78742 <78742@debbugs.gnu.org> To: bug#78742 <78742@debbugs.gnu.org> Subject: Status: [PATCH] Improve repeat-continue property handling Reply-To: bug#78742 <78742@debbugs.gnu.org> Date: Thu, 19 Jun 2025 06:11:46 +0000 retitle 78742 [PATCH] Improve repeat-continue property handling reassign 78742 emacs submitter 78742 "Paul D. Nelson" severity 78742 normal tag 78742 patch thanks From debbugs-submit-bounces@debbugs.gnu.org Tue Jun 10 04:07:19 2025 Received: (at submit) by debbugs.gnu.org; 10 Jun 2025 08:07:19 +0000 Received: from localhost ([127.0.0.1]:33004 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uOu0s-0000pV-EA for submit@debbugs.gnu.org; Tue, 10 Jun 2025 04:07:19 -0400 Received: from lists.gnu.org ([2001:470:142::17]:45548) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1uOu0n-0000oc-PM for submit@debbugs.gnu.org; Tue, 10 Jun 2025 04:07:15 -0400 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 1uOu0i-0003sX-9r for bug-gnu-emacs@gnu.org; Tue, 10 Jun 2025 04:07:08 -0400 Received: from mail-lf1-x134.google.com ([2a00:1450:4864:20::134]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uOu0f-0007Sp-Vk for bug-gnu-emacs@gnu.org; Tue, 10 Jun 2025 04:07:08 -0400 Received: by mail-lf1-x134.google.com with SMTP id 2adb3069b0e04-55351af2fc6so6178306e87.0 for ; Tue, 10 Jun 2025 01:07:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1749542823; x=1750147623; darn=gnu.org; h=mime-version:message-id:date:subject:to:from:from:to:cc:subject :date:message-id:reply-to; bh=EBYa9V47muO9EDl1FdaMWVgpyCCiC1sxLKxHeBJIQQI=; b=PU+Ctilch9IkMz8VC49dc4p0qUkxRBAG6f2FPsg9f/A7/kghcXC60b2tIwfg+rlR/b XU/jm5e2p50GrZ2KdQ8DIML2GrAz1xnbqCGbtic8HMB/NG8Uu4EEFZRxWVV1uSccIwuq nTyY+6bjAQ6udn7Ki77sW+eLg1GcKWdjdPEY6xa7Evhu10LE3XrGqudIxDakJcpxzkd+ TrCIYuVnr2e4PbO2ozfzhRlxMwwNJy9qnUcbCdUxWSWNdKu12Xn2QOpIow85P4yjmBA7 JJsBn06O3JpZlMtPkBFatiXa1xEePwEKCJUfQXtr7bibPUAQ4cPYCAFC/Jb5g1RXS0nJ cEWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1749542823; x=1750147623; h=mime-version:message-id:date:subject:to:from:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=EBYa9V47muO9EDl1FdaMWVgpyCCiC1sxLKxHeBJIQQI=; b=m7n5UYP/2srfOsOz5fxLQNM+mFT/9bTLcgTJF3tfi8SsTFti7FUUDlRpuRZ8JEEO1G OvHCGlqs/d4apiTckJAvEqpDbETGbYeAqnL5tOxQJ89uylxa4Uvr3xJ2t+95I0zccCNY rU9oJRIdsxr9J8ZJPNjzJ4sL9jE9zpGQf+ATdSt+Ws9IQ51A9WTEjB0dic9k4S/qMixl jkSS2xdZ0a4Ez3OuBtBk6IGOVA+P/0XFK/soX8Hvt+mK2hYgfUuLwovknUzZprGvhUfH 8y4diHYNel8iK1adHRnh2IXj9NflwPiGGoWlkNdd+F3bGAqczODDPq1s7XhhHR+O/1ej JX2w== X-Gm-Message-State: AOJu0Yzh1dpmuoYKNH4w3tkjCH+Z7g/uLm7k0jJUIfYReVffo5Y6Mtzv +2yDqUzWbw9m/rC9ah+2N1E72xuAoERRfNNsx+GQffAqLSLukzPDU/7RmIZwbc1g X-Gm-Gg: ASbGncsx9Sous7kPBqMZoGSmoTaiOL8Bh6Tizwwv5RJlF4icYqbt5Td4fNkE4GaOtSN scyf6IWEzKdJTN0V7MJVjSCwWIkaILApNnD/2HGc/R8mbOQPUo6BHfA9zZd/w/2p9UUjmo4Fzdk zfuadLDFLxxsreWlIIAszbrpB2drca+adDJc5NqjDj1+JczAbD54QegnNFny/ATORlxA+N5eMTP tNCkYgY3IEtxI/3bVRLhi/2JT2/wr+GBpTal/tDshKjlggOq+NgVgAbagvfIFqhUMxWHbYU/PiA FaKKB0kPd+AQBhmr7KmppSqpSQrORuCK2OAIVziNjv810A3aQtPkeji68Olauq4rNf0= X-Google-Smtp-Source: AGHT+IGbYRXiHg2cC2FvL0Fp1wg9GY7Ik7Wt6EPl8fRvSqQlrG7Fy7Ym1PrziuuAovlFSL+ASrbjmA== X-Received: by 2002:a05:6512:3089:b0:553:5d00:be86 with SMTP id 2adb3069b0e04-55366c35998mr4634136e87.41.1749542822732; Tue, 10 Jun 2025 01:07:02 -0700 (PDT) Received: from localhost ([185.229.155.48]) by smtp.gmail.com with UTF8SMTPSA id 2adb3069b0e04-553676d0183sm1457479e87.49.2025.06.10.01.07.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Jun 2025 01:07:02 -0700 (PDT) From: "Paul D. Nelson" To: bug-gnu-emacs@gnu.org Subject: [PATCH] Improve repeat-continue property handling X-Debbugs-CC: Juri Linkov , Karthik Chikmagalur Date: Tue, 10 Jun 2025 10:07:01 +0200 Message-ID: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=2a00:1450:4864:20::134; envelope-from=ultrono@gmail.com; helo=mail-lf1-x134.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, 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-Spam-Score: 1.0 (+) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) --=-=-= Content-Type: text/plain This patch adds support for a 'repeat-continue' property value of t to continue any active repeat map, following a suggestion by Karthik Chikmagalur on emacs-devel. Any feedback welcome. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Improve-repeat-continue-property-handling.patch >From 492a34a173cd2404cddf8ac97c98a1f968496d98 Mon Sep 17 00:00:00 2001 From: Paul Nelson Date: Tue, 10 Jun 2025 09:21:52 +0200 Subject: [PATCH] Improve repeat-continue property handling * lisp/repeat.el (repeat-get-map-sym): Support 'repeat-continue' property value of t to continue any active repeat map (suggested by Karthik Chikmagalur ). Simplify logic so that repeat-continue does not interfere with repeat-map activation. (repeat-check-map): Allow commands with 'repeat-continue' property value of t to continue without checking the key. (repeat-mode): Update and tweak docstring. * lisp/bind-key.el (bind-keys-form): Update handling of ':continue-only' keyword: only add keymap to 'repeat-continue' if current value is a list. (bind-keys): Update documentation, mirroring bind-keys-form. * lisp/keymap.el (defvar-keymap): Update handling of ':continue' keyword: only add keymap to 'repeat-continue' if current value is a list. * test/lisp/repeat-tests.el (repeat-tests-continue) (repeat-tests-continue-another): Enable previously commented tests that now work correctly. * etc/NEWS: Update announcement of 'repeat-continue'. --- etc/NEWS | 15 +++++++++------ lisp/bind-key.el | 15 ++++++++------- lisp/keymap.el | 6 ++++-- lisp/repeat.el | 29 +++++++++++++++++++---------- test/lisp/repeat-tests.el | 12 ++++++------ 5 files changed, 46 insertions(+), 31 deletions(-) diff --git a/etc/NEWS b/etc/NEWS index d5b62b9850a..83e050ebff4 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -2442,12 +2442,15 @@ will be calculated based on the window width. +++ ** New symbol property 'repeat-continue' for 'repeat-mode'. -A command with this symbol property whose value is a list of repeat -maps will not activate the repeat map in 'repeat-mode'. It will only -continue the already activated repeating sequence. Also 'defvar-keymap' -supports a new keyword ':continue' with a list of commands that only -continue the active repeating sequence, and the 'use-package' and -'bind-keys' macros support a similar keyword ':continue-only'. +A command with the 'repeat-continue' symbol property, which can be a +list of keymaps or t, will continue an already active repeating sequence +for a keymap in that list (resp. all keymaps). The new property does +not affect whether the command starts a repeating sequence, which +remains governed by the 'repeat-map' property. 'defvar-keymap' supports +a new keyword ':continue', a list of commands, and adds the keymap to +the 'repeat-continue' property of each command in that list. The +'use-package' and 'bind-keys' macros support a similar keyword +':continue-only'. ** New function 'completion-table-with-metadata'. It offers a more concise way to create a completion table with metadata. diff --git a/lisp/bind-key.el b/lisp/bind-key.el index 12417106783..49f5bd30351 100644 --- a/lisp/bind-key.el +++ b/lisp/bind-key.el @@ -402,13 +402,11 @@ bind-keys-form ;; repeat-map is non-nil, map is always ;; non-nil (if (eq repeat-type :continue-only) - `((unless (memq ',repeat-map - (or (get ,fun 'repeat-continue) - '())) - (put ,fun 'repeat-continue - (append (or (get ,fun 'repeat-continue) - '()) - (list ',repeat-map)))) + `((let ((cur (get ,fun 'repeat-continue))) + (when (and (listp cur) + (not (memq ',repeat-map cur))) + (put ,fun 'repeat-continue + (append cur (list ',repeat-map))))) (bind-key ,(car form) ,fun ,map ,filter)) `(,@(when (and repeat-map (not (eq repeat-type :exit))) `((put ,fun 'repeat-map ',repeat-map))) @@ -446,6 +444,9 @@ bind-keys same behavior as if no special keyword had been used (that is, the command is bound, and it's `repeat-map' property set) +:continue-only BINDINGS - Within the scope of `:repeat-map', will make + the command continue but not enter the repeat + map, via the `repeat-continue' property :filter FORM - optional form to determine when bindings apply The rest of the arguments are conses of keybinding string and a diff --git a/lisp/keymap.el b/lisp/keymap.el index a12084a3ad4..cf4c8d90bb1 100644 --- a/lisp/keymap.el +++ b/lisp/keymap.el @@ -754,8 +754,10 @@ defvar-keymap (dolist (def (plist-get repeat :enter)) (push `(put ',def 'repeat-map ',variable-name) props)) (dolist (def (plist-get repeat :continue)) - (push `(put ',def 'repeat-continue - (cons ',variable-name (get ',def 'repeat-continue))) + (push `(let ((val (get ',def 'repeat-continue))) + (when (listp val) + (put ',def 'repeat-continue + (cons ',variable-name val)))) props)) (while defs (pop defs) diff --git a/lisp/repeat.el b/lisp/repeat.el index daa53fe7195..9308f972a91 100644 --- a/lisp/repeat.el +++ b/lisp/repeat.el @@ -427,9 +427,18 @@ repeat-mode When Repeat mode is enabled, certain commands bound to multi-key sequences can be repeated by typing a single key, after typing the full key sequence once. -The commands which can be repeated like that are those whose symbol - has the property `repeat-map' which specifies a keymap of single -keys for repeating. + +The commands that can be repeated in this way are those whose symbols +have the `repeat-map' property, which specifies a keymap of single keys +for repeating. + +Normally, invoking a command outside that keymap terminates the +repeating sequence. However, if the command's `repeat-continue' +property is non-nil, it may instead continue the current repeating +sequence: if the property is a list of keymaps, then the command +continues when the current repeat map is in the list; if the property is +t, the command always continues the sequence. + See `describe-repeat-maps' for a list of all repeatable commands." :global t :group 'repeat (if (not repeat-mode) @@ -460,12 +469,11 @@ repeat-get-map-sym (when repeat-mode (let ((map-sym (or repeat-map (repeat--command-property 'repeat-map))) (continue (repeat--command-property 'repeat-continue))) - (when continue - (if repeat-in-progress - (when (and (consp continue) - (memq repeat-in-progress continue)) - (setq map-sym repeat-in-progress)) - (setq map-sym nil))) + (when (and repeat-in-progress + (or (eq continue t) + (and (consp continue) + (memq repeat-in-progress continue)))) + (setq map-sym repeat-in-progress)) map-sym))) (defun repeat-get-map (map) @@ -495,7 +503,8 @@ repeat-check-map ;; in the middle of repeating sequence (bug#47566). (or (< (minibuffer-depth) (car repeat--prev-mb)) (eq current-minibuffer-command (cdr repeat--prev-mb))) - (repeat-check-key last-command-event map) + (or (eq (repeat--command-property 'repeat-continue) t) + (repeat-check-key last-command-event map)) t)) (defun repeat-pre-hook () diff --git a/test/lisp/repeat-tests.el b/test/lisp/repeat-tests.el index f96d8df2ebd..6bf9badf31d 100644 --- a/test/lisp/repeat-tests.el +++ b/test/lisp/repeat-tests.el @@ -224,9 +224,9 @@ repeat-tests-continue "C-M-e c z" '((1 e)) "cz") ;; 'C-M-o' should also activate - ;; (repeat-tests--check - ;; "C-M-o c z" - ;; '((1 o) (1 c)) "z") + (repeat-tests--check + "C-M-o c z" + '((1 o) (1 c)) "z") ))) (ert-deftest repeat-tests-continue-another () @@ -246,9 +246,9 @@ repeat-tests-continue-another "C-M-e t z" '((1 e)) "tz") ;; 'C-M-u' should also activate - ;; (repeat-tests--check - ;; "C-M-u t z" - ;; '((1 u) (1 t)) "z") + (repeat-tests--check + "C-M-u t z" + '((1 u) (1 t)) "z") ;; 'C-M-o' shared with another map should continue current map (repeat-tests--check "C-M-s t C-M-o C-M-o t z" -- 2.39.3 (Apple Git-145) --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Wed Jun 11 02:45:54 2025 Received: (at 78742) by debbugs.gnu.org; 11 Jun 2025 06:45:54 +0000 Received: from localhost ([127.0.0.1]:45743 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uPFDe-0007on-1S for submit@debbugs.gnu.org; Wed, 11 Jun 2025 02:45:54 -0400 Received: from relay9-d.mail.gandi.net ([2001:4b98:dc4:8::229]:51813) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1uPFDb-0007ny-5Y; Wed, 11 Jun 2025 02:45:52 -0400 Received: by mail.gandi.net (Postfix) with ESMTPSA id A56FA4396B; Wed, 11 Jun 2025 06:45:42 +0000 (UTC) From: Juri Linkov To: "Paul D. Nelson" Subject: Re: bug#78742: [PATCH] Improve repeat-continue property handling In-Reply-To: Organization: LINKOV.NET References: Date: Wed, 11 Jun 2025 09:44:28 +0300 Message-ID: <87qzzqpz7f.fsf@mail.linkov.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/31.0.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain X-GND-State: clean X-GND-Score: -100 X-GND-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtddugdduudekfecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfitefpfffkpdcuggftfghnshhusghstghrihgsvgenuceurghilhhouhhtmecufedtudenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephffvvefujghofhffkfgfgggtsehttdertddtredtnecuhfhrohhmpefluhhrihcunfhinhhkohhvuceojhhurhhisehlihhnkhhovhdrnhgvtheqnecuggftrfgrthhtvghrnhepffegteefveelhfeljeefueehieduiedtfffhuddtkeeffffghfevheetgeeukeehnecukfhppeeluddruddvledruddtfedrvdejnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehinhgvthepledurdduvdelrddutdefrddvjedphhgvlhhopehmrghilhdrghgrnhguihdrnhgvthdpmhgrihhlfhhrohhmpehjuhhriheslhhinhhkohhvrdhnvghtpdhnsggprhgtphhtthhopeegpdhrtghpthhtoheptghonhhtrhholhesuggvsggsuhhgshdrghhnuhdrohhrghdprhgtphhtthhopehkrghrthhhihhktghhihhkmhgrghgrlhhurhesghhmrghilhdrtghomhdprhgtphhtthhopeejkeejgedvseguvggssghughhsrdhgnhhurdhorhhgpdhrtghpthhtohepuhhlthhrohhnohesghhmrghilhdrtghomh X-GND-Sasl: juri@linkov.net X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 78742 Cc: 78742@debbugs.gnu.org, Karthik Chikmagalur X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) close 78742 31.0.50 thanks > This patch adds support for a 'repeat-continue' property value of t to > continue any active repeat map, following a suggestion by Karthik > Chikmagalur on emacs-devel. Any feedback welcome. Thanks, now pushed. Also added tests for (put 'repeat-tests-call-g 'repeat-continue t)