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: =?UTF-8?Q?Re:_Suggestion_for_improving_ergonomics_of_repeat-maps:_define?= =?UTF-8?Q?-repeat-map?= Date: Fri, 10 Sep 2021 00:53:10 +0000 Message-ID: References: <874katproz.fsf@mail.linkov.net> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="17750"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Cyrus-JMAP/3.5.0-alpha0-1229-g7ca81dfce5-fm-20210908.005-g7ca81dfc Cc: emacs-devel@gnu.org To: "Juri Linkov" Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Fri Sep 10 03:03:59 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 1mOUxS-0004SD-8G for ged-emacs-devel@m.gmane-mx.org; Fri, 10 Sep 2021 03:03:59 +0200 Original-Received: from localhost ([::1]:39036 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mOUxP-0001kE-Ua for ged-emacs-devel@m.gmane-mx.org; Thu, 09 Sep 2021 21:03:55 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:59594) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mOUnS-0006Mp-2I for emacs-devel@gnu.org; Thu, 09 Sep 2021 20:53:38 -0400 Original-Received: from wout4-smtp.messagingengine.com ([64.147.123.20]:44459) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mOUnP-00006p-Na for emacs-devel@gnu.org; Thu, 09 Sep 2021 20:53:37 -0400 Original-Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id 6507D3200977; Thu, 9 Sep 2021 20:53:32 -0400 (EDT) Original-Received: from imap1 ([10.202.2.51]) by compute4.internal (MEProxy); Thu, 09 Sep 2021 20:53:32 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=acdw.net; h= mime-version:message-id:in-reply-to:references:date:from:to:cc :subject:content-type; s=fm3; bh=LFLQ0rbNJtOWzsXspuJ0PzVTH1Q0+EY f/gAAIgeUXJQ=; b=YkwZhWZ7s2diJFEDq27eXCc/Adf2wiHFhn6GvU00CY+i0td q9qhM0r4OKvK673DbpTXsO6Iob8ebvjci8UcFx3TK7Upolb6rYumjHhHpAM37/EC bfTfl6u6gE9AJHAntYxmsb2sED6faiu5nyZ5DjKd5e7xt7VmNwRFlkITjhTKdNgr fWgkktWUrDZhsldFD1d6Ca7u/UAajL53nLAHlhEe2i4RsebKTyW8IrOG1JV5iGT/ /rvOc6ZxRsPJP/awB7Xl43aQW14k+nOvHJB0JyDxE+qYcDkGmEelQD85bjZ7KsmH knd82qcmCQmvSkDhiLbj7olcT8gfzquui08tqjA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; bh=LFLQ0r bNJtOWzsXspuJ0PzVTH1Q0+EYf/gAAIgeUXJQ=; b=lzUgr/QersOh3guuHjBiQ3 Xbtu80jLcnqu/PtefUBdG1Z3gY8oZgHzaSKAChz0zzOnh5q58qwLa8/vjYU65oQd pJYggZ+AN3VmZPwfzS7MUUKUeV9jFLNhaZin9eIhEFBm46nciWMOd7J0pMhHYf4R aqvxIumVzOW6tYvkYvg08/bP8+U493GjTaXQPWa55xPE2Hqc6oM+dQtTuKn9tDJl nxtNhauhuBpA/o84CAwDn7nnl3+3mP/eC4jXMTGhS1evLM6PhJ3FbOLxlTTUntuK lHgseJmME3JZBzSeB1cLT/mtOcMhOvmmtitB69lJsccHPWNrjUuD3YLBrv/9kmOg == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrudegtddgfeekucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepofgfggfkjghffffhvffutgesthdtredtreerjeenucfhrhhomheprggtugif uceorggtugifsegrtggufidrnhgvtheqnecuggftrfgrthhtvghrnhepgfdtffdvgfdtle dvgfeuheejtdefjeefvdffffdvjeduhfeihfeuteejvdefkedvnecuffhomhgrihhnpegr tggufidrnhgvthdpsghrvggrughpuhhnkhdrtghluhgsnecuvehluhhsthgvrhfuihiivg eptdenucfrrghrrghmpehmrghilhhfrhhomheprggtugifsegrtggufidrnhgvth X-ME-Proxy: Original-Received: by mailuser.nyi.internal (Postfix, from userid 501) id 795951300089; Thu, 9 Sep 2021 20:53:31 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface In-Reply-To: <874katproz.fsf@mail.linkov.net> Received-SPF: permerror client-ip=64.147.123.20; envelope-from=acdw@acdw.net; helo=wout4-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: Thu, 09 Sep 2021 21:02:05 -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:274482 Archived-At: On 2021-09-09 (Thursday) at 17:50, Juri Linkov wrote: > > 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 think this is an absolutely wonderful idea, especially to have `define-keymap' be more like `setq' (in fact, I think even more functions could be defined this way, but I digress). I can work on a `define-keymap' this weekend, and incorporate `define-repeat-keymap' in it :D > > > 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. This is the biggest reason I'm asking about `define-repeat-map' here; It's definitely a user-configuration-ease type macro/function (honestly this probably should be a function, the more I think about it). It's not very "Emacs-y", from what I've seen of the "Emacs-y" way to do things. However, `define-repeat-key' /does/ have some functionality that's not included in even the code you've included: it automatically creates the necessary aliases for continuation commands, which you'd need to do separately to create `forward-word-with-case' and `backward-word-with-case', above. Though now that I'm thinking of it, I'd probably rewrite your example to include (define-repeat-key map "f" (defalias 'forward-word-with-case 'forward-word)) Though I don't think /that's/ very "Emacs-y", either. At the very least I'd be happy to add `define-repeat-map' or something like it to ELPA. -- ~ acdw acdw.net | breadpunk.club/~breadw