help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Setting auto-indentation of braces


From: Juha Nieminen
Subject: Re: Setting auto-indentation of braces
Date: Mon, 16 Feb 2009 11:50:08 +0200
User-agent: Thunderbird 2.0.0.19 (Macintosh/20081209)

Juha Nieminen kirjoitti:
In the macosx version this autoindentation is off, and I can't figure out where to turn it on. I'm so accustomed to it, that it's annoying that it doesn't work...

 Oh, man... I'm such an IDIOT! *bangs head on wall*

 You see, Macs have this really weird keyboard configuration for the
Finnish keyboard (which I'm using) which is completely different from
the PC configuration which I'm accustomed to from well over 10 years.
In the PC to get the curly braces you press AltGr+7 and AltGr+0, but
on the Mac you have to press Alt+Shift+8 and Alt+Shift+9. Needless
to say that this is really awkward to use, and I'm not accustomed to it.

 Thus I searched for a way in MacOS X to reconfigure this, and I
couldn't find any way. (Maybe there is, but I just couldn't find it. So
much for the famous "easy to use" OS...) So instead I went and tried
to remap these keys in my .emacs instead. I suppose you already
guess the reason why those braces were not being auto-indented...

 The thing is, no matter how much I tried to search info on how to
do it, I couldn't find a way to remap keys in .emacs. Or more precisely,
I couldn't find a way to make a given key combination be equivalent
to pressing some other key. So I invented this really ugly hack to get
around the problem:

(defun insert-string(s)
 (if (re-search-forward "" nil t)
     (replace-match s)))
(defun insert-open-curly() (interactive) (insert-string "{"))
(global-set-key "\M-7" 'insert-open-curly)

 Yes, as said, this is a really horrible hack, but with my limited
knowledge of emacs it was the only thing I could come up with.
I couldn't find any other way of "remapping" eg. "\M-7" to the curly
brace. No wonder emacs is not auto-indenting the brace because
I'm completely bypassing the logic behind it.

 And indeed, if I type the curly brace with Alt+Shift+8 then it gets
properly auto-indented.

 I suppose my question is: What is the proper way of remapping
keys, which will not bypass any auto-indenting routines?


reply via email to

[Prev in Thread] Current Thread [Next in Thread]