all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* On definition of `kbd'
@ 2006-10-11 11:09 Herbert Euler
  2006-10-11 11:16 ` David Kastrup
  0 siblings, 1 reply; 5+ messages in thread
From: Herbert Euler @ 2006-10-11 11:09 UTC (permalink / raw)


I find definition of `kbd' is:

   (defmacro kbd (keys)
     "Convert KEYS to the internal Emacs key representation.
   KEYS should be a string constant in the format used for
   saving keyboard macros (see `edmacro-mode')."
     (read-kbd-macro keys))

This would cause problem when evaluating

  (kbd (car list))

where the `car' of a list is a key sequence text.  Is the
definition correct?  I think the body should be

  `(read-kbd-macro ,keys)

Regards,
Guanpeng Xu

_________________________________________________________________
Express yourself instantly with MSN Messenger! Download today it's FREE! 
http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: On definition of `kbd'
  2006-10-11 11:09 On definition of `kbd' Herbert Euler
@ 2006-10-11 11:16 ` David Kastrup
  2006-10-11 13:55   ` Herbert Euler
  2006-10-11 14:24   ` Stuart D. Herring
  0 siblings, 2 replies; 5+ messages in thread
From: David Kastrup @ 2006-10-11 11:16 UTC (permalink / raw)
  Cc: emacs-devel

"Herbert Euler" <herberteuler@hotmail.com> writes:

> I find definition of `kbd' is:
>
>   (defmacro kbd (keys)
>     "Convert KEYS to the internal Emacs key representation.
>   KEYS should be a string constant in the format used for
>   saving keyboard macros (see `edmacro-mode')."
>     (read-kbd-macro keys))
>
> This would cause problem when evaluating
>
>  (kbd (car list))
>
> where the `car' of a list is a key sequence text.

In this case, KEYS is the list `(car list)' and not a string constant.

> Is the definition correct?  I think the body should be
>
>  `(read-kbd-macro ,keys)

That would completely defeat the purpose of having a macro, namely
being able to do compile-time evaluation.

-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: On definition of `kbd'
  2006-10-11 11:16 ` David Kastrup
@ 2006-10-11 13:55   ` Herbert Euler
  2006-10-11 14:03     ` David Kastrup
  2006-10-11 14:24   ` Stuart D. Herring
  1 sibling, 1 reply; 5+ messages in thread
From: Herbert Euler @ 2006-10-11 13:55 UTC (permalink / raw)
  Cc: help-gnu-emacs

Have changed to "help-gnu-emacs".  So, is this usage
of macro only suitable for cases the actual arguments
are constants?  I.e.

(let ((x "x")) (kbd x))

will not pass compilation?

Thanks.

Regards,
Guanpeng Xu


>From: David Kastrup <dak@gnu.org>
>To: "Herbert Euler" <herberteuler@hotmail.com>
>CC: emacs-devel@gnu.org
>Subject: Re: On definition of `kbd'
>Date: Wed, 11 Oct 2006 13:16:15 +0200
>
>"Herbert Euler" <herberteuler@hotmail.com> writes:
>
> > I find definition of `kbd' is:
> >
> >   (defmacro kbd (keys)
> >     "Convert KEYS to the internal Emacs key representation.
> >   KEYS should be a string constant in the format used for
> >   saving keyboard macros (see `edmacro-mode')."
> >     (read-kbd-macro keys))
> >
> > This would cause problem when evaluating
> >
> >  (kbd (car list))
> >
> > where the `car' of a list is a key sequence text.
>
>In this case, KEYS is the list `(car list)' and not a string constant.
>
> > Is the definition correct?  I think the body should be
> >
> >  `(read-kbd-macro ,keys)
>
>That would completely defeat the purpose of having a macro, namely
>being able to do compile-time evaluation.
>
>--
>David Kastrup, Kriemhildstr. 15, 44793 Bochum
>
>
>_______________________________________________
>Emacs-devel mailing list
>Emacs-devel@gnu.org
>http://lists.gnu.org/mailman/listinfo/emacs-devel

_________________________________________________________________
Don't just search. Find. Check out the new MSN Search! 
http://search.msn.click-url.com/go/onm00200636ave/direct/01/

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: On definition of `kbd'
  2006-10-11 13:55   ` Herbert Euler
@ 2006-10-11 14:03     ` David Kastrup
  0 siblings, 0 replies; 5+ messages in thread
From: David Kastrup @ 2006-10-11 14:03 UTC (permalink / raw)
  Cc: help-gnu-emacs

"Herbert Euler" <herberteuler@hotmail.com> writes:

> Have changed to "help-gnu-emacs".  So, is this usage
> of macro only suitable for cases the actual arguments
> are constants?

Is there anything unclear about the DOC string?  It _says_ `string
constant' explicitly.

> I.e.
>
> (let ((x "x")) (kbd x))
>
> will not pass compilation?

You could try asking Emacs itself instead of the list.  It will answer
more reliably, faster, with less effort, and authoritatively.

-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: On definition of `kbd'
  2006-10-11 11:16 ` David Kastrup
  2006-10-11 13:55   ` Herbert Euler
@ 2006-10-11 14:24   ` Stuart D. Herring
  1 sibling, 0 replies; 5+ messages in thread
From: Stuart D. Herring @ 2006-10-11 14:24 UTC (permalink / raw)
  Cc: Herbert Euler, emacs-devel

>> Is the definition correct?  I think the body should be
>>
>>  `(read-kbd-macro ,keys)
>
> That would completely defeat the purpose of having a macro, namely
> being able to do compile-time evaluation.

To elaborate on David's response: if you really want to get a key sequence
representation of a dynamic string, just use the `read-kbd-macro' function
that the `kbd' macro calls.  `kbd' is for when you just want to do
something simple and direct (read: hardcoded) in Lisp: (kbd "C-x C-c"). 
The result is human-readable but during byte-compilation actually becomes
"^X^C" (two characters), so there's no performance penalty.

Hope this helps,
Davis

-- 
This product is sold by volume, not by mass.  If it appears too dense or
too sparse, it is because mass-energy conversion has occurred during
shipping.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2006-10-11 14:24 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-10-11 11:09 On definition of `kbd' Herbert Euler
2006-10-11 11:16 ` David Kastrup
2006-10-11 13:55   ` Herbert Euler
2006-10-11 14:03     ` David Kastrup
2006-10-11 14:24   ` Stuart D. Herring

Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.