Subject: 26.2; OSC 52 paste in term/xterm.el not working

From: [email-masked] (Daniel Eklöf)
Date: Wed, 31 Jul 2019 18:57:32 +0200

I'm trying to use the OSC 52 paste feature of term/xterm.el. There's a
comment in term/xterm.el that says it has to be explicitly enabled.

I did so by adding 'getSelection' to 'xterm-extra-capabilities'.

I have tried this in xterm-347, and in my own terminal emulator. Now,
when pasting, I see the OSC 52 escape sequence being sent to the
terminal, and Emacs seems to get the reply, sort of.

In xterm, nothing appears to happen, except that the modeline quickly
flashes "Quit". Please note that xterm *is* sending the reply (verified
by manually sending the OSC 52 request). There's also no timeout in
Emacs so I'm confident it did read the reply.

In my own terminal emulator, Emacs seems to be stuck in a keyboard input
sequence; the modeline shows

  "C-y <base64 encoded clipboard data> ESC \-".

The most likely reason for the difference in observed behavior is that
xterm terminates the OSC 52 reply with BEL (it echoes the terminator
from the OSC 52 request, which in Emacs' case is BEL), while my terminal
emulator terminates with an ST sequence, "\e\\".

Other than the terminator, the byte sequence sent from my terminal
emulator is exactly the same as sent by xterm.

Note: this is on the stable 26.2 release. But the responsible function,
term/xterm.el:gui-backend-get-selection, appears to be identical in
latest master.

Have I configured something wrong? Or is this a bug?

Regards,
Daniel

In GNU Emacs 26.2 (build 1, x86_64-pc-linux-gnu)
 of 2019-05-25 built on svetlemodry
System Description:	Arch Linux

Recent messages:
For information about GNU Emacs and the GNU system, type C-h C-a.
Mark set [2 times]
Quit [2 times]
Making completion list... [2 times]

Configured using:
 'configure --prefix=/usr --sysconfdir=/etc --libexecdir=/usr/lib
 --localstatedir=/var --without-x --without-sound --with-modules
 'CFLAGS=-march=x86-64 -mtune=generic -O2 -pipe -fno-plt'
 CPPFLAGS=-D_FORTIFY_SOURCE=2
 LDFLAGS=-Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now'

Configured features:
DBUS NOTIFY ACL GNUTLS LIBXML2 ZLIB MODULES THREADS LIBSYSTEMD

Important settings:
  value of $LC_CTYPE: en_US.UTF-8
  value of $LC_MESSAGES: en_US.UTF-8
  value of $LANG: sv_SE.UTF-8
  locale-coding-system: utf-8-unix

Major mode: Lisp Interaction

Minor modes in effect:
  show-paren-mode: t
  display-line-numbers-mode: t
  which-function-mode: t
  global-whitespace-mode: t
  global-semanticdb-minor-mode: t
  global-semantic-idle-scheduler-mode: t
  global-semantic-idle-local-symbol-highlight-mode: t
  global-semantic-decoration-mode: t
  global-semantic-highlight-func-mode: t
  semantic-mode: t
  global-company-mode: t
  company-mode: t
  global-flycheck-mode: t
  flycheck-mode: t
  winner-mode: t
  cl-old-struct-compat-mode: t
  xterm-mouse-mode: t
  tooltip-mode: t
  global-eldoc-mode: t
  eldoc-mode: t
  electric-indent-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  column-number-mode: t
  line-number-mode: t
  transient-mark-mode: t

Load-path shadows:
/usr/share/emacs/site-lisp/flim/md4 hides /usr/share/emacs/26.2/lisp/md4
/usr/share/emacs/site-lisp/flim/hex-util hides /usr/share/emacs/26.2/lisp/hex-util
/usr/share/emacs/site-lisp/flim/ntlm hides /usr/share/emacs/26.2/lisp/net/ntlm
/usr/share/emacs/site-lisp/flim/hmac-def hides /usr/share/emacs/26.2/lisp/net/hmac-def
/usr/share/emacs/site-lisp/flim/sasl-digest hides /usr/share/emacs/26.2/lisp/net/sasl-digest
/usr/share/emacs/site-lisp/flim/sasl hides /usr/share/emacs/26.2/lisp/net/sasl
/usr/share/emacs/site-lisp/flim/hmac-md5 hides /usr/share/emacs/26.2/lisp/net/hmac-md5
/usr/share/emacs/site-lisp/flim/sasl-ntlm hides /usr/share/emacs/26.2/lisp/net/sasl-ntlm
/usr/share/emacs/site-lisp/flim/sasl-cram hides /usr/share/emacs/26.2/lisp/net/sasl-cram

Features:
(shadow sort flyspell ispell mail-extr emacsbug add-log term/xterm xterm
paren display-line-numbers which-func imenu elec-pair company-oddmuse
company-keywords company-etags etags xref project company-gtags
company-dabbrev-code company-dabbrev company-files company-capf
company-cmake company-xcode company-clang company-semantic company-eclim
company-template company-bbdb .emacs systemd url-parse url-vars
conf-mode mu4e-alert time ht s alert notifications dbus xml mu4e desktop
frameset mu4e-speedbar speedbar sb-image dframe mu4e-main mu4e-view
cal-menu calendar cal-loaddefs thingatpt browse-url comint ansi-color
gnus-art mm-uu mml2015 mm-view mml-smime smime dig mailcap gnus-sum
gnus-group gnus-undo gnus-start gnus-cloud nnimap nnmail mail-source tls
gnutls utf7 netrc nnoo parse-time gnus-spec gnus-int gnus-range gnus-win
gnus nnheader wid-edit mu4e-headers mu4e-compose mu4e-context mu4e-draft
mu4e-actions ido rfc2368 smtpmail auth-source sendmail mu4e-mark
mu4e-message flow-fill mu4e-proc mu4e-utils doc-view jka-compr
image-mode mu4e-lists mu4e-vars message rmc puny dired dired-loaddefs
format-spec rfc822 mml mml-sec password-cache gnus-util rmail tool-bar
rmail-loaddefs time-date mm-decode mm-bodies mm-encode mail-parse
rfc2231 rfc2047 rfc2045 mm-util ietf-drums mail-prsvr mailabbrev
mail-utils gmm-utils mailheader hl-line fringe mu4e-meta whitespace
midnight semantic/bovine/gcc semantic/dep semantic/db-mode semantic/db
eieio-base semantic/idle semantic/format ezimage image semantic/ctxt
semantic/decorate/mode semantic/tag-ls semantic/find semantic/decorate
pulse semantic/util-modes semantic/util semantic semantic/tag
semantic/lex semantic/fw eieio eieio-core cl-macs eieio-loaddefs
mode-local cedet company pcase flycheck regexp-opt cl-extra json map
find-func help-mode rx easymenu subr-x seq byte-opt gv bytecomp
byte-compile cconv dash edmacro kmacro windmove winner ring cl-seq
smart-mode-line-dark-theme smart-mode-line advice rich-minority
cl-loaddefs cl-lib zenburn-theme epa derived epg epg-config xt-mouse
disp-table mule-util tooltip eldoc electric uniquify ediff-hook vc-hooks
lisp-float-type tabulated-list replace newcomment text-mode elisp-mode
lisp-mode prog-mode register page menu-bar rfn-eshadow isearch timer
select mouse jit-lock font-lock syntax facemenu font-core
term/tty-colors frame cl-generic cham georgian utf-8-lang misc-lang
vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms cp51932
hebrew greek romanian slovak czech european ethiopic indian cyrillic
chinese composite charscript charprop case-table epa-hook jka-cmpr-hook
help simple abbrev obarray minibuffer cl-preloaded nadvice loaddefs
button faces cus-face macroexp files text-properties overlay sha1 md5
base64 format env code-pages mule custom widget hashtable-print-readable
backquote threads dbusbind inotify multi-tty make-network-process emacs)

Memory information:
((conses 16 260142 13833)
 (symbols 48 36419 1)
 (miscs 40 82 206)
 (strings 32 77860 5282)
 (string-bytes 1 2421895)
 (vectors 16 34057)
 (vector-slots 8 684478 5244)
 (floats 8 283 667)
 (intervals 56 386 104)
 (buffers 992 13))

-- 
Daniel