unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* remapping keys
@ 2008-02-18 11:35 Seldon
  2008-02-18 16:14 ` Stefan Monnier
  0 siblings, 1 reply; 11+ messages in thread
From: Seldon @ 2008-02-18 11:35 UTC (permalink / raw)
  To: help-gnu-emacs

Hi. I'm an Emacs newbie  and I need help about remapping keyboard keys.

I would like to bind the curly brackets "}" and "{" to another keys, 
handier to me (I have an italian keyboard, so the key sequence for the 
brackets is quite clumsy...)

What's the procedure for doing so ?
Thanks in advance.
-- 
Seldon

"L'immaginazione e' piu' importante della conoscenza"
Alberto Unapietra


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

* Re: remapping keys
  2008-02-18 11:35 remapping keys Seldon
@ 2008-02-18 16:14 ` Stefan Monnier
  2008-02-18 17:00   ` Seldon
  0 siblings, 1 reply; 11+ messages in thread
From: Stefan Monnier @ 2008-02-18 16:14 UTC (permalink / raw)
  To: help-gnu-emacs

> Hi.  I'm an Emacs newbie  and I need help about remapping keyboard keys.

> I would like to bind the curly brackets "}" and "{" to another keys, handier
> to me (I have an italian keyboard, so the key sequence for the brackets is
> quite clumsy...)

> What's the procedure for doing so ?

It all depends on how you want the remapping to behave.  Do you want
this remapping only within Emacs?  Do you want it to apply to things
like C-{ and M-}?  How about C-x { ?

I personally prefer to do those kinds of "inconvenient keyboard" things
globally by choosing another keyboard layout (e.g. with
gnome-keyboard-properties).


        Stefan


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

* Re: remapping keys
  2008-02-18 16:14 ` Stefan Monnier
@ 2008-02-18 17:00   ` Seldon
  2008-02-18 19:04     ` muede73
                       ` (3 more replies)
  0 siblings, 4 replies; 11+ messages in thread
From: Seldon @ 2008-02-18 17:00 UTC (permalink / raw)
  To: help-gnu-emacs

Stefan Monnier wrote:
>> Hi.  I'm an Emacs newbie  and I need help about remapping keyboard keys.
> 
>> I would like to bind the curly brackets "}" and "{" to another keys, handier
>> to me (I have an italian keyboard, so the key sequence for the brackets is
>> quite clumsy...)
> 
>> What's the procedure for doing so ?
> 
> It all depends on how you want the remapping to behave.  Do you want
> this remapping only within Emacs?

Yes.

> Do you want it to apply to things
> like C-{ and M-}?  How about C-x { ?
Yes, why not ?



> 
> I personally prefer to do those kinds of "inconvenient keyboard" things
> globally by choosing another keyboard layout (e.g. with
> gnome-keyboard-properties).
> 

I would prefer a more selective approach, remapping only the keys I need.

> 
>         Stefan


-- 
Seldon

"L'immaginazione e' piu' importante della conoscenza"
Alberto Unapietra


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

* Re: remapping keys
  2008-02-18 17:00   ` Seldon
@ 2008-02-18 19:04     ` muede73
  2008-02-25 10:45       ` Seldon
  2008-02-19  2:01     ` Juanma
                       ` (2 subsequent siblings)
  3 siblings, 1 reply; 11+ messages in thread
From: muede73 @ 2008-02-18 19:04 UTC (permalink / raw)
  To: help-gnu-emacs

Seldon wrote:
>>
> 
> I would prefer a more selective approach, remapping only the keys I need.
> 

Is 'keyboard-translate' what you want ?

-ap


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

* Re: remapping keys
  2008-02-18 17:00   ` Seldon
  2008-02-18 19:04     ` muede73
@ 2008-02-19  2:01     ` Juanma
       [not found]     ` <mailman.7615.1203400883.18990.help-gnu-emacs@gnu.org>
  2008-02-20 19:53     ` Stefan Monnier
  3 siblings, 0 replies; 11+ messages in thread
From: Juanma @ 2008-02-19  2:01 UTC (permalink / raw)
  To: help-gnu-emacs

On Monday 18 February 2008 18:00, Seldon wrote:
> [...]
> > I personally prefer to do those kinds of "inconvenient keyboard" things
> > globally by choosing another keyboard layout (e.g. with
> > gnome-keyboard-properties).
>
> I would prefer a more selective approach, remapping only the keys I need.

Try with function keyboard-translate.

You say you are newbie with Emacs. You might discover you need to change too 
many things. Just a couple of examples:
*  dabbrev-expand (M-/)
*  undo vs. negative-argument (C-_ vs. C--). Actually, undo is best located in 
C-/, but not in your layout.

I moved from the Spanish layout (similar to Italian) to a dual (switching) 
layout: US std. / US intl. w/ deadkeys (gives you all latin-1 characters). 
Now the slash is one easy hit away and so is the single quote mark. I'm not 
going back to Spanish layout even if I have to use a Spanish keyboard.

Juanma
------------------------------
"No pleasure, no rapture, no exquisite
 sin greater than central air."
    -- Azrael, in film "Dogma" (Kevin Smith, 1999)





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

* Re: remapping keys
       [not found]     ` <mailman.7615.1203400883.18990.help-gnu-emacs@gnu.org>
