all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Problem binding to a key
@ 2007-04-20 14:54 Cecil Westerhof
  2007-04-20 15:54 ` weber
  2007-04-20 16:27 ` Eric Hanchrow
  0 siblings, 2 replies; 14+ messages in thread
From: Cecil Westerhof @ 2007-04-20 14:54 UTC (permalink / raw)
  To: help-gnu-emacs

I have the following two lines in my .emacs:
  (define-key global-map "\C-cw" 'clipboard-kill-ring-save)
  (define-key global-map "\C-x\C-kw" 'clipboard-kill-ring-save)

The first line is no problem, the second gives:
  error: "Key sequence C-x C-k w uses invalid prefix characters"

What I understood from 'Learning GNU Emacs' is the second way, the way you
should bind your own definitions. Why does it not work?

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

* Re: Problem binding to a key
  2007-04-20 14:54 Problem binding to a key Cecil Westerhof
@ 2007-04-20 15:54 ` weber
  2007-04-20 16:14   ` Rjjd
  2007-04-21  4:04   ` Tim X
  2007-04-20 16:27 ` Eric Hanchrow
  1 sibling, 2 replies; 14+ messages in thread
From: weber @ 2007-04-20 15:54 UTC (permalink / raw)
  To: help-gnu-emacs

On 20 abr, 11:54, Cecil Westerhof <d...@dummy.nl> wrote:
> I have the following two lines in my .emacs:
>   (define-key global-map "\C-cw" 'clipboard-kill-ring-save)
>   (define-key global-map "\C-x\C-kw" 'clipboard-kill-ring-save)
>
> The first line is no problem, the second gives:
>   error: "Key sequence C-x C-k w uses invalid prefix characters"
>
> What I understood from 'Learning GNU Emacs' is the second way, the way you
> should bind your own definitions. Why does it not work?

Because C-k already has another definition (killing text)
You have to "undefine" C-k with something like this:
(global-set-key "\C-k" nil)
Hope it helps,
weber

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

* Re: Problem binding to a key
  2007-04-20 15:54 ` weber
@ 2007-04-20 16:14   ` Rjjd
  2007-04-20 21:14     ` Cecil Westerhof
  2007-04-21  4:04   ` Tim X
  1 sibling, 1 reply; 14+ messages in thread
From: Rjjd @ 2007-04-20 16:14 UTC (permalink / raw)
  To: help-gnu-emacs

weber wrote:
> On 20 abr, 11:54, Cecil Westerhof <d...@dummy.nl> wrote:
>> I have the following two lines in my .emacs:
>>   (define-key global-map "\C-cw" 'clipboard-kill-ring-save)
>>   (define-key global-map "\C-x\C-kw" 'clipboard-kill-ring-save)
>>
>> The first line is no problem, the second gives:
>>   error: "Key sequence C-x C-k w uses invalid prefix characters"
>>
>> What I understood from 'Learning GNU Emacs' is the second way, the way you
>> should bind your own definitions. Why does it not work?
> 
> Because C-k already has another definition (killing text)
> You have to "undefine" C-k with something like this:
> (global-set-key "\C-k" nil)
> Hope it helps,
> weber

But doesn't Cecil need to unbind \C-x\C-k, and not merely \C-k?
C-x C-k runs the command edit-kbd-macro.

Regards,
Bob

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

* Re: Problem binding to a key
  2007-04-20 14:54 Problem binding to a key Cecil Westerhof
  2007-04-20 15:54 ` weber
@ 2007-04-20 16:27 ` Eric Hanchrow
  1 sibling, 0 replies; 14+ messages in thread
From: Eric Hanchrow @ 2007-04-20 16:27 UTC (permalink / raw)
  To: help-gnu-emacs

>>>>> "Cecil" == Cecil Westerhof <dummy@dummy.nl> writes:

    Cecil>  (define-key global-map "\C-x\C-kw" 'clipboard-kill-ring-save)

    Cecil> error: "Key sequence C-x C-k w uses invalid prefix
    Cecil> characters"

My hunch is that \C-x\C-k is itself a "complete key".  Read (info "(elisp)Keymap Basics")

-- 

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

* Re: Problem binding to a key
  2007-04-20 16:14   ` Rjjd
@ 2007-04-20 21:14     ` Cecil Westerhof
  2007-04-21  4:09       ` Tim X
  0 siblings, 1 reply; 14+ messages in thread
From: Cecil Westerhof @ 2007-04-20 21:14 UTC (permalink / raw)
  To: help-gnu-emacs

Rjjd wrote:

> weber wrote:
>> On 20 abr, 11:54, Cecil Westerhof <d...@dummy.nl> wrote:
>>> I have the following two lines in my .emacs:
>>>   (define-key global-map "\C-cw" 'clipboard-kill-ring-save)
>>>   (define-key global-map "\C-x\C-kw" 'clipboard-kill-ring-save)
>>>
>>> The first line is no problem, the second gives:
>>>   error: "Key sequence C-x C-k w uses invalid prefix characters"
>>>
>>> What I understood from 'Learning GNU Emacs' is the second way, the way
>>> you should bind your own definitions. Why does it not work?
>> 
>> Because C-k already has another definition (killing text)
>> You have to "undefine" C-k with something like this:
>> (global-set-key "\C-k" nil)
>> Hope it helps,
>> weber
> 
> But doesn't Cecil need to unbind \C-x\C-k, and not merely \C-k?
> C-x C-k runs the command edit-kbd-macro.

I got what I tried to do out of 'Learning GNU Emacs', pages 160 and 161. But
it does not work. For example for the keybinding they give:
  C-x C-k b
But then I get:
  Key sequence b is not a keyboard macro

That is a big oops for O'Reilly.

I tried to use the reserved keys, but that is not possible. What is a good
way to select keys for binding macro's to?

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

* Re: Problem binding to a key
  2007-04-20 15:54 ` weber
  2007-04-20 16:14   ` Rjjd
@ 2007-04-21  4:04   ` Tim X
  1 sibling, 0 replies; 14+ messages in thread
From: Tim X @ 2007-04-21  4:04 UTC (permalink / raw)
  To: help-gnu-emacs

weber <hugows@gmail.com> writes:

> On 20 abr, 11:54, Cecil Westerhof <d...@dummy.nl> wrote:
>> I have the following two lines in my .emacs:
>>   (define-key global-map "\C-cw" 'clipboard-kill-ring-save)
>>   (define-key global-map "\C-x\C-kw" 'clipboard-kill-ring-save)
>>
>> The first line is no problem, the second gives:
>>   error: "Key sequence C-x C-k w uses invalid prefix characters"
>>
>> What I understood from 'Learning GNU Emacs' is the second way, the way you
>> should bind your own definitions. Why does it not work?
>
> Because C-k already has another definition (killing text)
> You have to "undefine" C-k with something like this:
> (global-set-key "\C-k" nil)
> Hope it helps,
> weber
>
>
Correct diagnosis, wrong solution I think. The problem is that part of the key
definition is already used C-xC-k is already bound to a command. Note that its
not C-k as this is a different binding to C-xC-k. 

tim

-- 
tcross (at) rapttech dot com dot au

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

* Re: Problem binding to a key
  2007-04-20 21:14     ` Cecil Westerhof
@ 2007-04-21  4:09       ` Tim X
  2007-04-21  7:33         ` Cecil Westerhof
  0 siblings, 1 reply; 14+ messages in thread
From: Tim X @ 2007-04-21  4:09 UTC (permalink / raw)
  To: help-gnu-emacs

Cecil Westerhof <dummy@dummy.nl> writes:

> Rjjd wrote:
>
>> weber wrote:
>>> On 20 abr, 11:54, Cecil Westerhof <d...@dummy.nl> wrote:
>>>> I have the following two lines in my .emacs:
>>>>   (define-key global-map "\C-cw" 'clipboard-kill-ring-save)
>>>>   (define-key global-map "\C-x\C-kw" 'clipboard-kill-ring-save)
>>>>
>>>> The first line is no problem, the second gives:
>>>>   error: "Key sequence C-x C-k w uses invalid prefix characters"
>>>>
>>>> What I understood from 'Learning GNU Emacs' is the second way, the way
>>>> you should bind your own definitions. Why does it not work?
>>> 
>>> Because C-k already has another definition (killing text)
>>> You have to "undefine" C-k with something like this:
>>> (global-set-key "\C-k" nil)
>>> Hope it helps,
>>> weber
>> 
>> But doesn't Cecil need to unbind \C-x\C-k, and not merely \C-k?
>> C-x C-k runs the command edit-kbd-macro.
>
> I got what I tried to do out of 'Learning GNU Emacs', pages 160 and 161. But
> it does not work. For example for the keybinding they give:
>   C-x C-k b
> But then I get:
>   Key sequence b is not a keyboard macro
>
> That is a big oops for O'Reilly.
>

Possibly not. That book is fairly old I think and emacs key binding may have
changed since it was written. 

> I tried to use the reserved keys, but that is not possible. What is a good
> way to select keys for binding macro's to?
>

What I tend to do is use C-h b to get a list of the key bindings used in the
mode you want to bind the key for and then search for one that is not used. I
then might use C-h k to verify the key bind I plan to use is not already used. 

There use to be a key binding FAQ posted to this list on a regular basis.
However, I've not seen it for quite some time now. I'm sure if you google you
will find a copy. It contains some good advice on key binding etc. 

Tim
-- 
tcross (at) rapttech dot com dot au

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

* Re: Problem binding to a key
  2007-04-21  4:09       ` Tim X
@ 2007-04-21  7:33         ` Cecil Westerhof
  2007-04-21  7:59           ` Cecil Westerhof
  0 siblings, 1 reply; 14+ messages in thread
From: Cecil Westerhof @ 2007-04-21  7:33 UTC (permalink / raw)
  To: help-gnu-emacs

Tim X wrote:
>> I got what I tried to do out of 'Learning GNU Emacs', pages 160 and 161.
>> But it does not work. For example for the keybinding they give:
>>   C-x C-k b
>> But then I get:
>>   Key sequence b is not a keyboard macro
>>
>> That is a big oops for O'Reilly.
>>
> 
> Possibly not. That book is fairly old I think and emacs key binding may
> have changed since it was written.

I have edition 3 from 2005, so that is not very old I would think, but that
could explain it,


>> I tried to use the reserved keys, but that is not possible. What is a
>> good way to select keys for binding macro's to?
>>
> 
> What I tend to do is use C-h b to get a list of the key bindings used in
> the mode you want to bind the key for and then search for one that is not
> used. I then might use C-h k to verify the key bind I plan to use is not
> already used.

You still have the possibility that a key that you pick that is not used,
will be used in a new installed mode. Properly I need to accept this risk.


> There use to be a key binding FAQ posted to this list on a regular basis.
> However, I've not seen it for quite some time now. I'm sure if you google
> you will find a copy. It contains some good advice on key binding etc.

The best copy I could find was one that had Emacs 20 as the latest version.
So the book is better I am afraid.

Well, instead of using an user key binding, I just will use a free key
binding.

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

* Re: Problem binding to a key
  2007-04-21  7:33         ` Cecil Westerhof
@ 2007-04-21  7:59           ` Cecil Westerhof
  2007-04-21 12:57             ` Johan Bockgård
  2007-04-22  6:46             ` Tim X
  0 siblings, 2 replies; 14+ messages in thread
From: Cecil Westerhof @ 2007-04-21  7:59 UTC (permalink / raw)
  To: help-gnu-emacs

Cecil Westerhof wrote:
>> Possibly not. That book is fairly old I think and emacs key binding may
>> have changed since it was written.
> 
> I have edition 3 from 2005, so that is not very old I would think, but
> that could explain it,

It is a big oops, It says in the preface that it specifically covers 21.3
and even more specifically covers 21.3.5. I have Emacs 21.3.1, so there
should not be a problem.
Properly they did not check the macro stuff before releasing the book.

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

* Re: Problem binding to a key
  2007-04-21  7:59           ` Cecil Westerhof
@ 2007-04-21 12:57             ` Johan Bockgård
  2007-04-21 16:19               ` Reiner Steib
  2007-04-22 11:28               ` Cecil Westerhof
  2007-04-22  6:46             ` Tim X
  1 sibling, 2 replies; 14+ messages in thread
From: Johan Bockgård @ 2007-04-21 12:57 UTC (permalink / raw)
  To: help-gnu-emacs

Cecil Westerhof <dummy@dummy.nl> writes:

> and even more specifically covers 21.3.5.

There's no such version.

The keyboard macro bindings have been changed in the CVS version
(Emacs 22, formerly known as 21.3.50).

-- 
Johan Bockgård

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

* Re: Problem binding to a key
  2007-04-21 12:57             ` Johan Bockgård
@ 2007-04-21 16:19               ` Reiner Steib
  2007-04-22 11:28               ` Cecil Westerhof
  1 sibling, 0 replies; 14+ messages in thread
From: Reiner Steib @ 2007-04-21 16:19 UTC (permalink / raw)
  To: help-gnu-emacs

On Sat, Apr 21 2007, Johan Bockgård wrote:

> Cecil Westerhof <dummy@dummy.nl> writes:
>
>> and even more specifically covers 21.3.5.
>
> There's no such version.

Emacs 21.3.5 could be the fifth build of Emacs 21.3.  :-)

Bye, Reiner.
-- 
       ,,,
      (o o)
---ooO-(_)-Ooo---  |  PGP key available  |  http://rsteib.home.pages.de/

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

* Re: Problem binding to a key
  2007-04-21  7:59           ` Cecil Westerhof
  2007-04-21 12:57             ` Johan Bockgård
@ 2007-04-22  6:46             ` Tim X
  2007-04-22 11:33               ` Cecil Westerhof
  1 sibling, 1 reply; 14+ messages in thread
From: Tim X @ 2007-04-22  6:46 UTC (permalink / raw)
  To: help-gnu-emacs

Cecil Westerhof <dummy@dummy.nl> writes:

> Cecil Westerhof wrote:
>>> Possibly not. That book is fairly old I think and emacs key binding may
>>> have changed since it was written.
>> 
>> I have edition 3 from 2005, so that is not very old I would think, but
>> that could explain it,
>
> It is a big oops, It says in the preface that it specifically covers 21.3
> and even more specifically covers 21.3.5. I have Emacs 21.3.1, so there
> should not be a problem.
> Properly they did not check the macro stuff before releasing the book.
>

It would seem so. I had this book many years ago and didn't realise they were
still updating and releasing it. You should send in an errata report to
O'Reilly (or check the errata for that book, maybe it ahs alrady been picked
up.). 

I guess this is one of the dangers of releasing later editions. I suspect there
was some time between version releases, so its not surprising they have missed
some of the changes. 

I had both the Learning Emacs Lisp and Programming Emacs Lisp" back around
95-96 or so. While I found them OK, I have to say they are two of my least used
O'Reilly books. I purchased them when I was first using emacs and in the end
found the best references were actually the on line tutorial, the Introduction
to Emacs book by Robert Chassel, the emacs manual  and the elisp reference
manual. Robert's Introduction book is a really good starting place (I think
they are bundling it with emacs 22 now along with the elisp manual). 

With respect to the key binding guide, I've found that its a pretty good
reference even if it refers to emacs 20. It provides some good explination of
the various key binding approaches and advice on how to select the appropriate
bindings for both personal use and when defining new packages etc. 

Tim
 


-- 
tcross (at) rapttech dot com dot au

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

* Re: Problem binding to a key
  2007-04-21 12:57             ` Johan Bockgård
  2007-04-21 16:19               ` Reiner Steib
@ 2007-04-22 11:28               ` Cecil Westerhof
  1 sibling, 0 replies; 14+ messages in thread
From: Cecil Westerhof @ 2007-04-22 11:28 UTC (permalink / raw)
  To: help-gnu-emacs

Johan Bockgård wrote:

> Cecil Westerhof <dummy@dummy.nl> writes:
> 
>> and even more specifically covers 21.3.5.
> 
> There's no such version.

Well, that is what they wrote in the preface on paxe X.

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

* Re: Problem binding to a key
  2007-04-22  6:46             ` Tim X
@ 2007-04-22 11:33               ` Cecil Westerhof
  0 siblings, 0 replies; 14+ messages in thread
From: Cecil Westerhof @ 2007-04-22 11:33 UTC (permalink / raw)
  To: help-gnu-emacs

Tim X wrote:
>> It is a big oops, It says in the preface that it specifically covers 21.3
>> and even more specifically covers 21.3.5. I have Emacs 21.3.1, so there
>> should not be a problem.
>> Properly they did not check the macro stuff before releasing the book.
>>
> 
> It would seem so. I had this book many years ago and didn't realise they
> were still updating and releasing it. You should send in an errata report
> to O'Reilly (or check the errata for that book, maybe it ahs alrady been
> picked up.).

It is not in the errata. I'll send them an e-mail.

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

end of thread, other threads:[~2007-04-22 11:33 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-04-20 14:54 Problem binding to a key Cecil Westerhof
2007-04-20 15:54 ` weber
2007-04-20 16:14   ` Rjjd
2007-04-20 21:14     ` Cecil Westerhof
2007-04-21  4:09       ` Tim X
2007-04-21  7:33         ` Cecil Westerhof
2007-04-21  7:59           ` Cecil Westerhof
2007-04-21 12:57             ` Johan Bockgård
2007-04-21 16:19               ` Reiner Steib
2007-04-22 11:28               ` Cecil Westerhof
2007-04-22  6:46             ` Tim X
2007-04-22 11:33               ` Cecil Westerhof
2007-04-21  4:04   ` Tim X
2007-04-20 16:27 ` Eric Hanchrow

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.