From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: One example of code I can't understand Date: Mon, 20 Jul 2009 14:13:59 -0400 Message-ID: References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1248113661 6722 80.91.229.12 (20 Jul 2009 18:14:21 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 20 Jul 2009 18:14:21 +0000 (UTC) Cc: emacs-devel@gnu.org To: rms@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Jul 20 20:14:14 2009 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1MSxNN-0006m8-V4 for ged-emacs-devel@m.gmane.org; Mon, 20 Jul 2009 20:14:14 +0200 Original-Received: from localhost ([127.0.0.1]:35289 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MSxNN-0005Po-7D for ged-emacs-devel@m.gmane.org; Mon, 20 Jul 2009 14:14:13 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MSxNI-0005OR-76 for emacs-devel@gnu.org; Mon, 20 Jul 2009 14:14:08 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MSxND-0005O2-DI for emacs-devel@gnu.org; Mon, 20 Jul 2009 14:14:07 -0400 Original-Received: from [199.232.76.173] (port=46440 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MSxND-0005Nz-AE for emacs-devel@gnu.org; Mon, 20 Jul 2009 14:14:03 -0400 Original-Received: from ironport2-out.teksavvy.com ([206.248.154.182]:34026) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MSxNA-0002xf-HR; Mon, 20 Jul 2009 14:14:00 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AtIEAEBRZEpFpZqY/2dsb2JhbACBUc8mhAwFhwI X-IronPort-AV: E=Sophos;i="4.43,235,1246852800"; d="scan'208";a="41910744" Original-Received: from 69-165-154-152.dsl.teksavvy.com (HELO pastel.home) ([69.165.154.152]) by ironport2-out.teksavvy.com with ESMTP; 20 Jul 2009 14:13:59 -0400 Original-Received: by pastel.home (Postfix, from userid 20848) id A72937F66; Mon, 20 Jul 2009 14:13:59 -0400 (EDT) In-Reply-To: (Richard Stallman's message of "Sun, 19 Jul 2009 19:21:52 -0400") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.94 (gnu/linux) X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. 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: news.gmane.org gmane.emacs.devel:112840 Archived-At: > Here's some code from mm-util.el that I don't understand. > Well, I can understand the first 6 lines, but after that > I am stumped. The doc string gives no details of what the > value should look like or what it means. > (defvar mm-iso-8859-x-to-15-table > (and (fboundp 'coding-system-p) > (mm-coding-system-p 'iso-8859-15) > (mapcar > (lambda (cs) > (if (mm-coding-system-p (car cs)) > (let ((c (string-to-char > (decode-coding-string "\341" (car cs))))) > (cons (char-charset c) > (cons > (- (string-to-char > (decode-coding-string "\341" 'iso-8859-15)) c) > (string-to-list (decode-coding-string (car (cdr cs)) > (car cs)))))) > '(gnus-charset 0))) > mm-iso-8859-15-compatible)) > "A table of the difference character between ISO-8859-X and ISO-8859-15.") Entries in this list have the form (CHARSET OFFSET CHARS...) and it means that characters in CHARSET (except for those in CHARS) can be converted to iso-8859-15 by adding OFFSET. In Emacs-23 it doesn't make much sense (because unification, OFFSET is always 0). It's used in mm-find-mime-charset-region (via mm-iso-8859-x-to-15-region) to provide a "poor man's unification": (if (and (> (length charsets) 1) (memq 'iso-8859-15 charsets) (memq 'iso-8859-15 hack-charsets) (save-excursion (mm-iso-8859-x-to-15-region b e))) (dolist (x mm-iso-8859-15-compatible) (setq charsets (delq (car x) charsets)))) i.e. if we need more than 1 coding-system to encode the region and iso-8859-15 is among them, then use the above table to turn some of the other chars into iso-8859-15 in the hope to reduce the number of coding-systems to use (and hence the number of chunk into which the text needs to be split). Now that we have utf-8, this is unnecessary since we can always encode the whole text with just a single coding-system, without having to break it down into chunks. Stefan