GNU bug report logs - #23403
25.1.50; cua-mode does not interact with cursor-face and themes well

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: "Jeremy T. Braun" <spamprevent@HIDDEN>; dated Fri, 29 Apr 2016 18:25:03 UTC; Maintainer for emacs is bug-gnu-emacs@HIDDEN.

Message received at submit <at>

Received: (at submit) by; 29 Apr 2016 18:24:36 +0000
From debbugs-submit-bounces <at> Fri Apr 29 14:24:36 2016
Received: from localhost ([]:55747
	by with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at>>)
	id 1awD5e-00043F-TW
	for submit <at>; Fri, 29 Apr 2016 14:24:36 -0400
Received: from ([]:43789)
 by with esmtp (Exim 4.84_2)
 (envelope-from <spamprevent@HIDDEN>) id 1awD1T-0003vo-5K
 for submit <at>; Fri, 29 Apr 2016 14:20:15 -0400
Received: from Debian-exim by with spam-scanned (Exim 4.71)
 (envelope-from <spamprevent@HIDDEN>) id 1awD13-00005C-NW
 for submit <at>; Fri, 29 Apr 2016 14:20:06 -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,T_DKIM_INVALID
 autolearn=disabled version=3.3.2
Received: from ([2001:4830:134:3::11]:43813)
 by with esmtp (Exim 4.71)
 (envelope-from <spamprevent@HIDDEN>) id 1awD11-0008SF-Bz
 for submit <at>; Fri, 29 Apr 2016 14:19:49 -0400
Received: from ([2001:4830:134:3::10]:34251)
 by with esmtp (Exim 4.71)
 (envelope-from <spamprevent@HIDDEN>) id 1awD0p-0000eA-7J
 for bug-gnu-emacs@HIDDEN; Fri, 29 Apr 2016 14:19:41 -0400
Received: from Debian-exim by with spam-scanned (Exim 4.71)
 (envelope-from <spamprevent@HIDDEN>) id 1awD0a-0008FZ-Lg
 for bug-gnu-emacs@HIDDEN; Fri, 29 Apr 2016 14:19:27 -0400
Received: from ([]:58545)
 by with esmtp (Exim 4.71)
 (envelope-from <spamprevent@HIDDEN>) id 1awD0Y-0008Cy-7Q
 for bug-gnu-emacs@HIDDEN; Fri, 29 Apr 2016 14:19:20 -0400
Received: from compute3.internal (compute3.nyi.internal [])
 by mailout.nyi.internal (Postfix) with ESMTP id D55C42065E
 for <bug-gnu-emacs@HIDDEN>; Fri, 29 Apr 2016 14:19:07 -0400 (EDT)
Received: from frontend1 ([])
 by compute3.internal (MEProxy); Fri, 29 Apr 2016 14:19:07 -0400
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed;; h=
 :mime-version:subject:to:x-sasl-enc:x-sasl-enc; s=mesmtp; bh=lMJ
 Q0eXho/GMbmCsIYAnHZq08Ws=; b=JXOYlo0XoDvN1ZuDOSH1U3GCCAFZTz55a8c
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=; h=content-transfer-encoding:content-type
 :x-sasl-enc; s=smtpout; bh=lMJQ0eXho/GMbmCsIYAnHZq08Ws=; b=WLw5l
X-Sasl-enc: W0Ufl9gb55HmuyVhtmIm1N91PDhQLAnU8n8ezeN5N/o8 1461953947
Received: from [] (unknown [])
 by (Postfix) with ESMTPA id 53173C00016
 for <bug-gnu-emacs@HIDDEN>; Fri, 29 Apr 2016 14:19:07 -0400 (EDT)
To: bug-gnu-emacs@HIDDEN
From: "Jeremy T. Braun" <spamprevent@HIDDEN>
Subject: 25.1.50; cua-mode does not interact with cursor-face and themes well
Message-ID: <5723A59A.6020909@HIDDEN>
Date: Fri, 29 Apr 2016 11:19:06 -0700
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
X-detected-operating-system: by GNU/Linux 2.2.x-3.x [generic]
X-detected-operating-system: by GNU/Linux 2.6.x
X-Received-From: 2001:4830:134:3::11
X-Spam-Score: -4.4 (----)
X-Debbugs-Envelope-To: submit
X-Mailman-Approved-At: Fri, 29 Apr 2016 14:24:33 -0400
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: -4.4 (----)

I've had issues where themes couldn't change cursor colors.  I finally
figured out the culprit, cua-mode.  Details on what I noticed and how I
found it follow.

I believe the "correct" way for themes to interact with the cursor color
is to modify the :background attribute of the face named cursor.  See:

cua-mode defines a variable cua-normal-cursor-color.  By default this is
set to one of initial-cursor-color, cursor-color from initial-frame-alis
or default-frame-alist, the frame-parameter 'cursor-color, or "red" if
those are all not true.

