Piet van Oostrum <[EMAIL PROTECTED]> 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/>



_______________________________________________
auctex mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/auctex

Reply via email to