help-gnu-emacs
[Top][All Lists]
Advanced

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

how to close braces in all modes automatically?


From: Patrick Drechsler
Subject: how to close braces in all modes automatically?
Date: Thu, 06 Nov 2003 00:11:37 +0100
User-agent: Gnus/5.1003 (Gnus v5.10.3) Emacs/21.3 (gnu/linux)

Hi,

is there a simple way of closing all braces automatically in all
modes (i.e. HTML, Java, LaTeX, Matlab,...)?

My Linux (Suse 8.2) came with a snipplet which does this for
LaTeX-mode but I haven't been able to adopt it for *all* modes.

--8<------------------------schnipp------------------------->8---
(defun TeX-Inserting (sta stb stc)
    (if (= (preceding-char) sta )
        (insert stb)
      (progn (insert stc) (backward-char 1))))
(defun TeX-schweif () (interactive "*") (TeX-Inserting ?\\ "{"  "{}"))
(defun TeX-rundekl () (interactive "*") (TeX-Inserting ?\\ "("  "()"))
(defun TeX-eckigek () (interactive "*") (TeX-Inserting ?\\ "["  "[]"))
(add-hook 'LaTeX-mode-hook
      '(lambda ()
         (local-set-key  "{" 'TeX-schweif)
         (local-set-key  "(" 'TeX-rundekl)
         (local-set-key  "[" 'TeX-eckigek)
))                                      
--8<------------------------schnapp------------------------->8---

Replacing the term 'TeX' with my initials and sticking it into my
~/.emacs didn't do the trick.

Grateful for any help (esp. concerning Matlab),

Patrick
-- 
"If anyone tells me to work smarter, not harder, I will kick him or her, 
hard, in a random body part.  I will then kick him or her a second time, 
"smarter, not harder," which is to say that on the second strike, I'll 
use the same force, but target more carefully.  "           -- Catherine



reply via email to

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