unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: acdw <acdw@acdw.net>
To: "Philip Kaludercic" <philipk@posteo.net>
Cc: emacs-devel@gnu.org
Subject: Re: Suggestion for improving ergonomics of repeat-maps: define-repeat-map
Date: Wed, 08 Sep 2021 17:01:31 +0000	[thread overview]
Message-ID: <444baed6-8fac-4dd3-a61e-3e6a89a1f7aa@www.fastmail.com> (raw)
In-Reply-To: <87bl53f78g.fsf@posteo.net>

On 2021-09-08 (Wednesday) at 14:54, Philip Kaludercic <philipk@posteo.net> wrote:
>
> I haven't taken a detailed look at the source, but I have two
> superficial questions:
> 
> 1. Why is the name argument required? Shouldn't the macro be able to
>    gensym a new symbol to use for the map?
> 2. Could the argument structure be flattened, so that you could write
>    something like
> 
>         (define-repeat-map
>           "c" capitalize-word
>           "u" upcase-word
>           "l" downcase-word
>           :continue
>           "f" forward-word
>           "b" backward-word
>           :enter
>           downcase-dwim
>           upcase-dwim
>           capitalize-dwim)
> 
>    ?
> 
> -- 
> 	Philip Kaludercic
> 

To answer your questions:

1. I wanted the resulting keymap to be introspectable; the macro creates a keymap named "NAME-repeat-map," 
   i.e., "case-repeat-map," that can be C-h v'd and friends.  (Now that I'm thinking about it, perhaps I
   should change the map's documentation property after the fact, to include the keys in the map.)
2. There's no particular reason it couldn't be flattened; I just like sexp's structure a bit better.

In fact (regarding 2), there is also this syntax, which I've been thinking of as well:

~~~
(define-repeat-map map
  (("c" . #'capitalize-word)
   ("u" . #'upcase-word)
   ("l" . #'downcase-word))
  (:continue
   ("f" . #'forward-word)
   ("b" . #'backward-word))
  (:enter '(downcase-dwim upcase-dwim capitalize-dwim)))
~~~

Your proposed syntax could also work just fine with a slight refactor, which I should do anyway; another consideration is whether the `:enter' commands should also define the keys in the current-global-map, or possibly a customizable map.

The other question is, does this need to be a macro, or is a function enough?

-- 
~ acdw
acdw.net | breadpunk.club/~breadw



  reply	other threads:[~2021-09-08 17:01 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-08  3:22 Suggestion for improving ergonomics of repeat-maps: define-repeat-map acdw
2021-09-08 14:54 ` Philip Kaludercic
2021-09-08 17:01   ` acdw [this message]
2021-09-09 17:50 ` Juri Linkov
2021-09-09 18:06   ` Lars Ingebrigtsen
2021-09-09 20:35     ` Augusto Stoffel
2021-09-09 20:39       ` Lars Ingebrigtsen
2021-09-10  0:53     ` acdw
2021-09-10 10:53       ` Lars Ingebrigtsen
2021-10-04  8:22       ` Lars Ingebrigtsen
2021-10-04  9:05         ` Adam Porter
2021-10-04  9:49           ` Lars Ingebrigtsen
2021-10-04 11:29             ` Adam Porter
2021-10-04 11:33               ` Lars Ingebrigtsen
2021-10-04 18:18             ` Juri Linkov
2021-10-04 19:02               ` Lars Ingebrigtsen
2021-10-04 19:24                 ` Stefan Monnier
2021-10-04 19:54                   ` Lars Ingebrigtsen
2021-10-04 20:16                   ` Lars Ingebrigtsen
2021-09-10  0:53   ` acdw

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=444baed6-8fac-4dd3-a61e-3e6a89a1f7aa@www.fastmail.com \
    --to=acdw@acdw.net \
    --cc=emacs-devel@gnu.org \
    --cc=philipk@posteo.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).