all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Marco Baringer <empb@bese.it>
Subject: swapping [] and () in elisp
Date: 17 Sep 2002 20:58:06 +0200	[thread overview]
Message-ID: <m2znug8mv5.fsf@bese.it> (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

             reply	other threads:[~2002-09-17 18:58 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-09-17 18:58 Marco Baringer [this message]
     [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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m2znug8mv5.fsf@bese.it \
    --to=empb@bese.it \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.