unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Changing key bindings of printable chars
@ 2004-06-24 21:04 Paul Batt
  2004-06-24 23:34 ` Michael Slass
  2004-06-24 23:46 ` David Vanderschel
  0 siblings, 2 replies; 11+ messages in thread
From: Paul Batt @ 2004-06-24 21:04 UTC (permalink / raw)


How can I change the key binding of a single printable character key to
another? I need to have "z" and "Z" print "y" and "Y" and vice versa and I
need to have RET do a double-return e.g. two line feeds instead of only one.
(I found many peaces of instruction how to change key bindings of double
key-strokes like C-x but can't just figure out how to do it for a single
printable character key). Thank you.

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

* Re: Changing key bindings of printable chars
  2004-06-24 21:04 Changing key bindings of printable chars Paul Batt
@ 2004-06-24 23:34 ` Michael Slass
  2004-06-25  0:55   ` John Paul Wallington
  2004-06-25 20:31   ` Paul Batt
  2004-06-24 23:46 ` David Vanderschel
  1 sibling, 2 replies; 11+ messages in thread
From: Michael Slass @ 2004-06-24 23:34 UTC (permalink / raw)


"Paul Batt" <paul@pbatt.ch> writes:

>How can I change the key binding of a single printable character key to
>another? I need to have "z" and "Z" print "y" and "Y" and vice versa and I
>need to have RET do a double-return e.g. two line feeds instead of only one.
>(I found many peaces of instruction how to change key bindings of double
>key-strokes like C-x but can't just figure out how to do it for a single
>printable character key). Thank you.
>
>
>
>
>
for Y,y,Z, and z ...
(local-set-key "Y" (lambda () (interactive) (insert "Z")))
... and so on


for return
(local-set-key "\C-m" (lambda () (interactive) (newline 2)))


I'm almost afraid to ask why you want this, but not quite.  Why do you
want this?
-- 
Mike Slass

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

* Re: Changing key bindings of printable chars
  2004-06-24 21:04 Changing key bindings of printable chars Paul Batt
  2004-06-24 23:34 ` Michael Slass
@ 2004-06-24 23:46 ` David Vanderschel
  1 sibling, 0 replies; 11+ messages in thread
From: David Vanderschel @ 2004-06-24 23:46 UTC (permalink / raw)


"Paul Batt" <paul@pbatt.ch> wrote in message
news:2k0tudF160v27U1@uni-berlin.de...
> How can I change the key binding of a single printable character key to
> another? I need to have "z" and "Z" print "y" and "Y" and vice versa

Check out keyboard-translate-table in the "Translating
Input" info node for elisp.  The keyboard-translate
function is probably what you need.  (I just made an
interesting mistake testing it:  I did
(keyboard-translate ?z ?y) first, and I could not
easilz ( :) ) do (keyboard-translate ?y ?z) because I
could no longer enter a z!  I solved the problem by
copying one from the buffer.  Word to the wise:
Compose both functions calls before executing either.)

>and I need to have RET do a double-return e.g. two
>line feeds instead of only one.  ...

I am not sure, but I think this probably requires use
of the function-key-map (same info node).  You may be
confusing ^M and ^J.

Regards,
  David V.

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

* Re: Changing key bindings of printable chars
  2004-06-24 23:34 ` Michael Slass
@ 2004-06-25  0:55   ` John Paul Wallington
  2004-06-25 18:22     ` Kevin Rodgers
  2004-06-25 20:31   ` Paul Batt
  1 sibling, 1 reply; 11+ messages in thread
From: John Paul Wallington @ 2004-06-25  0:55 UTC (permalink / raw)


Michael Slass <miknrene@drizzle.com> writes:

> "Paul Batt" <paul@pbatt.ch> writes:
>
>>How can I change the key binding of a single printable character key to
>>another? I need to have "z" and "Z" print "y" and "Y" and vice versa and I
[...]
> for Y,y,Z, and z ...
> (local-set-key "Y" (lambda () (interactive) (insert "Z")))

