[comp.emacs] Swapping

brant@manta.UUCP (Brant Cheikes) (12/31/87)

I'd like to swap the meaning of the pair of keys "[" and "]" with that
of "(" and ")" when in Lisp Mode.  That is, when I type a "[", I want
to see a "(", and similar with "]" and ")".  Why?  Because on my
keyboard, the parens are shifted while the brackets are not, and I'd
like to avoid all that shifting (a la Lispm keyboard).  I only want to
do this in Lisp Mode, so it seems I have to fool with lisp-mode-map.
But all my attempts, using define-key, have lost.  What's the trick?
People should mail to me directly, and I'll summarize (don't want to
fill the newsgroup with repeats).  Thanks.
-- 
Brant Cheikes
University of Pennsylvania
Department of Computer and Information Science
ARPA: brant@linc.cis.upenn.edu, UUCP: ...drexel!manta!brant

karl@tut.cis.ohio-state.edu (Karl Kleinpaste) (01/04/88)

Your first solution ought to be buy something with a proper keyboard,
but...

Try C-h v keyboard-translate-table and create a replacement string for
the k-t-t with appropriate alterations from the ASCII norm.
-- 
Karl

brant@manta.UUCP (Brant Cheikes) (01/04/88)

In article <326@manta.UUCP> I write:
>I'd like to swap the meaning of the pair of keys "[" and "]" with that
>of "(" and ")" when in Lisp Mode.

The cleanest solution (due to weemba@garnet) is the following:

(defun insert-lp () (interactive) (insert ?\())
(defun insert-rp () (interactive) (insert ?\)) (blink-matching-open))
(defun insert-lb () (interactive) (insert ?\[))
(defun insert-rb () (interactive) (insert ?\]))
(define-key lisp-mode-map "(" 'insert-lb)
(define-key lisp-mode-map ")" 'insert-rb)
(define-key lisp-mode-map "[" 'insert-lp)
(define-key lisp-mode-map "]" 'insert-rp)

Thanks to all who replied.   Happy Gnu Year! -b
-- 
Brant Cheikes
University of Pennsylvania
Department of Computer and Information Science
ARPA: brant@linc.cis.upenn.edu, UUCP: ...drexel!manta!brant