@ 2008-02-19 16:33       ` Seldon
  2008-02-20  0:32         ` Sam Peterson
  0 siblings, 1 reply; 11+ messages in thread
From: Seldon @ 2008-02-19 16:33 UTC (permalink / raw)
  To: help-gnu-emacs

Juanma wrote:
> On Monday 18 February 2008 18:00, Seldon wrote:
>> [...]
>>> I personally prefer to do those kinds of "inconvenient keyboard" things
>>> globally by choosing another keyboard layout (e.g. with
>>> gnome-keyboard-properties).
>> I would prefer a more selective approach, remapping only the keys I need.
> 
> Try with function keyboard-translate.
> 
I read the documentation, but I didn't understood how to call or use 
this function.

I think I will follow your advice and switch to an US layout.

Bye.


-- 
Seldon

"L'immaginazione e' piu' importante della conoscenza"
Alberto Unapietra


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

* Re: remapping keys
  2008-02-19 16:33       ` Seldon
@ 2008-02-20  0:32         ` Sam Peterson
  2008-02-20  2:12           ` Juanma
  0 siblings, 1 reply; 11+ messages in thread
From: Sam Peterson @ 2008-02-20  0:32 UTC (permalink / raw)
  To: help-gnu-emacs

Seldon <seldon@katamail.it> on Tue, 19 Feb 2008 17:33:53 +0100 didst
step forth and proclaim thus:

> Juanma wrote:
>> On Monday 18 February 2008 18:00, Seldon wrote:
>>> [...]
>>>> I personally prefer to do those kinds of "inconvenient keyboard" things
>>>> globally by choosing another keyboard layout (e.g. with
>>>> gnome-keyboard-properties).
>>> I would prefer a more selective approach, remapping only the keys I need.
>>
>> Try with function keyboard-translate.
>>
> I read the documentation, but I didn't understood how to call or use
> this function.
>
> I think I will follow your advice and switch to an US layout.
>
> Bye.

Wow, a whole thread on remapping keys, and NOBODY mentions
global-set-key or local-set-key.

;; just an example, change the keys to whatever you like
(global-set-key "{" '(lambda () (interactive) (insert "a")))

Many will argue that keyboard translate is better.  Whatever works...

-- 
Sam Peterson
skpeterson At nospam ucdavis.edu
"if programmers were paid to remove code instead of adding it,
software would be much better" -- unknown


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

* Re: remapping keys
  2008-02-20  0:32         ` Sam Peterson
@ 2008-02-20  2:12           ` Juanma
  0 siblings, 0 replies; 11+ messages in thread
From: Juanma @ 2008-02-20  2:12 UTC (permalink / raw)
  To: help-gnu-emacs

On Wednesday 20 February 2008 01:32, Sam Peterson wrote:
> Wow, a whole thread on remapping keys, and NOBODY mentions
> global-set-key or local-set-key.
>
> ;; just an example, change the keys to whatever you like
> (global-set-key "{" '(lambda () (interactive) (insert "a")))
>
> Many will argue that keyboard translate is better.  Whatever works...

I thought of it but I rejected it because the point is not just to get a curly 
bracket inserted in the text, but also to use it in keystrokes, which I guess 
can't be done with that lambda form. I can't figure any other way to do it 
than keyboard-translate. Involving only Emacs in the solution, that is.

Sadly, no approach solves the problem. Neither the above lambda form, nor 
keyboard-translate¹, nor define-key² provide a substitution of keys 
throughout the whole Emacs cathedral: in keystrokes the original key still 
applies.

¹: (keyboard-translate ?. ?/)
²: (define-key global-map (kbd ".") (kbd "/"))

In any of these cases, asking for the command mapped to M-. will give exactly 
that, not the command mapped to M-/ as intended.

It is still possible to re-map *all* keystrokes using curly brackets to make 
them use something more comfortable, but ... well, no way.

Juanma





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

* Re: remapping keys
  2008-02-18 17:00   ` Seldon
                       ` (2 preceding siblings ...)
       [not found]     ` <mailman.7615.1203400883.18990.help-gnu-emacs@gnu.org>