Commands needn't be functions -- they could be simple keyboard macros,
eg:  (global-set-key "Y" "Z")

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

* Re: Changing key bindings of printable chars
  2004-06-25  0:55   ` John Paul Wallington
@ 2004-06-25 18:22     ` Kevin Rodgers
  2004-06-26  0:30       ` John Paul Wallington
  0 siblings, 1 reply; 11+ messages in thread
From: Kevin Rodgers @ 2004-06-25 18:22 UTC (permalink / raw)


John Paul Wallington wrote:
 > Michael Slass <miknrene@drizzle.com> writes:
 >>"Paul Batt" <paul@pbatt.ch> writes:
 >>>How can I change the key binding of a single printable character key to
 >>>another? I need to have "z" and "Z" print "y" and "Y" and vice versa and I
 > [...]
 >
 >>for Y,y,Z, and z ...
 >>(local-set-key "Y" (lambda () (interactive) (insert "Z")))
 >
 > Commands needn't be functions -- they could be simple keyboard macros,
 > eg:  (global-set-key "Y" "Z")

Yes, but that combined with (global-set-key "Z" "Y") to meet Paul's
requirements leads to infinite recursion.

-- 
Kevin Rodgers

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

* Re: Changing key bindings of printable chars
  2004-06-24 23:34 ` Michael Slass
  2004-06-25  0:55   ` John Paul Wallington
@ 2004-06-25 20:31   ` Paul Batt
  2004-06-25 22:56     ` Michael Slass
  2004-06-30 15:34     ` Kai Grossjohann
  1 sibling, 2 replies; 11+ messages in thread
From: Paul Batt @ 2004-06-25 20:31 UTC (permalink / raw)


"Michael Slass" <miknrene@drizzle.com> schrieb im Newsbeitrag
news:m3zn6s1qev.fsf@eric.rossnet.com...
> "Paul Batt" <paul@pbatt.ch> writes:
(...)
> I'm almost afraid to ask why you want this, but not quite.  Why do you
> want this?

Mike
I expected the question. The Z-Y thing is because I write German in an
English environment occasionally. English and German keyboards have Z and Y
replaced with each other. I could handle this by changing the keyboard
settings in the OS of course, but other (English tongue) people use the
computer also, and I might one day forget to switch back; they'd probably
kill me. Double-RET is because I use refill-mode and longlines-mode and I
found these to work better with an emtpy line between paragraphs (there is
also the idea with "hard" Returns, but this does not help much and besides
that I prefer two line feed paragraphs in plain ascii text anyway). So I
hope to somehow get my own minor mode working with Z and Y replaced and a
double line feed for my texts.
-Paul

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

* Re: Changing key bindings of printable chars
  2004-06-25 20:31   ` Paul Batt
@ 2004-06-25 22:56     ` Michael Slass
  2004-06-26  0:05       ` Paul Batt
  2004-06-30 15:34     ` Kai Grossjohann
  1 sibling, 1 reply; 11+ messages in thread
From: Michael Slass @ 2004-06-25 22:56 UTC (permalink / raw)


"Paul Batt" <paul@pbatt.ch> writes:

>Mike
>I expected the question. The Z-Y thing is because I write German in an
>English environment occasionally. English and German keyboards have Z and Y
>replaced with each other. I could handle this by changing the keyboard
>settings in the OS of course, but other (English tongue) people use the
>computer also, and I might one day forget to switch back; they'd probably
>kill me. Double-RET is because I use refill-mode and longlines-mode and I
>found these to work better with an emtpy line between paragraphs (there is
>also the idea with "hard" Returns, but this does not help much and besides
>that I prefer two line feed paragraphs in plain ascii text anyway). So I
>hope to somehow get my own minor mode working with Z and Y replaced and a
>double line feed for my texts.
>-Paul

Ok, thanks for satisfying my curiosity :)
Did any of the posted answers work for you?

-- 
Mike Slass

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

* Re: Changing key bindings of printable chars
  2004-06-25 22:56     ` Michael Slass
@ 2004-06-26  0:05       ` Paul Batt
  0 siblings, 0 replies; 11+ messages in thread
