]> code.delx.au - gnu-emacs/blobdiff - src/charset.c
(Basic Keyboard Macro): Make F3 and F4 the preferred
[gnu-emacs] / src / charset.c
index 121cea7521d33b2bdde63d3004c978c9a9bc6b5e..43155d2cc6535eda46cc6ce55c117a5395188d0d 100644 (file)
@@ -1,6 +1,6 @@
 /* Basic character set support.
-   Copyright (C) 2001, 2002, 2003, 2004, 2005,
-                 2006, 2007, 2008 Free Software Foundation, Inc.
+   Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007,
+     2008  Free Software Foundation, Inc.
    Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
      2005, 2006, 2007, 2008
      National Institute of Advanced Industrial Science and Technology (AIST)
 
 This file is part of GNU Emacs.
 
-GNU Emacs is free software; you can redistribute it and/or modify
+GNU Emacs 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 3, or (at your option)
-any later version.
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
 
 GNU Emacs is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -23,9 +23,7 @@ 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 GNU Emacs; see the file COPYING.  If not, write to
-the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
-Boston, MA 02110-1301, USA.  */
+along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include <config.h>
 
@@ -76,12 +74,14 @@ Lisp_Object Qascii;
 Lisp_Object Qeight_bit;
 Lisp_Object Qiso_8859_1;
 Lisp_Object Qunicode;
+Lisp_Object Qemacs;
 
 /* The corresponding charsets.  */
 int charset_ascii;
 int charset_eight_bit;
 int charset_iso_8859_1;
 int charset_unicode;
+int charset_emacs;
 
 /* The other special charsets.  */
 int charset_jisx0201_roman;
@@ -1044,7 +1044,7 @@ usage: (define-charset-internal ...)  */)
       else if (ISO_CHARSET_TABLE (2, 0, 'B') == id)
        charset_jisx0208 = id;
     }
