[Top][All Lists]

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

Re: Is `kbd' idempotent?

From: Random832
Subject: Re: Is `kbd' idempotent?
Date: Tue, 1 Dec 2015 15:37:13 +0000 (UTC)
User-agent: slrn/pre1.0.3-7 (Linux)

On 2015-12-01, Michael Heerdegen <address@hidden> wrote:
> I'm deliberating if I'm doing the user a favor if I pass any `stringp'
> input implicitly to `kbd', because the keyboard macro format seems to be
> quite popular.  That would spare him to wrap his input into `kbd' by
> himself.  But if the result of `kbd' can change the "semantics" of a
> string describing a key sequence - as your counterexamples demonstrate -
> I can't do that.

What about calling kbd only if the 'read' result is a string? That way
if they really want to pass a self-made string, they can do e.g.
(identity "foo"), whereas "foo" alone will be treated as (kbd "foo")

I do wonder what the use case is, though, that benefits from allowing
the entry of an arbitrary lisp expression instead of just directly
passing the user input to kbd without even a read/eval stage. Are there
key sequences that can't be represented in kbd format that the user will
want to enter as vector literals?

How about a heuristic? If the first character of input is ", it is read
and passed to kbd. If it is [, it is read. If it is (, it read and
eval'd. Otherwise, it is passed directly to kbd. That'd save them from
having to type a string literal in the (I assume most common) case they
simply want to pass a printable string to kbd.

reply via email to

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