[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: how to close braces in all modes automatically?
From: |
Yongtao Yang |
Subject: |
Re: how to close braces in all modes automatically? |
Date: |
06 Nov 2003 11:03:21 +0100 |
User-agent: |
Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 |
Patrick Drechsler <patrick.drechsler@gmx.net> writes:
> 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.
>
...
>
> Grateful for any help (esp. concerning Matlab),
>
I have the following in my .emacs. Stupid but works. :) You have to
use matlab-mode.el for it to work
====begin=========
(autoload 'matlab-mode "matlab" "Enter Matlab mode." t)
(setq auto-mode-alist (cons '("\\.m$" . matlab-mode) auto-mode-alist))
(defun matlab-electric-semi ()
"Insert a semicolon in matlab mode.
then linefeed and reindent the new line. "
(interactive)
(insert ";")
(matlab-linefeed))
(defun matlab-electric-cont-line ()
"Insert a continue line in matlab mode.
then linefeed and reindent the new line. "
(interactive)
(insert "...")
(matlab-linefeed))
(defun matlab-electric-parenthesis ()
"Insert a pair of parenthesis in matlab mode."
(interactive)
(insert "()")
(backward-char 1))
(defun matlab-electric-bracket ()
"Insert a pair of brackets in matlab mode."
(interactive)
(insert "[]")
(backward-char 1))
(defun matlab-electric-brace ()
"Insert a pair of braces in matlab mode."
(interactive)
(insert "{}")
(backward-char 1))
(defun my-matlab-mode-hook ()
(setq matlab-shell-command-switches '("-nojvm" "-nosplash"))
(setq matlab-function-indent t) ; if you want function bodies indented
(setq fill-column 72) ; where auto-fill should wrap
(setq matlab-indent-level 4)
(setq matlab-shell-input-ring-size 1024)
(setq matlab-shell-history-file "~/.matlab/R13/history.m")
(setq matlab-verify-on-save-flag 'nil)
(turn-on-auto-fill)
(local-set-key ";" 'matlab-electric-semi)
(local-set-key "(" 'matlab-electric-parenthesis)
(local-set-key "[" 'matlab-electric-bracket)
(local-set-key "{" 'matlab-electric-brace)
(local-set-key "\C-\M-m" 'matlab-electric-cont-line)
; (turn-on-setnu-mode)
)
====end=========
--
Yongtao Yang
email: yangyongtao@yahoo.com