(when coding-system
(prefer-coding-system coding-system)
- (setq locale-coding-system coding-system))))
+ (setq locale-coding-system coding-system))
+ (when (get-language-info current-language-environment 'coding-priority)
+ (let ((codeset (locale-info 'codeset))
+ (coding-system (car (coding-system-priority-list))))
+ (when codeset
+ (let ((cs (coding-system-aliases coding-system))
+ result)
+ (while (and cs (not result))
+ (setq result
+ (locale-charset-match-p (symbol-name (pop cs))
+ (locale-info 'codeset))))
+ (unless result
+ (message "Warning: Default coding system `%s' disagrees with
+system codeset `%s' for this locale." coding-system codeset))))))))
- ;; On Windows, override locale-coding-system, keyboard-coding-system,
- ;; selection-coding-system with system codepage.
+ ;; On Windows, override locale-coding-system,
+ ;; keyboard-coding-system with system codepage. Note:
+ ;; selection-coding-system is already set in w32select.c.
(when (boundp 'w32-ansi-code-page)
(let ((code-page-coding (intern (format "cp%d" w32-ansi-code-page))))
(when (coding-system-p code-page-coding)
for (i = from; i < to; i++)
{
- QUIT;
+ int this_shadowed = 0;
+ int range_beg, range_end;
+ Lisp_Object val;
- if (CHAR_TABLE_P (vector))
- {
- if (char_table_depth == 0 && i >= CHAR_TABLE_SINGLE_BYTE_SLOTS)
- complete_char = 0;
+ QUIT;
- if (i >= CHAR_TABLE_SINGLE_BYTE_SLOTS
- && !CHARSET_DEFINED_P (i - 128))
- continue;
+ starting_i = i;
- definition
- = get_keyelt (XCHAR_TABLE (vector)->contents[i], 0);
- }
+ if (CHAR_TABLE_P (vector))
+ val = char_table_ref_and_range (vector, i, &range_beg, &i);
else
- definition = get_keyelt (AREF (vector, i), 0);
+ val = AREF (vector, i);
+ definition = get_keyelt (val, 0);
if (NILP (definition)) continue;
elt_describer will take care of spacing out far enough
for alignment purposes. */
(*elt_describer) (definition, args);
+
+ if (this_shadowed)
+ {
+ SET_PT (PT - 1);
+ insert_string (" (binding currently shadowed)");
+ SET_PT (PT + 1);
+ }
}
- /* For (sub) char-table, print `defalt' slot at last. */
- if (CHAR_TABLE_P (vector) && !NILP (XCHAR_TABLE (vector)->defalt))
+ if (CHAR_TABLE_P (vector) && ! NILP (XCHAR_TABLE (vector)->defalt))
{
- insert (" ", char_table_depth * 2);
- insert_string ("<<default>>");
+ if (!NILP (elt_prefix))
+ insert1 (elt_prefix);
+ insert ("default", 7);
(*elt_describer) (XCHAR_TABLE (vector)->defalt, args);
}
if (require_decoding)
{
- int bufsize;
- unsigned char *buf;
struct coding_system coding;
+ Lisp_Object coding_system = Qnil;
+
+ /* `next-selection-coding-system' should override everything,
+ even when the locale passed by the system disagrees. The
+ only exception is when `next-selection-coding-system'
+ requested CF_UNICODETEXT and we couldn't get that. */
+ if (use_configured_coding_system
+ && !NILP (Vnext_selection_coding_system))
+ coding_system = Vnext_selection_coding_system;
+
+ /* If we have CF_TEXT or CF_OEMTEXT, we want to check out
+ CF_LOCALE, too. */
+ else if (actual_clipboard_type != CF_UNICODETEXT)
+ {
+ HGLOBAL hlocale;
+ LCID lcid = DEFAULT_LCID;
+ UINT cp;
+
+ /* Documentation says that the OS always generates
+ CF_LOCALE info automatically, so the locale handle
+ should always be present. Fact is that this is not
+ always true on 9x ;-(. */
+ hlocale = GetClipboardData (CF_LOCALE);
+ if (hlocale != NULL)
+ {
+ const LCID * lcid_ptr;
+ lcid_ptr = (const LCID *) GlobalLock (hlocale);
+ if (lcid_ptr != NULL)
+ {
+ lcid = *lcid_ptr;
+ GlobalUnlock (hlocale);
+ }
+
+ /* 9x has garbage as the sort order (to be exact there
+ is another instance of the language id in the upper
+ word). We don't care about sort order anyway, so
+ we just filter out the unneeded mis-information to
+ avoid irritations. */
+ lcid = MAKELCID (LANGIDFROMLCID (lcid), SORT_DEFAULT);
+ }
+
+ /* If we are using fallback from CF_UNICODETEXT, we can't
+ use the configured coding system. Also we don't want
+ to use it, if the system has supplied us with a locale
+ and it is not just the system default. */
+ if (!use_configured_coding_system || lcid != DEFAULT_LCID)
+ {
+ cp = cp_from_locale (lcid, actual_clipboard_type);
+ /* If it's just our current standard setting anyway,
+ use the coding system that the user has selected.
+ Otherwise create a new spec to match the locale
+ that was specified by the other side or the
+ system. */
+ if (!use_configured_coding_system || cp != cfg_codepage)
+ coding_system = coding_from_cp (cp);
+ }
+ }
+
+ if (NILP (coding_system))
+ coding_system = Vselection_coding_system;
+ Vnext_selection_coding_system = Qnil;
- if (NILP (Vnext_selection_coding_system))
- Vnext_selection_coding_system = Vselection_coding_system;
- setup_coding_system
- (Fcheck_coding_system (Vnext_selection_coding_system), &coding);
+ setup_coding_system (Fcheck_coding_system (coding_system), &coding);
coding.src_multibyte = 0;
coding.dst_multibyte = 1;
- Vnext_selection_coding_system = Qnil;
coding.mode |= CODING_MODE_LAST_BLOCK;
- /* We explicitely disable composition handling because
+ /* We explicitly disable composition handling because
selection data should not contain any composition
sequence. */
- coding.composing = COMPOSITION_DISABLED;
+ coding.common_flags &= ~CODING_ANNOTATION_MASK;
+ /* Force DOS line-ends. */
+ coding.eol_type = CODING_EOL_CRLF;
+
- bufsize = decoding_buffer_size (&coding, nbytes);
- buf = (unsigned char *) xmalloc (bufsize);
- decode_coding (&coding, src, buf, nbytes, bufsize);
- Vlast_coding_system_used = coding.symbol;
- ret = make_string_from_bytes ((char *) buf,
+ coding.dst_bytes = nbytes * 2;
+ coding.destination = (unsigned char *) xmalloc (coding.dst_bytes);
+ decode_coding_c_string (&coding, src, nbytes, Qnil);
+ Vlast_coding_system_used = CODING_ID_NAME (coding.id);
+ ret = make_string_from_bytes ((char *) coding.destination,
coding.produced_char, coding.produced);
- xfree (buf);
- if (SYMBOLP (coding.post_read_conversion)
- && !NILP (Ffboundp (coding.post_read_conversion)))
- ret = run_pre_post_conversion_on_str (ret, &coding, 0);
+ xfree (coding.destination);
}
else
{
don't have corresponding multibyte char code are also
translated to octal form. */
else if ((it->c < ' '
- && (it->area != TEXT_AREA
- /* In mode line, treat \n like other crl chars. */
- || (it->c != '\t'
- && it->glyph_row && it->glyph_row->mode_line_p)
- || (it->c != '\n' && it->c != '\t')))
- || (it->multibyte_p
- ? ((it->c >= 127
- && it->len == 1)
- || !CHAR_PRINTABLE_P (it->c)
+ ? (it->area != TEXT_AREA
+ /* In mode line, treat \n, \t like other crl chars. */
- || (it->c != '\n'
++ || (it->c != '\t'
+ && it->glyph_row && it->glyph_row->mode_line_p)
+ || (it->c != '\n' && it->c != '\t'))
+ : (it->multibyte_p
+ ? (!CHAR_PRINTABLE_P (it->c)
|| (!NILP (Vshow_nonbreak_escape)
- && (it->c == 0x8ad || it->c == 0x8a0)))
+ && (it->c == 0xA0 /* NO-BREAK SPACE */
+ || it->c == 0xAD /* SOFT HYPHEN */)))
: (it->c >= 127
- && (!unibyte_display_via_language_environment
- || it->c == unibyte_char_to_multibyte (it->c)))))
+ && (! unibyte_display_via_language_environment
+ || (UNIBYTE_CHAR_HAS_MULTIBYTE_P (it->c)))))))
{
/* IT->c is a control character which must be displayed
either as '\003' or as `^C' where the '\\' and '^'