Ar an dara lá de mí na Nollaig, scríobh Stephen J. Turnbull:
> GNU provide iso-latin-[1-16]-with-esc. Might be worth
considering, with an
> autoload infrastructure.
This must be done *immediately*, as otherwise there is no way to read
files that have inadvertantly been saved with ISO-2022 extensions.
C-u C-x C-f /path/to/file RET iso-2022-8 RET . I don’t believe we have any
Latin 2 users any more.
There's no reason in 21.5 that you can't simply rename the
builtins to
-with-esc and duplicate or alias the ones defined in
latin-euro-standards. Then the autoload feature (which will almost
surely be hard to implement fully because of the large number of places
in the C initialization code where coding systems are used)
GNU have it. It’s not neurosurgery. Initial implementation below, without
ChangeLogs. It works fine with individual coding systems, but errors with
the included iso-with-esc.el, which is something I need to fix.
can be added later.
If you find that too revolting, revert this change until you've
provided some way to read "XEmacs ISO-8859" files that contain
ISO-2022 designation sequences.
Index: src/file-coding.c
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/src/file-coding.c,v
retrieving revision 1.58
diff -u -u -r1.58 file-coding.c
--- src/file-coding.c 2007/08/06 14:50:48 1.58
+++ src/file-coding.c 2007/12/02 18:52:51
@@ -469,6 +469,33 @@
return CODING_SYSTEMP (object) ? Qt : Qnil;
}
+DEFUN ("autoload-coding-system", Fautoload_coding_system, 2, 2, 0, /*
+Define SYMBOL as a coding-system that is defined on demand.
+
+FROM is a form to evaluate to define the coding-system.
+*/
+ (symbol, form))
+{
+ CHECK_SYMBOL (symbol);
+ CHECK_CONS (form);
+
+ if (!NILP (Ffind_coding_system (symbol)))
+ {
+ invalid_operation ("Cannot redefine existing coding system",
+ symbol);
+ }
+
+ Fputhash (symbol, form, Vcoding_system_hash_table);
+ Fputhash (add_suffix_to_symbol(symbol, "-unix"), form,
+ Vcoding_system_hash_table);
+ Fputhash (add_suffix_to_symbol(symbol, "-dos"), form,
+ Vcoding_system_hash_table);
+ Fputhash (add_suffix_to_symbol(symbol, "-mac"), form,
+ Vcoding_system_hash_table);
+
+ return Qt;
+}
+
DEFUN ("find-coding-system", Ffind_coding_system, 1, 1, 0, /*
Retrieve the coding system of the given name.
@@ -479,6 +506,8 @@
*/
(coding_system_or_name))
{
+ Lisp_Object lookup;
+
if (NILP (coding_system_or_name))
coding_system_or_name = Qbinary;
else if (CODING_SYSTEMP (coding_system_or_name))
@@ -488,12 +517,71 @@
while (1)
{
- coding_system_or_name =
+ lookup =
Fgethash (coding_system_or_name, Vcoding_system_hash_table, Qnil);
- if (CODING_SYSTEMP (coding_system_or_name)
- || NILP (coding_system_or_name))
- return coding_system_or_name;
+ if (CODING_SYSTEMP (lookup) || NILP (lookup))
+ return lookup;
+
+ if (CONSP (lookup))
+ {
+ struct gcpro gcpro1;
+ int length;
+ DECLARE_EISTRING (desired_base);
+ DECLARE_EISTRING (warning_info);
+
+ eicpy_lstr (desired_base, XSYMBOL_NAME (coding_system_or_name));
+
+ /* Work out the name of the base coding system. */
+ length = eilen (desired_base);
+ if (length > (int)(sizeof ("-unix") - 1))
+ {
+ if (0 == qxestrcmp ((UAscbyte *)"-unix", (eidata (desired_base))
+ + (length - (sizeof ("-unix") - 1))))
+ {
+ eidel (desired_base, length - (sizeof ("-unix") - 1),
+ -1, 5, 5);
+ }
+ }
+ else if (length > (int)(sizeof ("-dos") - 1))
+ {
+ if ((0 == qxestrcmp ((UAscbyte *)"-dos", (eidata (desired_base))
+ + (length - (sizeof ("-dos") - 1)))) ||
+ (0 == qxestrcmp ((UAscbyte *)"-mac", (eidata (desired_base))
+ + (length - (sizeof ("-mac") - 1)))))
+ {
+ eidel (desired_base, length - (sizeof ("-dos") - 1), -1,
+ 4, 4);
+ }
+ }
+
+ coding_system_or_name = intern_int (eidata (desired_base));
+
+ /* Remove this coding system and its subsidiary coding
+ systems from the hash, to avoid calling this code recursively. */
+ Fremhash (coding_system_or_name, Vcoding_system_hash_table);
+ Fremhash (add_suffix_to_symbol(coding_system_or_name, "-unix"),
+ Vcoding_system_hash_table);
+ Fremhash (add_suffix_to_symbol(coding_system_or_name, "-dos"),
+ Vcoding_system_hash_table);
+ Fremhash (add_suffix_to_symbol(coding_system_or_name, "-mac"),
+ Vcoding_system_hash_table);
+
+ eicpy_ascii (warning_info, "Error autoloading coding system ");
+ eicat_lstr (warning_info, XSYMBOL_NAME (coding_system_or_name));
+
+ /* Keep around the form so it doesn't disappear from under
+ #'eval's feet. */
+ GCPRO1 (lookup);
+ call1_trapping_problems ((const CIbyte *)eidata (warning_info),
+ Qeval, lookup, 0);
+ UNGCPRO;
+
+ lookup =
+ Fgethash (coding_system_or_name, Vcoding_system_hash_table, Qnil);
+ }
+
+ coding_system_or_name = lookup;
}
}
@@ -651,7 +739,7 @@
};
static int
-add_coding_system_to_list_mapper (Lisp_Object key, Lisp_Object UNUSED (value),
+add_coding_system_to_list_mapper (Lisp_Object key, Lisp_Object value,
void *coding_system_list_closure)
{
/* This function can GC */
@@ -660,9 +748,13 @@
Lisp_Object *coding_system_list = cscl->coding_system_list;
/* We can't just use VALUE because KEY might be an alias, and we need
- the real coding system object. */
- if (XCODING_SYSTEM (Ffind_coding_system (key))->internal_p ?
- cscl->internal : cscl->normal)
+ the real coding system object.
+
+ Autoloaded coding systems have conses for their values, and can't be
+ internal coding systems, or coding system aliases. */
+ if (CONSP (value) ||
+ (XCODING_SYSTEM (Ffind_coding_system (key))->internal_p ?
+ cscl->internal : cscl->normal))
*coding_system_list = Fcons (key, *coding_system_list);
return 0;
}
@@ -921,7 +1013,11 @@
else
CHECK_SYMBOL (name_or_existing);
- if (!NILP (Ffind_coding_system (name_or_existing)))
+ csobj = Ffind_coding_system (name_or_existing);
+ if (!NILP (csobj) &&
+ /* If csobj is a cons, it's a Lisp form to define this coding system,
+ so a make-coding-system call can overwrite it. */
+ !CONSP (csobj))
invalid_operation ("Cannot redefine existing coding system",
name_or_existing);
@@ -4386,6 +4482,7 @@
DEFSUBR (Fvalid_coding_system_type_p);
DEFSUBR (Fcoding_system_type_list);
DEFSUBR (Fcoding_system_p);
+ DEFSUBR (Fautoload_coding_system);
DEFSUBR (Ffind_coding_system);
DEFSUBR (Fget_coding_system);
DEFSUBR (Fcoding_system_list);
Index: lisp/mule/iso-with-esc.el
===================================================================
RCS file: iso-with-esc.el
diff -N iso-with-esc.el
--- /dev/null Sun Dec 2 20:00:36 2007
+++ iso-with-esc.el Sun Dec 2 20:00:40 2007
@@ -0,0 +1,128 @@
+;;; iso-with-esc.el --
+;;; Provision of the hateful and never widely implemented Latin, Greek and
+;;; Cyrillic coding systems that passed for Latin 2, Latin 10, (etc) support
+;;; in XEmacs for so long.
+;;
+;; Copyright (C) 2006 Free Software Foundation
+
+;; Author: Aidan Kehoe
+
+;; This file is part of XEmacs.
+
+;; XEmacs is free software; you can redistribute it and/or modify it
+;; under the terms of the GNU General Public License as published by
+;; the Free Software Foundation; either version 2, or (at your option)
+;; any later version.
+
+;; XEmacs is distributed in the hope that it will be useful, but
+;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+;; General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with XEmacs; see the file COPYING. If not, write to the
+;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+;; Boston, MA 02110-1301, USA.
+
+;;; Commentary:
+
+;;; Code:
+
+(provide 'iso-with-esc)
+
+;;;###autoload
+(define-coding-system-alias 'iso-latin-1-with-esc 'iso-2022-8)
+
+(make-coding-system
+ 'iso-latin-2-with-esc 'iso2022 "ISO-8859-2 (Latin-2)"
+ '(charset-g0 ascii
+ charset-g1 latin-iso8859-2
+ charset-g2 t
+ charset-g3 t
+ mnemonic "MIME/Ltn-2"))
+
+;;;###autoload
+(autoload-coding-system 'iso-latin-2-with-esc '(require 'iso-with-esc))
+
+(make-coding-system
+ 'iso-latin-3-with-esc 'iso2022 "ISO-8859-3 (Latin-3)"
+ '(charset-g0 ascii
+ charset-g1 latin-iso8859-3
+ charset-g2 t
+ charset-g3 t
+ mnemonic "MIME/Ltn-3"))
+
+;;;###autoload
+(autoload-coding-system 'iso-latin-3-with-esc '(require 'iso-with-esc))
+
+(make-coding-system
+ 'iso-latin-4-with-esc 'iso2022 "ISO-8859-4 (Latin-4)"
+ '(charset-g0 ascii
+ charset-g1 latin-iso8859-4
+ charset-g2 t
+ charset-g3 t
+ mnemonic "MIME/Ltn-4"))
+
+;;;###autoload
+(autoload-coding-system 'iso-latin-4-with-esc '(require 'iso-with-esc))
+
+(make-coding-system
+ 'iso-latin-9-with-esc 'iso2022
+ "ISO 4873 conforming 8-bit code (ASCII + Latin 9; aka Latin-1 with Euro)"
+ '(mnemonic "MIME/Ltn-9" ; bletch
+ eol-type nil
+ charset-g0 ascii
+ charset-g1 latin-iso8859-15
+ charset-g2 t
+ charset-g3 t))
+
+;;;###autoload
+(autoload-coding-system 'iso-latin-9-with-esc '(require 'iso-with-esc))
+
+(make-coding-system
+ 'iso-latin-10-with-esc 'iso2022 "MIME ISO-8859-16"
+ '(charset-g0 ascii
+ charset-g1 latin-iso8859-16
+ charset-g2 t ; grrr
+ charset-g3 t ; grrr
+ mnemonic "MIME/Ltn-10"))
+
+;;;###autoload
+(autoload-coding-system 'iso-latin-10-with-esc '(require 'iso-with-esc))
+
+(make-coding-system
+ 'iso-latin-5-with-esc 'iso2022 "ISO-8859-9 (Latin-5)"
+ '(charset-g0 ascii
+ charset-g1 latin-iso8859-9
+ charset-g2 t
+ charset-g3 t
+ mnemonic "MIME/Ltn-5"))
+
+;;;###autoload
+(autoload-coding-system 'iso-latin-5-with-esc '(require 'iso-with-esc))
+
+(make-coding-system
+ 'cyrillic-iso-8bit-with-esc 'iso2022
+ "ISO-8859-5 (Cyrillic)"
+ '(charset-g0 ascii
+ charset-g1 cyrillic-iso8859-5
+ charset-g2 t
+ charset-g3 t
+ mnemonic "ISO8/Cyr"))
+
+;;;###autoload
+(autoload-coding-system 'cyrillic-iso-8bit-with-esc '(require
'iso-with-esc))
+
+(make-coding-system
+ 'hebrew-iso-8bit-with-esc 'iso2022
+ "ISO-8859-8 (Hebrew)"
+ '(charset-g0 ascii
+ charset-g1 hebrew-iso8859-8
+ charset-g2 t
+ charset-g3 t
+ no-iso6429 t
+ mnemonic "MIME/Hbrw"))
+
+;;;###autoload
+(autoload-coding-system 'hebrew-iso-8bit-with-esc '(require 'iso-with-esc))
+
--
¿Dónde estará ahora mi sobrino Yoghurtu Nghé, que tuvo que huir
precipitadamente de la aldea por culpa de la escasez de rinocerontes?
_______________________________________________
XEmacs-Patches mailing list
XEmacs-Patches(a)xemacs.org
http://calypso.tux.org/cgi-bin/mailman/listinfo/xemacs-patches