GNU bug report logs - #36836
Tmux and Focus-In Events

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: emacs; Reported by: Gustaf Waldemarson <gustaf.waldemarson@HIDDEN>; dated Mon, 29 Jul 2019 13:52:01 UTC; Maintainer for emacs is bug-gnu-emacs@HIDDEN.

Message received at submit <at>

Received: (at submit) by; 29 Jul 2019 13:51:07 +0000
From debbugs-submit-bounces <at> Mon Jul 29 09:51:07 2019
Received: from localhost ([]:47903
	by with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at>>)
	id 1hs63O-0006nk-J4
	for submit <at>; Mon, 29 Jul 2019 09:51:07 -0400
Received: from ([]:45847)
 by with esmtp (Exim 4.84_2)
 (envelope-from <gustaf.waldemarson@HIDDEN>) id 1hs63N-0006nd-AA
 for submit <at>; Mon, 29 Jul 2019 09:51:05 -0400
Received: from ([2001:470:142:3::10]:47256)
 by with esmtp (Exim 4.86_2)
 (envelope-from <gustaf.waldemarson@HIDDEN>) id 1hs63L-0008EB-6p
 for bug-gnu-emacs@HIDDEN; Mon, 29 Jul 2019 09:51:05 -0400
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on
X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,FREEMAIL_FROM,
 URIBL_BLOCKED autolearn=disabled version=3.3.2
Received: from Debian-exim by with spam-scanned (Exim 4.71)
 (envelope-from <gustaf.waldemarson@HIDDEN>) id 1hs63J-0004gd-F1
 for bug-gnu-emacs@HIDDEN; Mon, 29 Jul 2019 09:51:03 -0400
Received: from ([2607:f8b0:4864:20::343]:41588)
 by with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16)
 (Exim 4.71) (envelope-from <gustaf.waldemarson@HIDDEN>)
 id 1hs63J-0004gC-8v
 for bug-gnu-emacs@HIDDEN; Mon, 29 Jul 2019 09:51:01 -0400
Received: by with SMTP id o101so62577647ota.8
 for <bug-gnu-emacs@HIDDEN>; Mon, 29 Jul 2019 06:51:00 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;; s=20161025;
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;; s=20161025;
X-Gm-Message-State: APjAAAWQ2gsqOMH9Cj38dcXJiyl2uWOQF6nf05InUinIt3FB9v3YJtU+
X-Google-Smtp-Source: APXvYqyrzK5uSRrl2mDuF6leSxUhL2XrBstB6h9jhRc3KSwC0v8ThII6qluMgd2yPs5WphxINZ63rE6djrSrbOdOVm4=
X-Received: by 2002:a05:6830:95:: with SMTP id
 Mon, 29 Jul 2019 06:50:59 -0700 (PDT)
MIME-Version: 1.0
From: Gustaf Waldemarson <gustaf.waldemarson@HIDDEN>
Date: Mon, 29 Jul 2019 15:50:48 +0200
Message-ID: <CABehr5du2qwdHYxpLOSa5sd_SA91xV7LLrcK2zqt_s7hUqdVqw@HIDDEN>
Subject: Tmux and Focus-In Events
To: bug-gnu-emacs@HIDDEN
Content-Type: text/plain; charset="UTF-8"
X-detected-operating-system: by Genre and OS details not
X-Received-From: 2607:f8b0:4864:20::343
X-Spam-Score: -1.3 (-)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at>
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <>
List-Unsubscribe: <>, 
 <mailto:debbugs-submit-request <at>>
List-Archive: <>
List-Post: <mailto:debbugs-submit <at>>
List-Help: <mailto:debbugs-submit-request <at>>
List-Subscribe: <>, 
 <mailto:debbugs-submit-request <at>>
Errors-To: debbugs-submit-bounces <at>
Sender: "Debbugs-submit" <debbugs-submit-bounces <at>>
X-Spam-Score: -2.3 (--)


I noticed a rather strange and somewhat hard to track down bug that's related to
tmux and terminal focus-in events.

Using Emacs 27 and tmux 2.1: If you start tmux with the option `tmux set-option
-g focus-events on` enabled and then inside tmux start an emacsclient, e.g.,

emacs -Q --daemon=test && emacsclient --socket-name=test ."

Then Emacs starts and unexpectedly inserts the characters "[I]" in the buffer
that is opened. This only seem to happen the first time the client is started.

