]> git.eshelyaron.com Git - emacs.git/commitdiff
Improve Haiku selection handling
authorPo Lu <luangruo@yahoo.com>
Mon, 14 Feb 2022 10:17:58 +0000 (10:17 +0000)
committerPo Lu <luangruo@yahoo.com>
Mon, 14 Feb 2022 10:26:29 +0000 (10:26 +0000)
* lisp/select.el (gui--selection-value-internal): Use X types on
Haiku as well.

* lisp/term/haiku-win.el (haiku--selection-type-to-mime): Update
types to correspond better with X.

* src/haikuselect.c (Fhaiku_selection_data):
(Fhaiku_selection_put): Remove a great deal of ad hoc code now
handled by the regular selection machinery.

lisp/select.el
lisp/term/haiku-win.el
src/haikuselect.c

index ca9061c0b039f4941be31852305f70f80e74b6ad..42b50c44e6c32142b31c3af9354ac602655b28ff 100644 (file)
@@ -176,7 +176,7 @@ decoded.  If `gui-get-selection' signals an error, return nil."
            (memq window-system '(x haiku))
            (eq type 'CLIPBOARD)
            (gui-backend-selection-owner-p type))
-    (let ((request-type (if (memq window-system '(x pgtk))
+    (let ((request-type (if (memq window-system '(x pgtk haiku))
                             (or x-select-request-type
                                 '(UTF8_STRING COMPOUND_TEXT STRING text/plain\;charset=utf-8))
                           'STRING))
index 4c06f7f58aaf04ff6ad9d57c784bbd306ff4b88a..c4810f116d25c5c6f0dbd647886faf7c6761831b 100644 (file)
@@ -86,7 +86,8 @@ DISPLAY may be set to the name of a display that will be initialized."
   "Convert symbolic selection type TYPE to its MIME equivalent.
 If TYPE is nil, return \"text/plain\"."
   (cond
-   ((memq type '(TEXT COMPOUND_TEXT STRING UTF8_STRING)) "text/plain")
+   ((eq type 'STRING) "text/plain;charset=iso-8859-1")
+   ((eq type 'UTF8_STRING) "text/plain")
    ((stringp type) type)
    ((symbolp type) (symbol-name type))
    (t "text/plain")))
index e65ab827c5116b393f42f96fc3279d627f47279a..65dac0e02fa4e079814d99fa2394d27bf0443331 100644 (file)
@@ -97,20 +97,12 @@ fetch.  */)
     return Qnil;
 
   Lisp_Object str = make_unibyte_string (dat, len);
-  Lisp_Object lispy_type = Qnil;
 
-  if (!strcmp (SSDATA (name), "text/utf-8") ||
-      !strcmp (SSDATA (name), "text/plain"))
-    {
-      if (string_ascii_p (str))
-       lispy_type = QSTRING;
-      else
-       lispy_type = QUTF8_STRING;
-    }
-
-  if (!NILP (lispy_type))
-    Fput_text_property (make_fixnum (0), make_fixnum (len),
-                       Qforeign_selection, lispy_type, str);
+  /* `foreign-selection' just means that the selection has to be
+     decoded by `gui-get-selection'.  It has no other meaning,
+     AFAICT.  */
+  Fput_text_property (make_fixnum (0), make_fixnum (len),
+                     Qforeign_selection, Qt, str);
 
   block_input ();
   BClipboard_free_data (dat);
@@ -125,10 +117,8 @@ DEFUN ("haiku-selection-put", Fhaiku_selection_put, Shaiku_selection_put,
 CLIPBOARD is the symbol `PRIMARY', `SECONDARY' or `CLIPBOARD'.  NAME
 is a MIME type denoting the type of the data to add.  DATA is the
 string that will be placed in the clipboard, or nil if the content is
-to be removed.  If NAME is the string "text/utf-8" or the string
-"text/plain", encode it as UTF-8 before storing it into the clipboard.
-CLEAR, if non-nil, means to erase all the previous contents of the
-clipboard.  */)
+to be removed.  CLEAR, if non-nil, means to erase all the previous
+contents of the clipboard.  */)
   (Lisp_Object clipboard, Lisp_Object name, Lisp_Object data,
    Lisp_Object clear)
 {
@@ -138,13 +128,6 @@ clipboard.  */)
     CHECK_STRING (data);
 
   block_input ();
-  /* It seems that Haiku applications counter-intuitively expect
-     UTF-8 data in both text/utf-8 and text/plain.  */
-  if (!NILP (data) && STRING_MULTIBYTE (data) &&
-      (!strcmp (SSDATA (name), "text/utf-8") ||
-       !strcmp (SSDATA (name), "text/plain")))
-    data = ENCODE_UTF_8 (data);
-
   char *dat = !NILP (data) ? SSDATA (data) : NULL;
   ptrdiff_t len = !NILP (data) ? SBYTES (data) : 0;