[Top][All Lists]

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

swapping [] and () in elisp

From: Marco Baringer
Subject: swapping [] and () in elisp
Date: 17 Sep 2002 20:58:06 +0200
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.1.30

i am trying to find a way in elisp to swap the [] and () keys.

all i have to do is:

1) get the old definition from the local-map, or if none exists, from
   the global map.

2) redefine the keys so that they call the swapped definition. setup
   last-command-char and use call-interactively so that everything
   works as it should.

so, to make (kbd "[") act like (kbd "(") here's what i do: (assuming
MODE-MAP is the key map to switch)

(let ((orig-open-square (or (lookup-key mode-map "[")
                            (lookup-key global-map "["))))
    (define-key mode-map "("
      (lambda ()
        (setq last-command-char ?\[)
        (call-interactively orig-open-square [?\[]))))

my problem is how to deal with ORIG-OPEN-SQUARE. by the time the (kbd
"(") key gets pressed the definition of orig-open-sqaure is gone. if i
make orig-open-square buffer-local then i get infiinte loops as i end
up setting the key to something which calls itself. i'd like a
mode-local variable or something of a way to say "this keymap has
already been modified, don't do it again."

p.s. - please do not mention the xmodmap/registry manipulation. 1)
they don't work on my powerbook. 2) i can't modify other the registry
on other people's machines, but i can modify the .emacs.
Ring the bells that still can ring.
Forget your perfect offering.
There is a crack in everything.
That's how the light gets in.
     -Leonard Cohen

reply via email to

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