Initial Commit
[packages] / xemacs-packages / auctex / style / inputenc.el
1 ;;; inputenc.el --- AUCTeX style for `inputenc.sty'
2
3 ;; Copyright (C) 2005 Free Software Foundation, Inc.
4
5 ;; Author: Arne Jørgensen <arne@arnested.dk>
6 ;; Keywords: tex
7
8 ;; This file is part of AUCTeX.
9
10 ;; AUCTeX is free software; you can redistribute it and/or modify it
11 ;; under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 3, or (at your option)
13 ;; any later version.
14
15 ;; AUCTeX is distributed in the hope that it will be useful, but
16 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18 ;; General Public License for more details.
19
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with AUCTeX; see the file COPYING.  If not, write to the Free
22 ;; Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
23 ;; MA 02110-1301, USA.
24
25 ;;; Commentary:
26
27 ;; This file adds support for `inputenc.sty'.
28
29 ;;; Code:
30
31 (defun LaTeX-inputenc-package-options nil
32   "Prompt for package options for the inputenc package."
33   ;; separate the condition in three to silence the byte compiler
34   (if (boundp 'latex-inputenc-coding-alist)
35       (when (fboundp 'latexenc-coding-system-to-inputenc)
36         (when (fboundp 'latexenc-inputenc-to-coding-system)
37           (let ((default (latexenc-coding-system-to-inputenc
38                           (or coding-system-for-write
39                               buffer-file-coding-system)))
40                 (selected 'undecided))
41             (setq selected (completing-read
42                             (if default
43                                 (format "Input encoding (default %s): " default)
44                               "Input encoding: ")
45                             (mapcar 'car latex-inputenc-coding-alist)
46                             nil
47                             nil
48                             nil
49                             nil
50                             default))
51
52             ;; if necessary offer to set the coding system for saving
53             ;; this buffer based on the selected input encoding
54             (when (and (null
55                         (coding-system-equal
56                          (coding-system-base
57                           (or coding-system-for-write
58                               buffer-file-coding-system))
59                          (coding-system-base
60                           (latexenc-inputenc-to-coding-system selected))))
61                        (y-or-n-p "Set coding system for saving this buffer? ")
62                        (set-buffer-file-coding-system
63                         (coding-system-base
64                          (latexenc-inputenc-to-coding-system selected)))
65                        (message nil)))
66
67             ;; return selected input encoding
68             selected)))
69     (read-string "Input encoding: ")))
70
71 (defun LaTeX-arg-inputenc-inputenc (optional)
72   "Prompt for input encoding."
73   (TeX-argument-insert (LaTeX-inputenc-package-options) nil))
74
75 (TeX-add-style-hook
76  "inputenc"
77  (lambda ()
78    ;; New symbols
79    (TeX-add-symbols
80     '("inputencoding" LaTeX-arg-inputenc-inputenc)))
81  LaTeX-dialect)
82
83 ;; Local Variables:
84 ;; coding: iso-8859-1
85 ;; End:
86
87 ;;; inputenc.el ends here