From: Paul Batt @ 2004-06-26  0:05 UTC (permalink / raw)


"Michael Slass" <miknrene@drizzle.com> schrieb im Newsbeitrag
news:m3d63nz1p7.fsf@eric.rossnet.com...
> "Paul Batt" <paul@pbatt.ch> writes:
>
> Ok, thanks for satisfying my curiosity :)
> Did any of the posted answers work for you?

Don't know yet. I'll try next week. If not I'll be glad if I may ask again.
Thanks, so far.
Paul

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

* Re: Changing key bindings of printable chars
  2004-06-25 18:22     ` Kevin Rodgers
@ 2004-06-26  0:30       ` John Paul Wallington
  2004-06-26  1:26         ` Pascal Bourguignon
  0 siblings, 1 reply; 11+ messages in thread
From: John Paul Wallington @ 2004-06-26  0:30 UTC (permalink / raw)


Kevin Rodgers <ihs_4664@yahoo.com> writes:

>  > Commands needn't be functions -- they could be simple keyboard macros,
>  > eg:  (global-set-key "Y" "Z")
>
> Yes, but that combined with (global-set-key "Z" "Y") to meet Paul's
> requirements leads to infinite recursion.

Doh!  I should have paid attention to what Paul asked.

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

* Re: Changing key bindings of printable chars
  2004-06-26  0:30       ` John Paul Wallington
@ 2004-06-26  1:26         ` Pascal Bourguignon
  0 siblings, 0 replies; 11+ messages in thread
From: Pascal Bourguignon @ 2004-06-26  1:26 UTC (permalink / raw)


John Paul Wallington <jpw@gnu.org> writes:

> Kevin Rodgers <ihs_4664@yahoo.com> writes:
> 
> >  > Commands needn't be functions -- they could be simple keyboard macros,
> >  > eg:  (global-set-key "Y" "Z")
> >
> > Yes, but that combined with (global-set-key "Z" "Y") to meet Paul's
> > requirements leads to infinite recursion.
> 
> Doh!  I should have paid attention to what Paul asked.

But not:

(global-set-key "Y" (lambda()(interactive"*")(insert "Z")))
(global-set-key "Z" (lambda()(interactive"*")(insert "Y")))
(global-set-key "y" (lambda()(interactive"*")(insert "z")))
(global-set-key "z" (lambda()(interactive"*")(insert "y")))

And note that in anycase, using C-q z gives z and C-q y gives y.

-- 
__Pascal Bourguignon__                     http://www.informatimago.com/

There is no worse tyranny than to force a man to pay for what he does not
want merely because you think it would be good for him. -- Robert Heinlein

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

* Re: Changing key bindings of printable chars
  2004-06-25 20:31   ` Paul Batt
  2004-06-25 22:56     ` Michael Slass
@ 2004-06-30 15:34     ` Kai Grossjohann
  1 sibling, 0 replies; 11+ messages in thread
From: Kai Grossjohann @ 2004-06-30 15:34 UTC (permalink / raw)


"Paul Batt" <paul@pbatt.ch> writes:

> I expected the question. The Z-Y thing is because I write German in an
> English environment occasionally. English and German keyboards have Z and Y
> replaced with each other.

Perhaps C-u C-\ german RET fits the bill?  It changes some other
keys, too.

Kai

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

end of thread, other threads:[~2004-06-30 15:34 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-06-24 21:04 Changing key bindings of printable chars Paul Batt
2004-06-24 23:34 ` Michael Slass
2004-06-25  0:55   ` John Paul Wallington
2004-06-25 18:22     ` Kevin Rodgers
2004-06-26  0:30       ` John Paul Wallington
2004-06-26  1:26         ` Pascal Bourguignon
2004-06-25 20:31   ` Paul Batt
2004-06-25 22:56     ` Michael Slass
2004-06-26  0:05       ` Paul Batt
2004-06-30 15:34     ` Kai Grossjohann
2004-06-24 23:46 ` David Vanderschel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).