From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: acdw Newsgroups: gmane.emacs.devel Subject: Suggestion for improving ergonomics of repeat-maps: define-repeat-map Date: Wed, 08 Sep 2021 03:22:15 +0000 Message-ID: Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="5722"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Cyrus-JMAP/3.5.0-alpha0-1215-g0d2d495392-fm-20210907.001-g0d2d4953 To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Wed Sep 08 07:44:28 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 1mNqNm-0001Iy-Jz for ged-emacs-devel@m.gmane-mx.org; Wed, 08 Sep 2021 07:44:27 +0200 Original-Received: from localhost ([::1]:39450 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mNqNl-0003nF-6f for ged-emacs-devel@m.gmane-mx.org; Wed, 08 Sep 2021 01:44:25 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:52168) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mNoAs-0000Up-91 for emacs-devel@gnu.org; Tue, 07 Sep 2021 23:23:01 -0400 Original-Received: from wout5-smtp.messagingengine.com ([64.147.123.21]:54081) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mNoAo-00014H-1Q for emacs-devel@gnu.org; Tue, 07 Sep 2021 23:22:57 -0400 Original-Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id 326D23200977 for ; Tue, 7 Sep 2021 23:22:51 -0400 (EDT) Original-Received: from imap1 ([10.202.2.51]) by compute4.internal (MEProxy); Tue, 07 Sep 2021 23:22:51 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=acdw.net; h= mime-version:message-id:date:from:to:subject:content-type; s= fm3; bh=KJe5nyS1bpzJ4fSVCxNQqjUGF7tore5L5mgcL/2oZ7Q=; b=NXhgebGY IHME6oPJrrR137SwAtb9n9seW9+uYjLbEfw+5sPtrsMq3maYAMNOSvVHTkU8pXir e/+4PQtJXagZAcx3Vfaj5DUm4kCsmfxb976J+pFOIqQ6fk2debuuk9k5sV0OHF5W 7aXkUtSlHCs/tBBJBIgXL4BHq6xyP9SDX37rrAItv4HzmOrKxlQvq1WiIFS0Ki3G qTeGQSV/Av+HElzEiC1NRW9AERYzgL5XYKSaMwFsiHPRPk9gmlCs8xTKpliQ3idp 0YRi0L69V25eqFANjYVM6KByBPZmAxQbsPKC3jnvKqQqf4i+gCnp3Db03CZwvZga xPtwLzOR5gJ+Bw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-type:date:from:message-id :mime-version:subject:to:x-me-proxy:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm3; bh=KJe5nyS1bpzJ4fSVCxNQqjUGF7tor e5L5mgcL/2oZ7Q=; b=n+b10ni6B4UXsFAP/CnIsUUTRsSRUPo4Eg8Q7pxSPmwMH RvcsK7S6BKXAa1AVKQ6/ye0/QyZ2a9WUP/Ud4drO1DEyvGolwK+uCookN/og08Wz ga3I0MRYs+7Io2U3+xH0hdQMxjgMYdFikNPlq5fXhvINfIjO7P1ie1BFSf1A0Q4D 0ky36IRs15XajCRbaEFs6CN5ByCdYWh9X5ppieA7klv4a11DUXxnfxwBjZtK5qqY EkghpjcpVdT+nOF4H0Kz+ec/IKp+Vxl1jLg6C0X6Db2fORFRAinI4n07loxsq0OT YXhBfSz2IuyZDVyN0Z5tC9t3/VxyMIwW6DZOfvoGg== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrudefiedgieejucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefofgggkfffhffvufgtsehttdertd erredtnecuhfhrohhmpegrtgguficuoegrtggufiesrggtugifrdhnvghtqeenucggtffr rghtthgvrhhnpeetueduieehleffgeeiheefvdehhfeiledvfeevffffhffgtdegjeevhf dvkeejffenucffohhmrghinhepthhilhguvghgihhtrdhorhhgpdgrtggufidrnhgvthdp sghrvggrughpuhhnkhdrtghluhgsnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrg hmpehmrghilhhfrhhomheprggtugifsegrtggufidrnhgvth X-ME-Proxy: Original-Received: by mailuser.nyi.internal (Postfix, from userid 501) id 5EA211301160; Tue, 7 Sep 2021 23:22:50 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface Received-SPF: permerror client-ip=64.147.123.21; envelope-from=acdw@acdw.net; helo=wout5-smtp.messagingengine.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.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, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, T_SPF_PERMERROR=0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Wed, 08 Sep 2021 01:41:39 -0400 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:274311 Archived-At: Hi Emacs maintainers! 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. The elevator pitch: The new functionality defined in repeat.el in Emacs 28 is very useful, but usually requires a large amount of configuration, to wit: ~~~ (defalias 'forward-word-with-case 'forward-word "Alias for `forward-word' for use in `case-repeat-map'.") (defalias 'backward-word-with-case 'backward-word "Alias for `backward-word for use in `case-repeat-map'.") (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'.") (dolist (command '(capitalize-word capitalize-dwim upcase-word upcase-dwim downcase-word downcase-dwim forward-word-with-case backward-word-with-case)) (put command 'repeat-map 'case-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)) ~~~ As you can see, `define-repeat-map' makes it easier to not only define repeating keys for commands, but to define commands that can enter the keymap, keys that are in the keymap and can continue the binds, but not enter the map, and commands that will exit the map when they're pressed. I was inspired by the repeaters[2] package on GitHub, but wrote my own because I wanted better (to me) ergonomics. Please let me know what you think about this macro and package. I've written some elisp for my own enjoyment but never submitted a package to Emacs, or looked into including it in core. I'm open to any and all suggestions, including simply adding this package to GNU ELPA. Thanks for all you do! [1]: https://tildegit.org/acdw/define-repeat-map.el/ -- ~ acdw (Case Duckworth) https://www.acdw.net | https://breadpunk.club/~breadw