- Lisp_Object selection = assq_no_quit (QCLIPBOARD, Vselection_alist);
- if (NILP (selection)) abort ();
- selection = XCDR (selection);
- if (!STRINGP (selection)) abort ();
+ Lisp_Object selection = select_convert_out (QCLIPBOARD, Qnil, Qnil);
+
+ /* Whichever lazy git wrote this originally just called abort()
+ when anything didn't go their way... */
+
+ /* Try some other text types */
+ if (NILP (selection))
+ selection = select_convert_out (QCLIPBOARD, QSTRING, Qnil);
+ if (NILP (selection))
+ selection = select_convert_out (QCLIPBOARD, QTEXT, Qnil);
+ if (NILP (selection))
+ selection = select_convert_out (QCLIPBOARD, QCOMPOUND_TEXT, Qnil);
+
+ if (CONSP (selection) && SYMBOLP (XCAR (selection))
+ && (EQ (XCAR (selection), QSTRING)
+ || EQ (XCAR (selection), QTEXT)
+ || EQ (XCAR (selection), QCOMPOUND_TEXT)))
+ selection = XCDR (selection);
+
+ if (NILP (selection))
+ signal_error (Qselection_conversion_error,
+ build_string ("no selection"));
+
+ if (!STRINGP (selection))
+ signal_error (Qselection_conversion_error,
+ build_string ("couldn't convert selection to string"));
+
+