Initial Commit
[packages] / xemacs-packages / auctex / style / plext.el
1 ;;; plext.el --- AUCTeX style for the plext package.
2
3 ;; Copyright (C) 2014 Free Software Foundation, Inc.
4
5 ;; Author: Ikumi Keita <ikumi@ikumi.que.jp>
6 ;; Maintainer: auctex-devel@gnu.org
7 ;; Created: 2014-07-05
8 ;; Keywords: tex, japanese
9
10 ;; This file is part of AUCTeX.
11
12 ;; AUCTeX is free software; you can redistribute it and/or modify it
13 ;; under the terms of the GNU General Public License as published by
14 ;; the Free Software Foundation; either version 3, or (at your option)
15 ;; any later version.
16
17 ;; AUCTeX is distributed in the hope that it will be useful, but
18 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
20 ;; General Public License for more details.
21
22 ;; You should have received a copy of the GNU General Public License
23 ;; along with AUCTeX; see the file COPYING.  If not, write to the Free
24 ;; Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
25 ;; 02110-1301, USA.
26
27 ;;; Commentary:
28
29 ;; This file adds support for the plext package.
30
31 ;;; Code:
32
33 (TeX-add-style-hook
34  "plext"
35  (lambda ()
36    ;; plext.sty extends some environments to accept option, e.g. <t>,
37    ;; for vertical typesetting.
38    (LaTeX-add-environments
39     ;; TODO: Add support for minipage and picture
40     ;; environments extension.
41     '("array"    LaTeX-plext-env-array)
42     '("tabular"  LaTeX-plext-env-array)
43     '("tabular*" LaTeX-plext-env-array))
44
45    (set (make-local-variable 'LaTeX-array-skipping-regexp)
46         (concat "\\(?:<[tyz]>\\)?[ \t]*" (regexp-opt '("[t]" "[b]" ""))))
47    (set (make-local-variable 'LaTeX-tabular*-skipping-regexp)
48         (concat "\\(?:<[tyz]>\\)?[ \t]*{[^}]*}[ \t]*"
49                 (regexp-opt '("[t]" "[b]" "")))))
50  LaTeX-dialect)
51
52 (defun LaTeX-plext-env-array (env)
53   (let ((dir (read-string "(Optional) Direction (t or y or z): "))
54         (width (if (string= env "tabular*")
55                    (read-string "Width: " LaTeX-default-width)))
56         (pos (and LaTeX-default-position ; LaTeX-default-position can
57                                         ; be nil, i.e. do not prompt
58                   (read-string "(Optional) Position: " LaTeX-default-position)))
59         (fmt (read-string "Format: " LaTeX-default-format)))
60     (unless (zerop (length dir))
61       (setq dir (concat "<" dir ">")))
62     (if (string= env "tabular*")
63         (setq LaTeX-default-width width))
64     (setq LaTeX-default-position pos)
65     (setq LaTeX-default-format fmt)
66     (LaTeX-insert-environment env
67                               (concat
68                                dir
69                                (if (string= env "tabular*")
70                                    (concat TeX-grop width TeX-grcl))
71                                (unless (zerop (length pos))
72                                  (concat LaTeX-optop pos LaTeX-optcl))
73                                (concat TeX-grop fmt TeX-grcl)))
74     (if (string= env "tabular*")
75         (LaTeX-item-tabular* t)
76       (LaTeX-item-array t))))
77
78 ;;; plext.el ends here.