;;; latex-i18n.el --- Support for i18n in LaTeX documents. ;; ;; Maintainer: ;; Version: 0.1 ;; Keywords: i18n, wp ;; X-URL: ;; ;; Copyright 2002 ;; ;; This program is free software; you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by ;; the Free Software Foundation; either version 1, or (at your option) ;; any later version. ;; ;; This program is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;; GNU General Public License for more details. ;; ;; You should have received a copy of the GNU General Public License ;; along with this program; if not, write to the Free Software ;; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. ;;; Code: (require 'latex) ;;; Setup: (provide 'latex-i18n) ;; Keymap ;(defvar latex-i18n-keymap ;(let ((map(copy-keymap LaTeX-mode-map))) ; (define-key map "\\" 'latex-i18n-backslash) ; (define-key map "\}" 'latex-i18n-rmoustache) ; (define-key map "\{" 'latex-i18n-lmoustache) ; (define-key map " " 'latex-i18n-space) ; (define-key map "$" 'latex-i18n-dollar) ; map)) ;(defun latex-i18n-mode () ; (interactive) ; (make-variable-buffer-local 'slash-done) ; (make-variable-buffer-local 'starting-input-method) ; (make-variable-buffer-local 'starting-math-input-method) ; (make-variable-buffer-local 'been-in-math-mode) ; (make-variable-buffer-local 'starting-moustache) ; (make-variable-buffer-local 'latex-i18n-mode) ; (setq latex-i18n-mode t) ; (use-local-map latex-i18n-keymap)) ; (set-buffer-modified-p (buffer-modified-p))) (define-minor-mode latex-i18n-mode "Easy LaTeX input for foreign languages." nil "i18n" '(("\\" . latex-i18n-backslash) ("\}" . latex-i18n-rmoustache) ("\{" . latex-i18n-lmoustache) (" " . latex-i18n-space) ("$" . latex-i18n-dollar)) (interactive) (make-variable-buffer-local 'slash-done) (make-variable-buffer-local 'starting-input-method) (make-variable-buffer-local 'starting-math-input-method) (make-variable-buffer-local 'been-in-math-mode) (make-variable-buffer-local 'starting-moustache) (make-variable-buffer-local 'latex-i18n-mode) (setq latex-i18n-mode t) (TeX-set-mode-name)) ;(or (assoc 'latex-i18n-mode minor-mode-alist) ; (setq minor-mode-alist (cons '(latex-i18n-mode " i18n") minor-mode-alist))) ; (or (assoc 'latex-i18n-mode minor-mode-map-alist) ; (setq minor-mode-map-alist ; (cons (cons 'latex-i18n-mode latex-i18n-keymap) ; minor-mode-map-alist))) (defvar latex-i18n-regexp-list '("section" "subsection" "subsubsection" "text" "author" "title" "paragraph" "caption") "Environments that accept input in various languages (not just ASCII") (defun latex-i18n-backslash () (interactive) ;(unless(TeX-point-is-escaped) (setq starting-input-method current-input-method) (inactivate-input-method) (setq slash-done t) (insert "\\")) (defun latex-i18n-rmoustache () (interactive) (insert "\}") (when slash-done (save-excursion (backward-word 2) (if (and been-in-math-mode (looking-at "end")) (progn (activate-input-method starting-math-input-method) (setq been-in-math-mode nil)))) (when (texmathp) (if (save-excursion (backward-word 2) (looking-at "begin")) (progn (setq starting-math-input-method starting-input-method) (setq been-in-math-mode t) (inactivate-input-method)) (inactivate-input-method))) (setq starting-moustache nil) (setq slash-done nil))) (defun latex-i18n-lmoustache () (interactive) (when slash-done (save-excursion (backward-word 1) (let (non-math) (setq non-math (catch 'found (dolist (temp latex-i18n-regexp-list) (if (looking-at temp) (throw 'found t))))) (if non-math (activate-input-method starting-input-method)))) (setq starting-moustache t)) (insert "\{")) (defun latex-i18n-space () (interactive) (when slash-done (when (not starting-moustache) (activate-input-method starting-input-method) (setq slash-done nil))) (insert ?\ ) (do-auto-fill)) (defun latex-i18n-dollar () (interactive) (if (texmathp) (activate-input-method starting-math-input-method) (setq starting-math-input-method current-input-method) (inactivate-input-method)) (insert "$"))