unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: Vincent Lefevre <vincent@vinc17.net>
Cc: 12354@debbugs.gnu.org
Subject: bug#12354: 24.2; garbage inserted at the beginning of the buffer even when xterm-extra-capabilities is t
Date: Mon, 29 Jun 2015 09:12:01 -0400	[thread overview]
Message-ID: <jwvh9pq1xdp.fsf-monnier+emacsbugs@gnu.org> (raw)
In-Reply-To: <20150629023519.GA7712@xvii.vinc17.org> (Vincent Lefevre's message of "Mon, 29 Jun 2015 04:35:19 +0200")

> In fact, reportBackground also yields the garbage problem.
> So, there's a bug here:

>     (when (memq 'reportBackground xterm-extra-capabilities)
>       (xterm--query "\e]11;?\e\\"
>                     '(("\e]11;" .  xterm--report-background-handler))))

> If I understand correctly, there's a timeout here, but since the
> feature is claimed to be supported, the timeout should be removed.

The timeout is present because we prefer having garbage in those
(presumably rare) cases where the terminal answers too late, over having
Emacs hang forever (tho it's not a hard-hang) when the terminal doesn't
understand the request.

You try the patch below, and set xterm-query-timeout to some value of
your choosing (e.g. nil).


        Stefan


diff --git a/lisp/term/xterm.el b/lisp/term/xterm.el
index 45da1bd..54c46de 100644
--- a/lisp/term/xterm.el
+++ b/lisp/term/xterm.el
@@ -688,6 +688,10 @@ string bytes that can be copied is 3/4 of this value."
           ;;(xterm--init-activate-get-selection)
           (xterm--init-activate-set-selection))))))
 
+(defvar xterm-query-timeout 2
+  "Seconds to wait for an answer from the terminal.
+Can be nil to mean \"no timeout\".")
+
 (defun xterm--query (query handlers &optional no-async)
   "Send QUERY string to the terminal and watch for a response.
 HANDLERS is an alist with elements of the form (STRING . FUNCTION).
@@ -696,7 +700,8 @@ We run the first FUNCTION whose STRING matches the input events."
   ;; rather annoying (bug#6758).  Maybe we could always use the asynchronous
   ;; approach, but it's less tested.
   ;; FIXME: Merge the two branches.
-  (if (and (input-pending-p) (not no-async))
+  (if (and (or (null xterm-query-timeout) (input-pending-p))
+           (not no-async))
       (progn
         (dolist (handler handlers)
           (define-key input-decode-map (car handler)
@@ -714,7 +719,7 @@ We run the first FUNCTION whose STRING matches the input events."
       (let ((handler (pop handlers))
             (i 0))
         (while (and (< i (length (car handler)))
-                    (let ((evt (read-event nil nil 2)))
+                    (let ((evt (read-event nil nil xterm-query-timeout)))
                       (or (eq evt (aref (car handler) i))
                           (progn (if evt (push evt unread-command-events))
                                  nil))))

> However it is not passed by default via SSH,

Ah, indeed, that's my case: I almost only use "-nw" in an SSH session.


        Stefan





  reply	other threads:[~2015-06-29 13:12 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-05 11:16 bug#12354: 24.2; garbage inserted at the beginning of the buffer even when xterm-extra-capabilities is t Vincent Lefevre
2012-09-05 16:59 ` Glenn Morris
2012-09-05 18:44   ` Vincent Lefevre
2015-05-27 11:27     ` Vincent Lefevre
2015-06-29  1:01       ` Stefan Monnier
2015-06-29  2:35         ` Vincent Lefevre
2015-06-29 13:12           ` Stefan Monnier [this message]
2015-06-29 13:47             ` Vincent Lefevre
2015-06-30 14:04               ` Stefan Monnier
2015-07-01  3:19                 ` Stefan Monnier
2015-07-01 15:01                   ` Vincent Lefevre
2015-07-02 14:49                     ` Stefan Monnier
2015-07-03  1:16                       ` Vincent Lefevre
2017-12-17  2:07                         ` Noam Postavsky
2012-09-08  9:57 ` Andreas Schwab
2012-09-08 11:00   ` Vincent Lefevre

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

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=jwvh9pq1xdp.fsf-monnier+emacsbugs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=12354@debbugs.gnu.org \
    --cc=vincent@vinc17.net \
    /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 public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).