From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.devel Subject: Repeat lambda (was: Some minor suggestions to Tab Bar) Date: Tue, 23 Mar 2021 20:30:47 +0200 Organization: LINKOV.NET Message-ID: <87blb969vc.fsf_-_@mail.linkov.net> References: <87o8fhekvx.fsf@mail.linkov.net> <385DDC1B-F508-4165-87FD-FFE2461348A6@kuaishou.com> <87ft0nyrfb.fsf@mail.linkov.net> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="35495"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (x86_64-pc-linux-gnu) Cc: emacs-devel To: Zhiwei Chen Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Tue Mar 23 20:14:20 2021 Return-path: Envelope-to: ged-emacs-devel@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 1lOmTs-00098C-Ac for ged-emacs-devel@m.gmane-mx.org; Tue, 23 Mar 2021 20:14:20 +0100 Original-Received: from localhost ([::1]:45750 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lOmTr-0006pI-6t for ged-emacs-devel@m.gmane-mx.org; Tue, 23 Mar 2021 15:14:19 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:36962) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lOm1H-0000DL-IJ for emacs-devel@gnu.org; Tue, 23 Mar 2021 14:44:50 -0400 Original-Received: from relay7-d.mail.gandi.net ([217.70.183.200]:46847) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lOm0p-0003p8-6H for emacs-devel@gnu.org; Tue, 23 Mar 2021 14:44:44 -0400 X-Originating-IP: 91.129.107.223 Original-Received: from mail.gandi.net (m91-129-107-223.cust.tele2.ee [91.129.107.223]) (Authenticated sender: juri@linkov.net) by relay7-d.mail.gandi.net (Postfix) with ESMTPSA id 363CA20003; Tue, 23 Mar 2021 18:44:13 +0000 (UTC) In-Reply-To: (Zhiwei Chen's message of "Tue, 23 Mar 2021 12:17:56 +0000") Received-SPF: pass client-ip=217.70.183.200; envelope-from=juri@linkov.net; helo=relay7-d.mail.gandi.net X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 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-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:266887 Archived-At: >> (defvar tab-bar-move-repeat-map >> (let ((map (make-sparse-keymap))) >> (define-key map "m" 'tab-move) >> (define-key map "M" (lambda () >> (interactive) >> (tab-move -1))) >> map) >> "Keymap to repeat tab move key sequences `C-x t m m'. >> Used in `repeat-mode'.") >> (put 'tab-move 'repeat-map 'tab-bar-move-repeat-map) > > One nitpicking is that `C-x t m M m’ is not allowed > since `(tab-move -1)` hasn’t a `repeat-map’ property. > Maybe name it tab-move-prev and set the property? This can't be a general solution since there are other keymaps where repeating lambda is required. For example, other-window-repeat-map currently has no keybinding that could switch to navigating windows in the opposite direction. There were proposals to bind it to "O", but since there is no such command as "previous-window" to cycle windows backwards, using a lambda is required, but currently this doesn't work: (define-key other-window-repeat-map "O" (lambda () (interactive) (other-window -1))) Stefan already asked about this, but I had no idea how it could be improved. Now I tried to set the KEEP-PRED arg of set-transient-map to t, and it seems both lambdas above can be used with this change: diff --git a/lisp/repeat.el b/lisp/repeat.el index 84a613da0c..4be4f766ef 100644 --- a/lisp/repeat.el +++ b/lisp/repeat.el @@ -398,7 +398,7 @@ repeat-post-hook (when repeat-exit-key (define-key map repeat-exit-key 'ignore)) - (set-transient-map map))))))) + (set-transient-map map t)))))))