From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Marco Baringer Newsgroups: gmane.emacs.help Subject: swapping [] and () in elisp Date: 17 Sep 2002 20:58:06 +0200 Sender: help-gnu-emacs-admin@gnu.org Message-ID: NNTP-Posting-Host: localhost.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: main.gmane.org 1032289154 30653 127.0.0.1 (17 Sep 2002 18:59:14 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Tue, 17 Sep 2002 18:59:14 +0000 (UTC) Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 17rNZ2-0007yH-00 for ; Tue, 17 Sep 2002 20:59:12 +0200 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.10) id 17rNZN-0002td-00; Tue, 17 Sep 2002 14:59:33 -0400 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.10) id 17rNWt-0001ga-00 for help-gnu-emacs@gnu.org; Tue, 17 Sep 2002 14:56:59 -0400 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.10) id 17rNWr-0001g5-00 for help-gnu-emacs@gnu.org; Tue, 17 Sep 2002 14:56:59 -0400 Original-Received: from mail-2.tiscali.it ([195.130.225.148] helo=mail.tiscali.it) by monty-python.gnu.org with esmtp (Exim 4.10) id 17rNWr-0001fv-00 for help-gnu-emacs@gnu.org; Tue, 17 Sep 2002 14:56:57 -0400 Original-Received: from localhost (62.10.101.161) by mail.tiscali.it (6.5.026) id 3D6E3431008BEDDF for help-gnu-emacs@gnu.org; Tue, 17 Sep 2002 20:56:56 +0200 Original-To: help-gnu-emacs@gnu.org Original-Lines: 41 User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.1.30 Errors-To: help-gnu-emacs-admin@gnu.org X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.0.11 Precedence: bulk List-Help: List-Post: List-Subscribe: , List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: Xref: main.gmane.org gmane.emacs.help:1554 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:1554 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