@ 2008-02-20 19:53     ` Stefan Monnier
  2008-02-27 20:29       ` Hans Ekbrand
  3 siblings, 1 reply; 11+ messages in thread
From: Stefan Monnier @ 2008-02-20 19:53 UTC (permalink / raw)
  To: help-gnu-emacs

>>> Hi.  I'm an Emacs newbie  and I need help about remapping keyboard keys.
>>> I would like to bind the curly brackets "}" and "{" to another keys, handier
>>> to me (I have an italian keyboard, so the key sequence for the brackets is
>>> quite clumsy...)
>>> What's the procedure for doing so ?
>> It all depends on how you want the remapping to behave.  Do you want
>> this remapping only within Emacs?

> Yes.

>> Do you want it to apply to things
>> like C-{ and M-}?  How about C-x { ?
> Yes, why not ?

Because that's more difficult (unless you answered "no" to the previous
question, in which case it's easier instead).

You could try

  (define-key key-translation-map "{" "f")
  (define-key key-translation-map "}" "g")

and if you want to use "f" and "g" for { and }, then add

  (define-key key-translation-map "f" "{")
  (define-key key-translation-map "g" "}")

Note that it will apply to C-x { but not to C-{ and M-{, C-f, C-g, tho
it will apply to ESC { and ESC g.  I.e. it's kind of messy.

>> I personally prefer to do those kinds of "inconvenient keyboard" things
>> globally by choosing another keyboard layout (e.g. with
>> gnome-keyboard-properties).

> I would prefer a more selective approach, remapping only the keys I need.

Define your own keyboard layout?


        Stefan


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

* Re: remapping keys
  2008-02-18 19:04     ` muede73
@ 2008-02-25 10:45       ` Seldon
  0 siblings, 0 replies; 11+ messages in thread
From: Seldon @ 2008-02-25 10:45 UTC (permalink / raw)
  To: help-gnu-emacs

muede73 wrote:
> Seldon wrote:
>>>
>>
>> I would prefer a more selective approach, remapping only the keys I need.
>>
> 
> Is 'keyboard-translate' what you want ?
> 
> -ap

As  I said, I read the documentation, but I didn't understood how to 
call or use this function.

I think I will switch to an US layout.


-- 
Seldon

"L'immaginazione e' piu' importante della conoscenza"
Alberto Unapietra


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

* Re: remapping keys
  2008-02-20 19:53     ` Stefan Monnier
@ 2008-02-27 20:29       ` Hans Ekbrand
  0 siblings, 0 replies; 11+ messages in thread
From: Hans Ekbrand @ 2008-02-27 20:29 UTC (permalink / raw)
  To: help-gnu-emacs

[-- Attachment #1: Type: text/plain, Size: 1239 bytes --]

On Wed, Feb 20, 2008 at 02:53:26PM -0500, Stefan Monnier wrote:
> >>> Hi.  I'm an Emacs newbie  and I need help about remapping keyboard keys.
> >>> I would like to bind the curly brackets "}" and "{" to another keys, handier
> >>> to me (I have an italian keyboard, so the key sequence for the brackets is
> >>> quite clumsy...)
> >>> What's the procedure for doing so ?
> >> It all depends on how you want the remapping to behave.  Do you want
> >> this remapping only within Emacs?
> 
> > Yes.

Why not in other applications too? To only change this for emacs seems
more difficult than doing it at the X level

[...]

> Note that it will apply to C-x { but not to C-{ and M-{, C-f, C-g, tho
> it will apply to ESC { and ESC g.  I.e. it's kind of messy.
> 
> >> I personally prefer to do those kinds of "inconvenient keyboard" things
> >> globally by choosing another keyboard layout (e.g. with
> >> gnome-keyboard-properties).
> 
> > I would prefer a more selective approach, remapping only the keys I need.
> 
> Define your own keyboard layout?

Or rather just define a few remappings in .Xmodmaprc and have a line 

/usr/bin/X11/xmodmap ~/.Xmodmaprc

in .xsession.

kind regards,

--
Hans Ekbrand

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

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

end of thread, other threads:[~2008-02-27 20:29 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-02-18 11:35 remapping keys Seldon
2008-02-18 16:14 ` Stefan Monnier
2008-02-18 17:00   ` Seldon
2008-02-18 19:04     ` muede73
2008-02-25 10:45       ` Seldon
2008-02-19  2:01     ` Juanma
     [not found]     ` <mailman.7615.1203400883.18990.help-gnu-emacs@gnu.org>
2008-02-19 16:33       ` Seldon
2008-02-20  0:32         ` Sam Peterson
2008-02-20  2:12           ` Juanma
2008-02-20 19:53     ` Stefan Monnier
2008-02-27 20:29       ` Hans Ekbrand

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).