A quick bisection on the Emacs code-base lead me to this commit:

commit 6fdc3fac5658a7ab142c358cddd90f3db5665ef5
Author: Daniel Colascione <dancol@HIDDEN>
Date:   Fri Jun 8 22:47:27 2018 -0700
    Support terminal focus notifications

    * lisp/frame.el (handle-focus-in,handle-focus-out): Make event
    argument optional.
    (blink-cursor-check): Make sure that the current frame is a
    window-system frame before restarting the blink timer. TTY frames
    can get focus, but don't need a blink timer because the terminal
    will do the blinking.

    * lisp/term/xterm.el
    (xterm-handle-focus-in,xterm-handle-focus-out): New functions.
    (xterm-rxvt-function-map): Recognize focus notification sequences.
    (xterm--init-focus-tracking): New function.
    (terminal-init-xterm): Call it.

Apparently it seems like "\e[I" is the focus-in event, which is translated to
"[I]" by `electric-pair-mode`.

I'm not entirely sure where the bug is in this case however. Is it up to Emacs
to handle focus-in events from the terminal or is that something tmux itself
should handle in this case? Or is there some setting somewhere that should be
toggled to prevent this kind of thing from happening?

I originally observed this behavior in Konsole, but the same thing happen in
xterm itself as well, and possibly other terminal emulators.

In GNU Emacs 27.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.18.9)
 of 2019-07-29 built on E105888
Repository revision: a9593253e90aa58134833078ae1fc5505ae9f58c
Repository branch: master
System Description: Ubuntu 16.04.6 LTS

Recent messages:
Mark set
Mark set
Detected language: English [9 times]
Saving file /home/guswal01/
Wrote /home/guswal01/
Mark set [2 times]
(No changes need to be saved) [2 times]
Making completion list... [3 times]

Configured using:
 'configure --prefix=/home/guswal01/.local

Configured features:

Important settings:
  value of $LC_MONETARY: sv_SE.UTF-8
  value of $LC_NUMERIC: sv_SE.UTF-8
  value of $LC_TIME: sv_SE.UTF-8
  value of $LANG: en_US.UTF-8
  locale-coding-system: utf-8-unix

Major mode: Markdown

Minor modes in effect:
  orgtbl-mode: t
  shell-dirtrack-mode: t
  orgstruct-mode: t
  guess-language-mode: t
  poly-markdown-mode: t
  beacon-mode: t
  flyspell-mode: t
  flycheck-pos-tip-mode: t
  projectile-mode: t
  hes-mode: t
  global-linum-mode: t
  yas-global-mode: t
  yas-minor-mode: t
  global-company-mode: t
  company-mode: t
  global-anzu-mode: t
  anzu-mode: t
  perspeen-mode: t
  global-atomic-chrome-edit-mode: t
  global-undo-tree-mode: t
  undo-tree-mode: t
  which-key-mode: t
  anyclip-mode: t
  override-global-mode: t
  electric-pair-mode: t
  save-place-mode: t
  global-subword-mode: t
  subword-mode: t
  show-paren-mode: t
  winner-mode: t
  global-auto-revert-mode: t
  xterm-mouse-mode: t
  savehist-mode: t
  ido-everywhere: t
  tooltip-mode: t
  global-eldoc-mode: t
  eldoc-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tool-bar-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:
None found.

