From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Arne =?utf-8?Q?J=C3=B8rgensen?= Newsgroups: gmane.emacs.devel Subject: Re: auto-coding-function for LaTeX Date: Fri, 12 Nov 2004 07:44:56 +0100 Organization: emfle birnan Message-ID: <87lld7sh07.fsf@seamus.arnested.dk> References: <87u0ryah75.fsf@seamus.arnested.dk> <87654coxm9.fsf@jurta.org> <87654ct2zi.fsf@seamus.arnested.dk> <87y8h8rlbs.fsf@seamus.arnested.dk> NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: sea.gmane.org 1100241938 11855 80.91.229.6 (12 Nov 2004 06:45:38 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Fri, 12 Nov 2004 06:45:38 +0000 (UTC) Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Nov 12 07:45:21 2004 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1CSVBR-0002LT-00 for ; Fri, 12 Nov 2004 07:45:21 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1CSVJy-0006Nu-ML for ged-emacs-devel@m.gmane.org; Fri, 12 Nov 2004 01:54:10 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.33) id 1CSVJq-0006Np-Sz for emacs-devel@gnu.org; Fri, 12 Nov 2004 01:54:02 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.33) id 1CSVJq-0006Nd-Da for emacs-devel@gnu.org; Fri, 12 Nov 2004 01:54:02 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1CSVJq-0006Na-Ai for emacs-devel@gnu.org; Fri, 12 Nov 2004 01:54:02 -0500 Original-Received: from [80.91.229.2] (helo=main.gmane.org) by monty-python.gnu.org with esmtp (Exim 4.34) id 1CSVB7-000860-BG for emacs-devel@gnu.org; Fri, 12 Nov 2004 01:45:01 -0500 Original-Received: from list by main.gmane.org with local (Exim 3.35 #1 (Debian)) id 1CSVB6-0001tl-00 for ; Fri, 12 Nov 2004 07:45:00 +0100 Original-Received: from 213.237.94.152 ([213.237.94.152]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 12 Nov 2004 07:45:00 +0100 Original-Received: from arne by 213.237.94.152 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 12 Nov 2004 07:45:00 +0100 X-Injected-Via-Gmane: http://gmane.org/ Original-To: emacs-devel@gnu.org Original-Lines: 78 Original-X-Complaints-To: usenet@sea.gmane.org X-Gmane-NNTP-Posting-Host: 213.237.94.152 X-Face: 5t,7/Y$&<1A_t.$vC2{pWZ{m@3_06; kcm]no{hgEL/}Uz(>XV6cl4}xO\v?-h3%>znNaZtq `~rf,GY1T%r=a.zH`hOb(-]'x)nI088Z&|e;V^h;/TShou User-Agent: Gnus/5.110003 (No Gnus v0.3) Emacs/21.3.50 (gnu/linux) Cancel-Lock: sha1:hYonzF7F5psH3uiIA+qCx39StDo= X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: main.gmane.org gmane.emacs.devel:29772 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:29772 Reiner Steib writes: > On Fri, Nov 12 2004, Arne Jørgensen wrote: > >> It could look like this: [...] > > I have added some other coding systems available in Emacs None of the coding systems you added are present in my Emacs. So why add them? To make it easier for a user to customized when/if they are added? Or are they present in your Emacs? > and I tried to improve the code and doc-strings. WDYT? Beautiful! Since the function no longer is supposed to be in `auto-coding-alist' I think the name of the alist should be changed though. Maybe `latex-inputenc-coding-alist' or something. --8<---------------cut here---------------start------------->8--- (defcustom latex-inputenc-coding-alist '(("ansinew" . windows-1252) ; MS Windows ANSI encoding, extension of Latin-1 ("applemac" . mac-roman) ("ascii" . us-ascii) ("cp1250" . cp1250) ; MS Windows encoding, codepage 1250 ("cp1252" . windows-1252) ; synonym of ansinew ("cp437de" . cp437) ; IBM code page 437 (German version): 225 is \ss ("cp437" . cp437) ; IBM code page 437: 225 is \beta ("cp850" . cp850) ; IBM code page 850 ("cp852" . cp852) ; IBM code page 852 ("cp865" . cp865) ; IBM code page 865 ;; The DECMultinational charaterset used by the OpenVMS system ;; ("decmulti" . undecided) ("latin1" . iso-8859-1) ("latin2" . iso-8859-2) ("latin3" . iso-8859-3) ("latin4" . iso-8859-4) ("latin5" . iso-8859-5) ("latin9" . iso-8859-15) ;; ("next" . undecided) ; The Next encoding ("utf8" . utf-8)) "Mapping from encoding names used by \"inputenc.sty\" to Emacs coding systems. Used by the function `latex-find-file-coding-system'." :group 'mule :type '(alist :key-type (string :tag "LaTeX input encoding") :value-type (coding-system :tag "Coding system"))) (defun latex-find-file-coding-system (arg) "Determine the encoding of a LaTeX buffer if it uses \"inputenc.sty\". This function is intended to be added to `file-coding-system-alist'. The mapping from LaTeX's \"inputenc.sty\" encoding names to Emacs coding system names is determined from `latex-auto-coding-alist'." (when (re-search-forward "\\usepackage\\[\\(.*\\)\\]{inputenc}" 1000 t) (let* ((match (match-string 1)) (inputenc-match (cdr (assoc match latex-inputenc-coding-alist))) (sym (intern match))) (when inputenc-match (setq sym inputenc-match)) (when (coding-system-p sym) sym)))) (add-to-list 'file-coding-system-alist '("\\.tex\\|\\.ltx\\'" . latex-find-file-coding-system)) --8<---------------cut here---------------end--------------->8--- By the way. The re-search-forward searches until position 1000. Should that number be customizable? The functions in `auto-coding-alist' get an argument of 249 for number of positions to search, but I think that is not enough for LaTeX files. Kind regards, -- Arne Jørgensen Gammel Kongevej 7, 1. th., DK-1610 Copenhagen V, Denmark mobile: +45 21 65 01 13 email: arne@arnested.dk,