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: Re: Suggestion for improving ergonomics of repeat-maps: define-repeat-map Date: Thu, 09 Sep 2021 20:50:52 +0300 Organization: LINKOV.NET Message-ID: <874katproz.fsf@mail.linkov.net> References: Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="31284"; 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@gnu.org To: acdw Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Thu Sep 09 20:00:03 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 1mOOLC-0007yD-Ig for ged-emacs-devel@m.gmane-mx.org; Thu, 09 Sep 2021 20:00:02 +0200 Original-Received: from localhost ([::1]:51272 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mOOLA-0004XN-PS for ged-emacs-devel@m.gmane-mx.org; Thu, 09 Sep 2021 14:00:00 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:45350) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mOOJl-00036G-L2 for emacs-devel@gnu.org; Thu, 09 Sep 2021 13:58:33 -0400 Original-Received: from relay1-d.mail.gandi.net ([217.70.183.193]:59333) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mOOJk-0005h4-1v for emacs-devel@gnu.org; Thu, 09 Sep 2021 13:58:33 -0400 Original-Received: (Authenticated sender: juri@linkov.net) by relay1-d.mail.gandi.net (Postfix) with ESMTPSA id 09BA3240007; Thu, 9 Sep 2021 17:58:28 +0000 (UTC) In-Reply-To: (acdw@acdw.net's message of "Wed, 08 Sep 2021 03:22:15 +0000") Received-SPF: pass client-ip=217.70.183.193; envelope-from=juri@linkov.net; helo=relay1-d.mail.gandi.net X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, 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:274462 Archived-At: > I've written a package[1] for my own ease of use in defining > repeat-maps for Emacs 28, and a few people have told me I should see > about adding it to Emacs proper. So here we are. Thanks, this would be a nice addition. > (defvar case-repeat-map > (let ((map (make-sparse-keymap))) > (define-key map "c" #'capitalize-word) > (define-key map "u" #'upcase-word) > (define-key map "l" #'downcase-word) > ;; movement > (define-key map "f" #'forward-word-with-case) > (define-key map "b" #'backward-word-with-case) > map) > "A map to repeat word-casing commands. For use with `repeat-mode'.") The reason why currently in Emacs core repeat-maps are defined this way is because this is a standard way to define a keymap. If normal keymaps were defined with a macro similar to the macro that you created, it would be easier to migrate the existing repeat-maps to your macro. I mean if we had a macro `define-keymap' that defines normal keymaps and that is similar to your `define-repeat-map', then creating a repeat-map from the normal map would require just changing the macro name `define-keymap' to `define-repeat-map'. > I wrote the macro `define-repeat-map' to alleviate this large amount > of configuration. Using this macro, the above turns into this: > > ~~~ > (define-repeat-map case > ("c" capitalize-word > "u" upcase-word > "l" downcase-word) > (:continue "f" forward-word > "b" backward-word) > (:enter downcase-dwim > upcase-dwim > capitalize-dwim)) I'd like to hear more opinions whether the above macro is a better way to define repeat-maps in Emacs core. I'm sure this macro is nice to use in a personal customization init file, but the question is about using it in Emacs core. If this will be preferable for Emacs core, then it could be included in repeat.el. Otherwise, GNU ELPA is a better place. Then for Emacs core I'd suggest at least to add another macro 'define-repeat-key' that will remove the need of adding manually `(put command 'repeat-map 'case-repeat-map)`, e.g.: (defvar case-repeat-map (let ((map (make-sparse-keymap))) (define-repeat-key map "c" #'capitalize-word) (define-repeat-key map "u" #'upcase-word) (define-repeat-key map "l" #'downcase-word) ;; movement (define-repeat-key map "f" #'forward-word-with-case) (define-repeat-key map "b" #'backward-word-with-case) map) Then it will preserve the same style already used in core.