(shadow sort bbdb-message mail-extr emacsbug sendmail echistory chistory
ehelp ecb-compatibility ecb-layout ecb-create-layout ecb-compilation
ecb-common-browser ecb-navigate eieio-compat ecb-cedet-wrapper
semantic/db-mode semantic/db-find semantic/db-ref semantic/analyze
semantic/sort semantic/scope semantic/analyze/fcn semantic/db
semantic/format ezimage semantic/tag-ls semantic/find semantic/ctxt
semantic/util-modes semantic/util semantic semantic/tag semantic/lex
semantic/fw mode-local cedet ecb-mode-line ecb-face tree-buffer ecb-util
help-fns radix-tree term/tmux term/xterm xterm org-rmail org-mhe org-irc
org-info org-gnus nnir gnus-sum url url-proxy url-privacy url-expand
url-methods url-history mailcap shr svg xml dom gnus-group gnus-undo
gnus-start gnus-cloud nnimap nnmail mail-source utf7 netrc nnoo
parse-time gnus-spec gnus-int gnus-range message rfc822 mml mml-sec epa
epg epg-config mm-decode mm-bodies mm-encode mail-parse rfc2231
mailabbrev gmm-utils mailheader gnus-win gnus nnheader gnus-util rmail
rmail-loaddefs rfc2047 rfc2045 ietf-drums text-property-search
mail-utils mm-util mail-prsvr org-docview doc-view jka-compr image-mode
dired dired-loaddefs org-bibtex bibtex org-bbdb org-w3m org-table
ob-latex ob-plantuml ob-org ob-shell shell ob-gnuplot ob-python ob-ditaa
ob-dot org-element avl-tree org org-macro org-footnote org-pcomplete
pcomplete org-list org-faces org-entities time-date org-version
ob-emacs-lisp ob ob-tangle org-src ob-ref ob-lob ob-table ob-keys ob-exp
ob-comint ob-core ob-eval org-compat org-macs org-loaddefs cal-menu
calendar cal-loaddefs guess-language poly-markdown polymode derived
poly-lock polymode-base polymode-weave polymode-export polymode-compat
polymode-methods polymode-core format-spec polymode-classes eieio-custom
eieio-base smart-mode-line-dark-theme smart-mode-line rich-minority
beacon server auto-complete-config auto-complete popup form-feed paredit
nameless lisp-mnt flyspell ispell whitespace flycheck-pos-tip pos-tip
flycheck find-func rainbow-delimiters projectile grep ibuf-ext ibuffer
ibuffer-loaddefs highlight-escape-sequences linum yasnippet-snippets
yasnippet company-oddmuse company-keywords company-etags etags fileloop
generator 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 company
anzu perspeen perspeen-tab powerline powerline-separators
powerline-themes atomic-chrome websocket url-cookie url-domsuf bindat
let-alist color-theme-approximate delim-col hydra-examples windmove rect
hydra lv dap-mode dap-overlays lsp lsp-mode ewoc markdown-mode
edit-indirect color noutline outline tree-widget xref url-util spinner
pcase network-stream puny nsm rmc inline imenu ht f s em-glob esh-util
dash-functional dash flymake-proc flymake compile warnings thingatpt
project bbdb bbdb-site timezone cus-edit cus-start cus-load wid-edit
ace-link avy undo-tree diff which-key advice anyclip-mode diminish
use-package use-package-ensure use-package-delight use-package-diminish
use-package-bind-key bind-key use-package-core finder-inf
local-autoloads cwarn cc-mode cc-fonts cc-guess cc-menus cc-cmds
cc-styles cc-align cc-engine cc-vars cc-defs elec-pair saveplace
cap-words superword subword paren winner autorevert filenotify xt-mouse
tango-dark-theme savehist ido gud easy-mmode comint ansi-color ring
keybinds terminals autoinsert tex-site rx cl-extra help-mode
slime-autoloads edmacro kmacro info package easymenu browse-url
url-handlers url-parse auth-source cl-seq eieio eieio-core cl-macs
eieio-loaddefs password-cache json subr-x map url-vars seq byte-opt gv
bytecomp byte-compile cconv cl-loaddefs cl-lib tooltip eldoc electric
uniquify ediff-hook vc-hooks lisp-float-type mwheel term/x-win x-win
term/common-win x-dnd tool-bar dnd fontset image regexp-opt fringe
tabulated-list replace newcomment text-mode elisp-mode lisp-mode
prog-mode register page menu-bar rfn-eshadow isearch timer select
scroll-bar 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 lcms2 dynamic-setting
system-font-setting font-render-setting move-toolbar gtk x-toolkit x
multi-tty make-network-process emacs)

Memory information:
((conses 16 478739 54790)
 (symbols 48 43732 1)
 (strings 32 147104 5075)
 (string-bytes 1 5423337)
 (vectors 16 61266)
 (vector-slots 8 737765 36386)
 (floats 8 541 96)
 (intervals 56 2393 2891)
 (buffers 992 16)
 (heap 1024 31120 2033))

Acknowledgement sent to Gustaf Waldemarson <gustaf.waldemarson@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs@HIDDEN. Full text available.
Report forwarded to bug-gnu-emacs@HIDDEN:
bug#36836; Package emacs. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Mon, 29 Jul 2019 14:00:02 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.