When cua-enable-cursor-indications is enabled, cua--update-indications
is run as a part of cua--post-command-handler, which is added to

When run, cua-enable-cursor-indications typically calls set-cursor-color
to one of the cua-*-cursor-color variables.

The result?  Themes can change the cursor-color (via the face or via
set-cursor-color, but after they are loaded/run, the post-command-hook
eventually runs cua--update-indications, which overwrites the theme's
new "normal" cursor color with whatever was previously stored in
cua-normal-cursor-color (for "normal" buffers, anyway).

I first noticed this because I run emacs in --daemon mode a lot.  When
emacs is in --daemon mode, I think that .emacs/init.el is run in the
frame/context of the terminal or background emacs process. When my
init.el is run, (frame-parameter nil 'cursor-color) returns "white",
which cua-normal-cursor-color is set to.  When I switch between the
background-mode = dark/light color themes linked below, the cursor
always stays white, and it's illegible in the "light" theme.

When I launch emacs without --daemon, my init.el loads the theme first,
which sets frame-parameter.cursor-color to #839496, which initializes
cua-normal-cursor-color, which is legible in both dark and light modes.

I'm not sure how "best" to fix this.  Options I see:
* Change documentation on custom themes, requiring that in addition to
   modifying the cursor face, they should also modify cua-*-cursor-color.
* Change cua-mode to be aware that themes may modify the cursor face,
   and either update cua-normal-cursor-face to reflect the cursor face's
   :background attribute, or maybe have cua--update-indications use
   something like:
     (or cua-normal-cursor-face (grab the :background attribute of 
   And then the user can set/customize cua-normal-cursor-face to nil to
   allow the theme to control it.
* Document this, and require the user to hook theme loading and
   after-make-frame-functions to update cua-normal-cursor-color to be
   (frame-parameter frame 'cursor-color), which would have been set by
   the theme at that point.
* Other?


In GNU Emacs (x86_64-pc-linux-gnu, GTK+ Version 3.10.8)
  of 2016-04-25 built on lgw01-57
Windowing system distributor 'The X.Org Foundation', version 11.0.11501000
System Description:    Ubuntu 14.04.4 LTS

Configured using:
  'configure --build=x86_64-linux-gnu --prefix=/usr
  '--includedir=${prefix}/include' '--mandir=${prefix}/share/man'
  '--infodir=${prefix}/share/info' --sysconfdir=/etc --localstatedir=/var
  '--libexecdir=${prefix}/lib/x86_64-linux-gnu' --disable-maintainer-mode
  --disable-dependency-tracking --prefix=/usr --sharedstatedir=/var/lib
  --program-suffix=-snapshot --with-x=yes --with-x-toolkit=gtk3
  'CFLAGS=-g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat
  -Werror=format-security' CPPFLAGS=-D_FORTIFY_SOURCE=2
  'LDFLAGS=-Wl,-Bsymbolic-functions -Wl,-z,relro''

Configured features:

Important settings:
   value of $LANG: en_US.UTF-8
   value of $XMODIFIERS: @im=ibus
   locale-coding-system: utf-8-unix

Major mode: Lisp Interaction

Minor modes in effect:
   tooltip-mode: t
   global-eldoc-mode: t
   electric-indent-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-composition-mode: t
   auto-encryption-mode: t
   auto-compression-mode: t
   line-number-mode: t
   transient-mark-mode: t

Recent messages:
For information about GNU Emacs and the GNU system, type C-h C-a.

Load-path shadows:
None found.

(shadow sort mail-extr emacsbug message puny seq byte-opt gv bytecomp
byte-compile cl-extra help-mode cconv cl-loaddefs pcase cl-lib dired
dired-loaddefs format-spec rfc822 mml easymenu mml-sec password-cache
epa derived epg epg-config gnus-util rmail rmail-loaddefs mm-decode
mm-bodies mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader
sendmail rfc2047 rfc2045 ietf-drums mm-util mail-prsvr mail-utils
time-date mule-util 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 newcomment elisp-mode
lisp-mode prog-mode register page menu-bar rfn-eshadow 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 charscript 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
dbusbind inotify dynamic-setting system-font-setting font-render-setting
move-toolbar gtk x-toolkit x multi-tty make-network-process emacs)

Memory information:
((conses 16 97251 6761)
  (symbols 48 20808 0)
  (miscs 40 433 132)
  (strings 32 17940 4659)
  (string-bytes 1 555138)
  (vectors 16 13743)
  (vector-slots 8 447013 4512)
  (floats 8 181 19)
  (intervals 56 231 0)
  (buffers 976 11)
  (heap 1024 33150 1055))

Acknowledgement sent to "Jeremy T. Braun" <spamprevent@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#23403; 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, 25 Nov 2019 12:00:02 UTC

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