Subject: bug#5803: 23.1.94; Using tq-enqueue in timer messes with keystroke echoing

From: David Engster <[email-masked]>
Date: Tue, 30 Mar 2010 00:54:11 +0200

This bug report will be sent to the Free Software Foundation,
not to your local site managers!
Please write in English if possible, because the Emacs maintainers
usually do not have translators to read other languages for them.

Your bug report will be posted to the [email-masked] mailing list,
and to the gnu.emacs.bug news group.

Please describe exactly what actions triggered the bug
and the precise symptoms of the bug.  If you can, give
a recipe starting from `emacs -Q':

When using `tq-enqueue' in a timer, the keystroke echoing in the
echo area becomes weird or is completely invisible.  You should be able
to reproduce this as follows:

* emacs -Q

* Evaluate the following:

(setq proc (start-process "shell" (get-buffer-create "*process*") "/bin/sh"))
(setq mytq (tq-create proc))
(defun send-test ()
  (tq-enqueue mytq "echo TEST\n" "TEST[^0]*" nil nil))
(setq timer (run-with-timer 1 1 'send-test))

* Now hit 'C-x' and wait a second.

* The string "C-x-" should appear in the echo area, but nothing can be
  seen.

* Hit "C-g". (The message "C-x C-g is undefined" appears, which is
  expected.)

* Now evaluate

(cancel-timer timer)
(setq timer (run-with-timer 1 2 'send-test))

* Wait a few seconds, now again hit "C-x" and watch the echo area.

* In seemingly random succession, the strings "C-x", " C-x" and the
  empty string appear, with a few seconds time in between.

* Evaluating (cancel-timer timer) will restore normal behavior.

If Emacs crashed, and you have the Emacs process in the gdb debugger,
please include the output from the following gdb commands:
    `bt full' and `xbacktrace'.
For information about debugging Emacs, please read the file
/opt/emacs/share/emacs/23.1.94/etc/DEBUG.

In GNU Emacs 23.1.94.1 (i686-pc-linux-gnu, GTK+ Version 2.18.3)
 of 2010-03-30 on void
Windowing system distributor `The X.Org Foundation', version 11.0.10604000
configured using `configure  '--prefix=/opt/emacs''

Important settings:
  value of $LC_ALL: nil
  value of $LC_COLLATE: nil
  value of $LC_CTYPE: nil
  value of $LC_MESSAGES: nil
  value of $LC_MONETARY: nil
  value of $LC_NUMERIC: nil
  value of $LC_TIME: nil
  value of $LANG: en_US.UTF-8
  value of $XMODIFIERS: nil
  locale-coding-system: utf-8-unix
  default enable-multibyte-characters: t

Major mode: Emacs-Lisp

Minor modes in effect:
  tooltip-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  transient-mark-mode: t

Recent input:
M-x v e r s i o n <return> C-x C-f [ r p c y <backspace> 
<backspace> <backspace> <backspace> <backspace> p r 
o c <tab> <return> <down> <down> <down> <down> <down> 
<down> C-k C-k <down> <down> <down> <up> <up> <down> 
<down> <down> <down> <right> <right> <left> <left> 
<up> <up> <up> <up> <up> <left> C-x C-e <down> C-x 
C-e <down> <down> C-e C-x C-e <down> C-x C-e <down> 
C-e C-x C-g <down> <up> C-x C-e <down> <down> C-x C-g 
<up> <up> <up> <down> <down> <down> <left> C-x C-e 
<up> <up> <down> <right> <right> <right> <right> <right> 
<right> <right> <right> <right> <backspace> 2 C-e C-x 
C-e <down> <down> C-x <left> C-x C-x b C-x b <left> 
<return> <left> C-x C-e <up> <up> <down> <right> <right> 
<right> <right> <right> <right> <right> <right> <right> 
<backspace> 3 C-e C-x C-e <down> C-x C-g M-x r e p 
o <tab> r <tab> <return>

Recent messages:
(nil #<process shell> . #<buffer  tq-temp-shell>)
send-test
nil
[nil 19377 10445 698196 1 send-test nil nil]
nil
[nil 19377 10458 258144 2 send-test nil nil]
exchange-point-and-mark: No mark set in this buffer
nil
[nil 19377 10482 122182 3 send-test nil nil]
Making completion list...

Load-path shadows:
None found.

Features:
(shadow sort mail-extr message sendmail regexp-opt ecomplete rfc822 mml
mml-sec password-cache mm-decode mm-bodies mm-encode mailcap mail-parse
rfc2231 rfc2047 rfc2045 qp ietf-drums mailabbrev nnheader gnus-util
netrc time-date mm-util mail-prsvr gmm-utils wid-edit mailheader canlock
sha1 hex-util hashcash mail-utils emacsbug help-mode easymenu view tq
tooltip ediff-hook vc-hooks lisp-float-type mwheel x-win x-dnd
font-setting tool-bar dnd fontset image fringe lisp-mode register page
menu-bar rfn-eshadow timer select scroll-bar mldrag mouse jit-lock
font-lock syntax facemenu font-core frame cham georgian utf-8-lang
misc-lang vietnamese tibetan thai tai-viet lao korean japanese hebrew
greek romanian slovak czech european ethiopic indian cyrillic chinese
case-table epa-hook jka-cmpr-hook help simple abbrev loaddefs button
minibuffer faces cus-face files text-properties overlay md5 base64
format env code-pages mule custom widget hashtable-print-readable
backquote make-network-process dbusbind system-font-setting
font-render-setting gtk x-toolkit x multi-tty emacs)