unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* swapping [] and () in elisp
@ 2002-09-17 18:58 Marco Baringer
  0 siblings, 0 replies; 3+ messages in thread
From: Marco Baringer @ 2002-09-17 18:58 UTC (permalink / raw)



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 ()
        (interactive)
        (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.
      
-- 
-Marco
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

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

* Re: swapping [] and () in elisp
       [not found] <mailman.1032289172.11134.help-gnu-emacs@gnu.org>
@ 2002-09-17 19:12 ` Stefan Monnier <foo@acm.com>
  2002-09-17 19:37   ` Marco Baringer
  0 siblings, 1 reply; 3+ messages in thread
From: Stefan Monnier <foo@acm.com> @ 2002-09-17 19:12 UTC (permalink / raw)


>>>>> "Marco" == Marco Baringer <empb@bese.it> writes:
> i am trying to find a way in elisp to swap the [] and () keys.

Check out keyboard-translate.


        Stefan

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

* Re: swapping [] and () in elisp
  2002-09-17 19:12 ` swapping [] and () in elisp Stefan Monnier <foo@acm.com>
@ 2002-09-17 19:37   ` Marco Baringer
  0 siblings, 0 replies; 3+ messages in thread
From: Marco Baringer @ 2002-09-17 19:37 UTC (permalink / raw)


"Stefan Monnier <foo@acm.com>" <monnier+gnu.emacs.help/news/@flint.cs.yale.edu> writes:

> >>>>> "Marco" == Marco Baringer <empb@bese.it> writes:
> > i am trying to find a way in elisp to swap the [] and () keys.
> 
> Check out keyboard-translate.

that would work too :)

thanks.
-- 
-Marco
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

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

end of thread, other threads:[~2002-09-17 19:37 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <mailman.1032289172.11134.help-gnu-emacs@gnu.org>
2002-09-17 19:12 ` swapping [] and () in elisp Stefan Monnier <foo@acm.com>
2002-09-17 19:37   ` Marco Baringer
2002-09-17 18:58 Marco Baringer

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