-       
+
   if (charset.emacs_mule_id >= 0)
     {
       emacs_mule_charset[charset.emacs_mule_id] = CHARSET_FROM_ID (id);
@@ -1259,7 +1259,7 @@ Optional third argument DEUNIFY, if non-nil, means to de-unify CHARSET.  */)
 DEFUN ("get-unused-iso-final-char", Fget_unused_iso_final_char,
        Sget_unused_iso_final_char, 2, 2, 0,
        doc: /*
-Return an unused ISO final char for a charset of DIMENISION and CHARS.
+Return an unused ISO final char for a charset of DIMENSION and CHARS.
 DIMENSION is the number of bytes to represent a character: 1 or 2.
 CHARS is the number of characters in a dimension: 94 or 96.
 
@@ -1671,7 +1671,7 @@ Return nil if CODE-POINT is not valid in CHARSET.
 CODE-POINT may be a cons (HIGHER-16-BIT-VALUE . LOWER-16-BIT-VALUE).
 
 Optional argument RESTRICTION specifies a way to map the pair of CCS
-and CODE-POINT to a chracter.   Currently not supported and just ignored.  */)
+and CODE-POINT to a character.  Currently not supported and just ignored.  */)
   (charset, code_point, restriction)
      Lisp_Object charset, code_point, restriction;
 {
@@ -1701,7 +1701,7 @@ DEFUN ("encode-char", Fencode_char, Sencode_char, 2, 3, 0,
        doc: /* Encode the character CH into a code-point of CHARSET.
 Return nil if CHARSET doesn't include CH.
 
-Optional argument RESTRICTION specifies a way to map CHAR to a
+Optional argument RESTRICTION specifies a way to map CH to a
 code-point in CCS.  Currently not supported and just ignored.  */)
      (ch, charset, restriction)
      Lisp_Object ch, charset, restriction;
@@ -1813,11 +1813,14 @@ char_charset (c, charset_list, code_return)
      Lisp_Object charset_list;
      unsigned *code_return;
 {
+  int maybe_null = 0;
+
   if (NILP (charset_list))
     charset_list = Vcharset_ordered_list;
+  else
+    maybe_null = 1;
 
-  while (CONSP (charset_list)
-        && ! EQ (charset_list, Vcharset_non_preferred_head))
+  while (CONSP (charset_list))
     {
       struct charset *charset = CHARSET_FROM_ID (XINT (XCAR (charset_list)));
       unsigned code = ENCODE_CHAR (charset, c);
@@ -1829,18 +1832,22 @@ char_charset (c, charset_list, code_return)
          return charset;
        }
       charset_list = XCDR (charset_list);
+      if (c <= MAX_UNICODE_CHAR
+        && EQ (charset_list, Vcharset_non_preferred_head))
+       return CHARSET_FROM_ID (charset_unicode);
     }
-  return (c <= MAX_UNICODE_CHAR ? CHARSET_FROM_ID (charset_unicode)
+  return (maybe_null ? NULL
+         : c <= MAX_5_BYTE_CHAR ? CHARSET_FROM_ID (charset_emacs)
          : CHARSET_FROM_ID (charset_eight_bit));
 }
 
 
 DEFUN ("split-char", Fsplit_char, Ssplit_char, 1, 1, 0,
        doc:
-       /*Return list of charset and one to four position-codes of CHAR.
+       /*Return list of charset and one to four position-codes of CH.
 The charset is decided by the current priority order of charsets.
 A position-code is a byte value of each dimension of the code-point of
-CHAR in the charset.  */)
+CH in the charset.  */)
      (ch)
      Lisp_Object ch;
 {
@@ -1905,7 +1912,7 @@ Return charset of ISO's specification DIMENSION, CHARS, and FINAL-CHAR.
 
 ISO 2022's designation sequence (escape sequence) distinguishes charsets
 by their DIMENSION, CHARS, and FINAL-CHAR,
-where as Emacs distinguishes them by charset symbol.
+whereas Emacs distinguishes them by charset symbol.
 See the documentation of the function `charset-info' for the meanings of
 DIMENSION, CHARS, and FINAL-CHAR.  */)
      (dimension, chars, final_char)
@@ -1950,7 +1957,7 @@ Clear encoder and decoder of charsets that are loaded from mapfiles.  */)
 
   if (CHAR_TABLE_P (Vchar_unified_charset_table))
     {
-      Foptimize_char_table (Vchar_unified_charset_table);
+      Foptimize_char_table (Vchar_unified_charset_table, Qnil);
       Vchar_unify_table = Vchar_unified_charset_table;
       Vchar_unified_charset_table = Qnil;
     }
@@ -2037,9 +2044,18 @@ Return charset identification number of CHARSET.  */)
 void
 init_charset ()
 {
-  Vcharset_map_path
-    = Fcons (Fexpand_file_name (build_string ("charsets"), Vdata_directory),
-            Qnil);
+  Lisp_Object tempdir;
+  tempdir = Fexpand_file_name (build_string ("charsets"), Vdata_directory);
+  if (access (SDATA (tempdir), 0) < 0)
+    {
+      dir_warning ("Error: charsets directory (%s) does not exist.\n\
+Emacs will not function correctly without the character map files.\n\
+Please check your installation!\n",
+                   tempdir);
+      /* TODO should this be a fatal error?  (Bug#909)  */
+    }
+
+  Vcharset_map_path = Fcons (tempdir, Qnil);
 }
 
 
@@ -2075,6 +2091,7 @@ syms_of_charset ()
 
   DEFSYM (Qascii, "ascii");
   DEFSYM (Qunicode, "unicode");
+  DEFSYM (Qemacs, "emacs");
   DEFSYM (Qeight_bit, "eight-bit");
   DEFSYM (Qiso_8859_1, "iso-8859-1");
 
@@ -2134,7 +2151,7 @@ syms_of_charset ()
   defsubr (&Scharset_id_internal);
 
   DEFVAR_LISP ("charset-map-path", &Vcharset_map_path,
-              doc: /* *Lisp of directories to search for charset map files.  */);
+              doc: /* *List of directories to search for charset map files.  */);
   Vcharset_map_path = Qnil;
 
   DEFVAR_LISP ("charset-list", &Vcharset_list,
@@ -2156,6 +2173,9 @@ the value may be a list of mnemonics.  */);
   charset_unicode
     = define_charset_internal (Qunicode, 3, "\x00\xFF\x00\xFF\x00\x10",
                               0, MAX_UNICODE_CHAR, -1, 0, -1, 1, 0, 0);
+  charset_emacs
+    = define_charset_internal (Qemacs, 3, "\x00\xFF\x00\xFF\x00\x3F",
+                              0, MAX_5_BYTE_CHAR, -1, 0, -1, 1, 1, 0);
   charset_eight_bit
     = define_charset_internal (Qeight_bit, 1, "\x80\xFF\x00\x00\x00\x00",
                               128, 255, -1, 0, -1, 0, 1,