summaryrefslogtreecommitdiff
path: root/elpa/auctex-13.1.3/style/inputenc.el
blob: 14ff61c6f74437ec7a94c9e30cce10b330eead4c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
;;; inputenc.el --- AUCTeX style for `inputenc.sty'  -*- lexical-binding: t; -*-

;; Copyright (C) 2005-2021  Free Software Foundation, Inc.

;; Author: Arne Jørgensen <arne@arnested.dk>
;; Keywords: tex

;; This file is part of AUCTeX.

;; AUCTeX 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 3, or (at your option)
;; any later version.

;; AUCTeX 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 AUCTeX; see the file COPYING.  If not, write to the Free
;; Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
;; MA 02110-1301, USA.

;;; Commentary:

;; This file adds support for `inputenc.sty'.

;;; Code:

(require 'tex)

(defun LaTeX-inputenc-package-options nil
  "Prompt for package options for the inputenc package."
  ;; separate the condition in three to silence the byte compiler
  (if (boundp 'latex-inputenc-coding-alist)
      (when (fboundp 'latexenc-coding-system-to-inputenc)
        (when (fboundp 'latexenc-inputenc-to-coding-system)
          (let ((default (latexenc-coding-system-to-inputenc
                          (or coding-system-for-write
                              buffer-file-coding-system)))
                (selected 'undecided))
            (setq selected (completing-read
                            (if default
                                (format "Input encoding (default %s): " default)
                              "Input encoding: ")
                            (mapcar #'car latex-inputenc-coding-alist)
                            nil
                            nil
                            nil
                            nil
                            default))

            ;; if necessary offer to set the coding system for saving
            ;; this buffer based on the selected input encoding
            (when (and (null
                        (coding-system-equal
                         (coding-system-base
                          (or coding-system-for-write
                              buffer-file-coding-system))
                         (coding-system-base
                          (latexenc-inputenc-to-coding-system selected))))
                       (y-or-n-p "Set coding system for saving this buffer? ")
                       (set-buffer-file-coding-system
                        (coding-system-base
                         (latexenc-inputenc-to-coding-system selected)))
                       (message nil)))

            ;; return selected input encoding
            selected)))
    (TeX-read-string "Input encoding: ")))

(defun LaTeX-arg-inputenc-inputenc (_optional)
  "Prompt for input encoding."
  (TeX-argument-insert (LaTeX-inputenc-package-options) nil))

(TeX-add-style-hook
 "inputenc"
 (lambda ()
   ;; New symbols
   (TeX-add-symbols
    '("inputencoding" LaTeX-arg-inputenc-inputenc)))
 TeX-dialect)

;; Local Variables:
;; coding: utf-8
;; End:

;;; inputenc.el ends here