auctex
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[AUCTeX] Re: inputenc and coding system


From: Arne Jørgensen
Subject: [AUCTeX] Re: inputenc and coding system
Date: Wed, 18 Oct 2006 21:46:39 +0200
User-agent: Gnus/5.110006 (No Gnus v0.6) Emacs/22.0.50 (gnu/linux)

Piet van Oostrum <address@hidden> writes:

> Now I want to have an automatic check before the buffer is saved: if the
> buffer contains non-ASCII characters and there is no \usepackage{inputenc}
> or one with a wrong encoding then I would like to have a warning (or an
> offer to insert the proper command.

I have had that idea too. And I vaguely remember that I started coding
something - can find any traces of it though.

The only thing that comes close is the piece below from my .emacs.

(Among other things) I inserts the right \usepackage[...]{inputenc}
for the buffer when you insert the document-environment.

(defun my-LaTeX-document-style-hook nil
  "Insert my default \\usepackages."
  (save-excursion
    (goto-char (point-min))
    (search-forward "\\documentclass" nil t)
    (forward-line)
    (insert "\\usepackage[T1]{fontenc}\n")
    (when (fboundp 'latexenc-coding-system-to-inputenc)
      (if (and (not buffer-file-coding-system)
               (not (eq (latexenc-coding-system-to-inputenc
                         buffer-file-coding-system)
                        'undecided)))
          (insert "\\usepackage[" (latexenc-coding-system-to-inputenc
                                   buffer-file-coding-system) "]{inputenc}\n")
        (insert "\\usepackage[utf8]{inputenc}\n")
        (set-buffer-file-coding-system 'utf-8-unix))
      (insert "\\usepackage{babel}\n")
      (insert "\\usepackage[osf,sc]{mathpazo}\n")
      (insert "\\usepackage{microtype}\n"))))

(add-hook 'LaTeX-mode-hook
          (lambda nil (add-hook 'LaTeX-document-style-hook
                                'my-LaTeX-document-style-hook nil t)))


Kind regards

        /arne
-- 
Arne Jørgensen <http://arnested.dk/>





reply via email to

[Prev in Thread] Current Thread [Next in Thread]