From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: handa@gnu.org (K. Handa) Newsgroups: gmane.emacs.devel Subject: Re: Creating a coding system Date: Tue, 23 Dec 2014 17:59:13 +0900 Message-ID: <87fvc63foe.fsf@gnu.org> References: <87ppbeitcs.fsf@fencepost.gnu.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1419325183 27717 80.91.229.3 (23 Dec 2014 08:59:43 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 23 Dec 2014 08:59:43 +0000 (UTC) Cc: emacs-devel@gnu.org To: David Kastrup Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Dec 23 09:59:33 2014 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Y3LJV-00056u-2t for ged-emacs-devel@m.gmane.org; Tue, 23 Dec 2014 09:59:33 +0100 Original-Received: from localhost ([::1]:43673 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y3LJU-00058L-AX for ged-emacs-devel@m.gmane.org; Tue, 23 Dec 2014 03:59:32 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:59964) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y3LJM-00058E-NK for emacs-devel@gnu.org; Tue, 23 Dec 2014 03:59:30 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Y3LJH-000560-7j for emacs-devel@gnu.org; Tue, 23 Dec 2014 03:59:24 -0500 Original-Received: from fencepost.gnu.org ([2001:4830:134:3::e]:43885) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y3LJH-00055n-5G for emacs-devel@gnu.org; Tue, 23 Dec 2014 03:59:19 -0500 Original-Received: from fl1-122-134-99-48.iba.mesh.ad.jp ([122.134.99.48]:33876 helo=tinhau) by fencepost.gnu.org with esmtpsa (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1Y3LJG-0005HB-GT; Tue, 23 Dec 2014 03:59:18 -0500 Original-Received: from handa by tinhau with local (Exim 4.80) (envelope-from ) id 1Y3LJB-0001qU-EM; Tue, 23 Dec 2014 17:59:13 +0900 In-Reply-To: <87ppbeitcs.fsf@fencepost.gnu.org> (message from David Kastrup on Sat, 20 Dec 2014 10:05:39 +0100) X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2001:4830:134:3::e X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:180547 Archived-At: Hi, sorry for the late response. In article <87ppbeitcs.fsf@fencepost.gnu.org>, David Kastrup writes: > Ok, what am I doing wrong here? Why does decode-coding-string not do > anything here? > (define-translation-table 'midi-decode-table > (make-translation-table-from-alist > (mapcar > (lambda (p) > (cons (car p) (string-to-vector (cdr p)))) > '(([144 0] . "c,,,,") [...] > (define-coding-system 'midi > "This converts Midi note-on events to note names" > :mnemonic ?M > :coding-type 'charset > :eol-type 'unix > :decode-translation-table 'midi-decode-table > :mime-text-unsuitable t) Please add :charset-list '(iso-8859-1) to the arguments of define-ccoding-system. The translation table of coding system works AFTER byte sequences are decoded into char sequences by the basic decoding routine which is specified by :coding-type (and the other additional attributes). As it seems that you are expecting that the basic decoding routine decodes the byte 144 to the character 144, using the following set is good: :coding-type 'charset :charset-list '(iso-8859-1) The other method is to use CCL (i.e :coding-type 'ccl), but, if the combination of the charset decoding and translation table works, it's faster than running CCL code. If you need arithmetic or conditional operation, you have to use CCL, or :post-read-conversion. --- K. Handa handa@gnu.org PS. Should I read the other mails of this thread? I'm very sorry for this lazy attitude, but I don't have a time to read all emacs-devel mails.