* Re: Binding a function to control c control space
[not found] ` <87y5wii9nt.fsf@Compaq.site>
@ 2011-10-18 21:55 ` jpkotta
0 siblings, 0 replies; 2+ messages in thread
From: jpkotta @ 2011-10-18 21:55 UTC (permalink / raw)
To: help-gnu-emacs
On Oct 18, 10:47 am, Cecil Westerhof <Ce...@decebal.nl> wrote:
> Op dinsdag 18 okt 2011 14:25 CEST schreef Stefan Monnier:
>
> >> (global-set-key "\C-c\C-spc" 'delete-trailing-whitespace)
>
> > Better stay away from strings to represent key sequences (these used to
> > work in Emacs-18, but ever since we added support for GUIs, only the
> > vector representation can be used reliably):
>
> > (global-set-key [?\C-c ?\C- ] 'delete-trailing-whitespace)
>
> Works like a charm. Thanks.
>
> With the other definitions I did not have a problem, but I will update
> them anyway. Better safe as sorry.
>
> > Note that the C-SPC combination can not be produced from a tty (when
> > you hit C-SPC, the terminal sends the code of C-@). This problem is
> > related to the problem of representing C-SPC inside a string.
>
> I almost never work with Emacs in a tty, almost always in the GUI, but
> to be safe again I defined it also. :-D
>
> By the way in the GUI when C-@ is not defined it is redirected to
> 'C- '. When it is defined its definition is used. So be sure to have
> the same definition for both key combinations. ;-}
>
> --
> Cecil Westerhof
> Senior Software Engineer
> LinkedIn:http://www.linkedin.com/in/cecilwesterhof
Here's how I do it. Use C-h k <keyseq> to get the help for a key
sequence. Then use the kbd macro with the text representation of key
sequence that C-h k gave. E.g. when I do C-h k C-c C-SPC, I get a
message saying "C-c C-SPC is undefined" (if it was defined, I'd get a
help buffer with the same text representation of the key sequence).
So I could do (global-set-key (kbd "C-c C-SPC") 'some-command) to
define it. I can't think of any key sequences that this has not
worked with, and I'm fairly certain that this is the same
representation that ends up in the lossage buffer.
^ permalink raw reply [flat|nested] 2+ messages in thread