--- tex.el 28 Oct 2005 18:09:08 +0200 5.541 +++ tex.el 01 Nov 2005 17:09:02 +0100 @@ -3277,6 +3277,11 @@ :group 'TeX-macro :type 'boolean) +(defcustom TeX-electric-exp-and-subscript nil + "If non-nil insert braces after typing `^' and `_' in math mode." + :group 'TeX-macro + :type 'boolean) + (defcustom TeX-newline-function 'newline "Function to be called upon pressing `RET'." :group 'TeX-indentation @@ -3285,6 +3290,13 @@ (const reindent-then-newline-and-indent) (sexp :tag "Other"))) +(defun TeX-electric-exp-and-subscript (arg) + (interactive "*p") + (self-insert-command arg) + (when (and TeX-electric-exp-and-subscript (texmathp)) + (insert "{}") + (backward-char))) + (defun TeX-newline () "Call the function specified by the variable `TeX-newline-function'." (interactive) (funcall TeX-newline-function)) @@ -3311,6 +3323,8 @@ (define-key map "\C-c\C-m" 'TeX-insert-macro) (if TeX-electric-escape (define-key map "\\" 'TeX-electric-macro)) + (define-key map "^" 'TeX-electric-exp-and-subscript) + (define-key map "_" 'TeX-electric-exp-and-subscript) (define-key map "\e\t" 'TeX-complete-symbol) ;*** Emacs 19 way (define-key map "\C-c'" 'TeX-comment-or-uncomment-paragraph) ;*** Old way