From: Stephane Chauveau <schauveau@nvidia.com>
To: <24652@debbugs.gnu.org>
Subject: bug#24652: 25.1.50; gui-backend-get-selection does not work in xterm fra
Date: Fri, 9 Dec 2016 10:30:58 +0100 [thread overview]
Message-ID: <584A79D2.1060202@nvidia.com> (raw)
In-Reply-To: <87vax1zdce.fsf@aol.de>
Hi,
I have the same problem and I was indeed able to fix it by replacing the
\a by \e\\
Below is my patched gui-backend-get-selection (for 25.5.1) and how I
enable
it in my .emacs.
(unless window-system
(when (string= emacs-version "25.1.1" )
;;
;; The \a used to terminate the OSC52 get-selection reply is causing
;; some issues in the current term/xterm.el implementation (emacs 25.1).
;; so avoid calling (xterm--init-activate-get-selection)
;;
;; Below is patched version of the faulty method
;;
(cl-defmethod gui-backend-get-selection
(type data-type
&context (window-system nil)
;; Only applies to terminals which have it enabled.
((terminal-parameter nil 'xterm--get-selection-PATCHED) (eql t)))
(unless (eq data-type 'STRING)
(error "Unsupported data type %S" data-type))
(let* ((screen (eq (terminal-parameter nil 'terminal-initted)
'terminal-init-screen))
(query (concat "\e]52;" (xterm--selection-char type) ";")))
(with-temp-buffer
(set-buffer-multibyte nil)
(xterm--query
(concat (when screen "\eP") query "?\e\\" (when screen "\e\\"))
(list (cons query (lambda ()
(while (let ((char (read-char)))
(unless (eq char ?\\)
(unless (eq char ?\e)
(insert char))
t))))))
'no-async)
(base64-decode-region (point-min) (point-max))
(decode-coding-region (point-min) (point-max) 'utf-8-unix t))))
;; Call this instead of xterm--init-activate-get-selection
;; to enable our patched implementation of gui-backend-get-selection
(defun xterm--init-activate-get-selection-PATCHED ()
(set-terminal-parameter nil 'xterm--get-selection-PATCHED t)
)
;; a hook that will be called at the end of the xterm initialization
(defun xterm-osc52-hook ()
"Specific configuration when running in xterm"
(message "in xterm-osc52-hook")
(xterm--init-activate-set-selection)
(xterm--init-activate-get-selection-PATCHED)
)
(add-hook 'terminal-init-xterm-hook 'xterm-osc52-hook)
) ;; end of check of emacs version
) ;; end of unless window-system
==============
It probably does not work well with Screen because \e\\ is also the DCS
terminator.
I do not use Screen but looking at the implementation of
gui-backend-set-selection, I suppose that a solution could be to split
the DSC request in two between the \e and the \\.
For instance, the line
(concat (when screen "\eP") query "?\e\\" (when screen "\e\\"))
could become
(concat (when screen "\eP") query "?\e" (when screen "\e\\\eP")
"\\" (when screen "\e\\"))
Remark: Tmux requires a different DCS format and so will not work
properly even though it is identified as Screen.
next prev parent reply other threads:[~2016-12-09 9:30 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-10-09 16:39 bug#24652: 25.1.50; gui-backend-get-selection does not work in xterm frame Olaf Rogalsky
2016-12-09 9:30 ` Stephane Chauveau [this message]
2021-02-06 12:08 ` Lars Ingebrigtsen
2021-03-12 1:51 ` Lars Ingebrigtsen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=584A79D2.1060202@nvidia.com \
--to=schauveau@nvidia.com \
--cc=24652@debbugs.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.