emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Suggestion for improving ergonomics of repeat-maps: define-repeat-ma


From: acdw
Subject: Re: Suggestion for improving ergonomics of repeat-maps: define-repeat-map
Date: Wed, 08 Sep 2021 17:01:31 +0000
User-agent: Cyrus-JMAP/3.5.0-alpha0-1229-g7ca81dfce5-fm-20210908.005-g7ca81dfc

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 via email to

[Prev in Thread] Current Thread [Next in Thread]