comparison src/charset.c @ 101778:33994495e60c

(Fchar_charset): New optional arg restriction.
author Kenichi Handa <handa@m17n.org>
date Wed, 04 Feb 2009 01:55:07 +0000
parents e038c1a8307c
children d05149e3855d
comparison
equal deleted inserted replaced
101777:99033eb8c94c 101778:33994495e60c
2096 } 2096 }
2097 return Fcons (CHARSET_NAME (charset), val); 2097 return Fcons (CHARSET_NAME (charset), val);
2098 } 2098 }
2099 2099
2100 2100
2101 DEFUN ("char-charset", Fchar_charset, Schar_charset, 1, 1, 0, 2101 DEFUN ("char-charset", Fchar_charset, Schar_charset, 1, 2, 0,
2102 doc: /* Return the charset of highest priority that contains CH. */) 2102 doc: /* Return the charset of highest priority that contains CH.
2103 (ch) 2103 If optional 2nd arg RESTRICTION is non-nil, it is a list of charsets
2104 Lisp_Object ch; 2104 from which to find the charset. It may also be a coding system. In
2105 that case, find the charset from what supported by that coding system. */)
2106 (ch, restriction)
2107 Lisp_Object ch, restriction;
2105 { 2108 {
2106 struct charset *charset; 2109 struct charset *charset;
2107 2110
2108 CHECK_CHARACTER (ch); 2111 CHECK_CHARACTER (ch);
2109 charset = CHAR_CHARSET (XINT (ch)); 2112 if (NILP (restriction))
2113 charset = CHAR_CHARSET (XINT (ch));
2114 else
2115 {
2116 Lisp_Object charset_list;
2117
2118 if (CONSP (restriction))
2119 {
2120 for (charset_list = Qnil; CONSP (restriction);
2121 restriction = XCDR (restriction))
2122 {
2123 int id;
2124
2125 CHECK_CHARSET_GET_ID (XCAR (restriction), id);
2126 charset_list = Fcons (make_number (id), charset_list);
2127 }
2128 charset_list = Fnreverse (charset_list);
2129 }
2130 else
2131 charset_list = coding_system_charset_list (restriction);
2132 charset = char_charset (XINT (ch), charset_list, NULL);
2133 if (! charset)
2134 return Qnil;
2135 }
2110 return (CHARSET_NAME (charset)); 2136 return (CHARSET_NAME (charset));
2111 } 2137 }
2112 2138
2113 2139
2114 DEFUN ("charset-after", Fcharset_after, Scharset_after, 0, 1, 0, 2140 DEFUN ("charset-after", Fcharset_after, Scharset_after, 0, 1, 0,