From 01c03043e6e93dd12570a960ca54108d543578db Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Sat, 15 Mar 2025 11:48:36 +0200 Subject: [PATCH 1/2] ; Improve documentation of 'gui-get-selection' use on X * doc/lispref/frames.texi (Window System Selections): * lisp/select.el (gui-get-selection): Suggest to use an explicit DATA-TYPE when calling 'gui-get-selection'. --- doc/lispref/frames.texi | 10 ++++++++-- lisp/select.el | 13 +++++++++---- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/doc/lispref/frames.texi b/doc/lispref/frames.texi index 39bfed48e4e..bc7a7e6c7c7 100644 --- a/doc/lispref/frames.texi +++ b/doc/lispref/frames.texi @@ -4079,8 +4079,14 @@ programs. It takes two optional arguments, @var{type} and The @var{data-type} argument specifies the form of data conversion to use, to convert the raw data obtained from another program into Lisp -data. @xref{X Selections}, for an enumeration of data types valid under -X, and @pxref{Other Selections} for those elsewhere. +data. It defaults to @code{STRING}. @xref{X Selections}, for an +enumeration of data types valid on X, and @pxref{Other Selections} for +those elsewhere. On X Window system, we recommend to always specify a +particular @var{data-type}, especially if the selection is expected to +be non-ASCII text (in which case Lisp programs should prefer +@code{UTF8_STRING} as the value of @var{data-type}). This is because +the default @var{data-type} value, @code{STRING}, can only support +Latin-1 text, which in many cases is nowadays inadequate. @end defun @defopt selection-coding-system diff --git a/lisp/select.el b/lisp/select.el index d8e97f33001..59eedc79263 100644 --- a/lisp/select.el +++ b/lisp/select.el @@ -372,10 +372,15 @@ all upper-case names. The most often used ones, in addition to `PRIMARY', are `SECONDARY' and `CLIPBOARD'. DATA-TYPE is usually `STRING', but can also be one of the symbols -in `selection-converter-alist', which see. Window systems other -than X usually support only a small subset of these symbols, in -addition to `STRING'; MS-Windows supports `TARGETS', which reports -the formats available in the clipboard if TYPE is `CLIPBOARD'." +in `selection-converter-alist', which see. On X, we recommend +to always use a specific DATA-TYPE expected from the selection +owner. In particular, if the data is expected to be non-ASCII +text, in many cases using \\='UTF8_STRING is the most reasonable +value for DATA-TYPE. + +Window systems other than X usually support only a small subset of +these symbols, in addition to `STRING'; MS-Windows supports `TARGETS', +which reports the formats available in the clipboard if TYPE is `CLIPBOARD'." (let ((data (gui-backend-get-selection (or type 'PRIMARY) (or data-type 'STRING)))) (when (and (stringp data) From 1a8fbf69e3378996e633cf299b6a2d0716722d86 Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Sat, 15 Mar 2025 13:42:12 +0200 Subject: [PATCH 2/2] Fix 'whitespace-mode' in CJK locales * lisp/international/characters.el (ambiguous-width-chars): Remove U+00A4 and U+00B7 from the list of ambiguous-width characters. (cjk-ambiguous-chars-are-wide): Doc fix. (Bug#76852) --- lisp/international/characters.el | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lisp/international/characters.el b/lisp/international/characters.el index 318957c15b9..7be8bf32a93 100644 --- a/lisp/international/characters.el +++ b/lisp/international/characters.el @@ -1397,12 +1397,14 @@ with L, LRE, or LRO Unicode bidi character type.") ;; A: East Asian "Ambiguous" characters. (let ((l '((#x00A1 . #x00A1) - (#x00A4 . #x00A4) + ; (#x00A4 . #x00A4) whitespace-mode uses this (#x00A7 . #x00A8) (#x00AA . #x00AA) (#x00AD . #x00AE) (#x00B0 . #x00B4) - (#x00B6 . #x00BA) + ; (#x00B6 . #x00BA) whitespace-mode uses U+00B7 + (#x00B6 . #x00B6) + (#x00B8 . #x00BA) (#x00BC . #x00BF) (#x00C6 . #x00C6) (#x00D0 . #x00D0) @@ -1620,6 +1622,10 @@ fonts being used. In some CJK locales the fonts are set so that these characters are displayed as full-width. This setting is most important for text-mode frames, because there Emacs cannot access the metrics of the fonts used by the console or the terminal emulator. +You should configure the terminal emulator to behave consistently +with the value of this option, by making sure it dispays ambiguous-width +characters as half-width or full-width, depending on the value of this +option. Do not set this directly via `setq'; instead, use `setopt' or the Customize commands. Alternatively, call `update-cjk-ambiguous-char-widths'