aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/term
diff options
context:
space:
mode:
authorPo Lu2022-10-03 20:18:22 +0800
committerPo Lu2022-10-03 20:18:37 +0800
commitda02b9edadbc809b25ac83eccf64089f1cf3b160 (patch)
tree084641cd35e268b195b51ba7d09352207c52eb16 /lisp/term
parente245c4f226979ccb717cccc8f82b2b0a0f96bdac (diff)
downloademacs-da02b9edadbc809b25ac83eccf64089f1cf3b160.tar.gz
emacs-da02b9edadbc809b25ac83eccf64089f1cf3b160.zip
Fix coding systems used for X input methods
* doc/emacs/mule.texi (International): Refer to X Coding as well. (Communication Coding): Document that locale-coding-system is not always used on X to decode keyboard input. (X Coding): New node. * etc/NEWS: Announce change to input method coding resolution. * lisp/term/x-win.el (x-get-input-coding-system): New function. * src/coding.c (syms_of_coding): Update doc string of locale-coding-system. * src/xfns.c (struct x_xim_text_conversion_data) (x_xim_text_to_utf8_unix_1, x_xim_text_to_utf8_unix_2) (x_xim_text_to_utf8_unix): Accept dpyinfo. Use the coding system specified inside if possible. (xic_preedit_draw_callback): Pass dpyinfo. * src/xterm.c (handle_one_xevent): Use XIM coding system for IM input. (xim_open_dpy): Try to determine the input method coding system. (mark_xterm): Mark `xim_coding'. (syms_of_xterm): New variable `x-input-coding-system'. * src/xterm.h (struct x_display_info): New field `xim_coding'. (FRAME_X_XIM_CODING): New macro.
Diffstat (limited to 'lisp/term')
-rw-r--r--lisp/term/x-win.el22
1 files changed, 22 insertions, 0 deletions
diff --git a/lisp/term/x-win.el b/lisp/term/x-win.el
index 9d3e7803650..57c6b785e73 100644
--- a/lisp/term/x-win.el
+++ b/lisp/term/x-win.el
@@ -1613,6 +1613,28 @@ Users should not call this function; see `device-class' instead."
1613(setq x-dnd-movement-function #'x-dnd-movement) 1613(setq x-dnd-movement-function #'x-dnd-movement)
1614(setq x-dnd-unsupported-drop-function #'x-dnd-handle-unsupported-drop) 1614(setq x-dnd-unsupported-drop-function #'x-dnd-handle-unsupported-drop)
1615 1615
1616(defvar x-input-coding-function)
1617
1618(defun x-get-input-coding-system (x-locale)
1619 "Return a coding system for the locale X-LOCALE.
1620Return a coding system that is able to decode text sent with the
1621X input method locale X-LOCALE, or nil if no coding system was
1622found."
1623 (if (equal x-locale "C")
1624 ;; Treat the C locale specially, as it means "ascii" under X.
1625 'ascii
1626 (let ((locale (downcase x-locale)))
1627 (or (locale-name-match locale locale-preferred-coding-systems)
1628 (when locale
1629 (if (string-match "\\.\\([^@]+\\)" locale)
1630 (locale-charset-to-coding-system
1631 (match-string 1 locale))))
1632 (let ((language-name
1633 (locale-name-match locale locale-language-names)))
1634 (and (consp language-name) (cdr language-name)))))))
1635
1636(setq x-input-coding-function #'x-get-input-coding-system)
1637
1616(provide 'x-win) 1638(provide 'x-win)
1617(provide 'term/x-win) 1639(provide 'term/x-win)
1618 1640