From debbugs-submit-bounces@debbugs.gnu.org Fri Apr 29 14:24:36 2016 Received: (at submit) by debbugs.gnu.org; 29 Apr 2016 18:24:36 +0000 Received: from localhost ([127.0.0.1]:55747 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1awD5e-00043F-TW for submit@debbugs.gnu.org; Fri, 29 Apr 2016 14:24:36 -0400 Received: from eggs.gnu.org ([208.118.235.92]:43789) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1awD1T-0003vo-5K for submit@debbugs.gnu.org; Fri, 29 Apr 2016 14:20:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1awD13-00005C-NW for submit@debbugs.gnu.org; Fri, 29 Apr 2016 14:20:06 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,T_DKIM_INVALID autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:43813) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1awD11-0008SF-Bz for submit@debbugs.gnu.org; Fri, 29 Apr 2016 14:19:49 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34251) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1awD0p-0000eA-7J for bug-gnu-emacs@gnu.org; Fri, 29 Apr 2016 14:19:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1awD0a-0008FZ-Lg for bug-gnu-emacs@gnu.org; Fri, 29 Apr 2016 14:19:27 -0400 Received: from out5-smtp.messagingengine.com ([66.111.4.29]:58545) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1awD0Y-0008Cy-7Q for bug-gnu-emacs@gnu.org; Fri, 29 Apr 2016 14:19:20 -0400 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id D55C42065E for ; Fri, 29 Apr 2016 14:19:07 -0400 (EDT) Received: from frontend1 ([10.202.2.160]) by compute3.internal (MEProxy); Fri, 29 Apr 2016 14:19:07 -0400 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=squidevil.net; h= content-transfer-encoding:content-type:date:from:message-id :mime-version:subject:to:x-sasl-enc:x-sasl-enc; s=mesmtp; bh=lMJ Q0eXho/GMbmCsIYAnHZq08Ws=; b=JXOYlo0XoDvN1ZuDOSH1U3GCCAFZTz55a8c Uf8O4JvTvOEBu/HCjT7r2FRzmdLQZ4h4i7e+IUHQFpetUoURxVJnA9HtR59dP+yx nCRcmGLRbdQyJTVOWFqSIA4CRBFINj3/uA64d/+MWVAf0BPGeazvO4Znzxj1umRs J0Z7GsfI= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:message-id:mime-version:subject:to:x-sasl-enc :x-sasl-enc; s=smtpout; bh=lMJQ0eXho/GMbmCsIYAnHZq08Ws=; b=WLw5l LI2+1up1Bg/6J3yxnKZzT1GlgMtNgZcppifgfYohbFEHtljYX5EyXc0o4RzVlTqj Sd1CWLBK4OdAgHgHVgPdZ/w7VCdsDO0EQaG2V9NVP3I7UZBmn6G88dm10RpR3E6O EfQefuZToPkMswcdYIQUWO5xbe0MbVoXk/E2IQ= X-Sasl-enc: W0Ufl9gb55HmuyVhtmIm1N91PDhQLAnU8n8ezeN5N/o8 1461953947 Received: from [10.60.0.30] (unknown [192.31.242.195]) by mail.messagingengine.com (Postfix) with ESMTPA id 53173C00016 for ; Fri, 29 Apr 2016 14:19:07 -0400 (EDT) To: bug-gnu-emacs@gnu.org From: "Jeremy T. Braun" Subject: 25.1.50; cua-mode does not interact with cursor-face and themes well Message-ID: <5723A59A.6020909@squidevil.net> Date: Fri, 29 Apr 2016 11:19:06 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.7.2 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-detected-operating-system: by eggs.gnu.org: 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@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" 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: https://www.gnu.org/software/emacs/manual/html_node/emacs/Cursor-Display.html 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 post-command-hook. 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. https://github.com/sellout/emacs-color-theme-solarized 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 cursor-face)) 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? Thanks, Jeremy In GNU Emacs 25.1.50.2 (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 '--libdir=${prefix}/lib/x86_64-linux-gnu' '--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: XPM JPEG TIFF GIF PNG RSVG IMAGEMAGICK SOUND GPM DBUS GCONF GSETTINGS NOTIFY LIBSELINUX GNUTLS LIBXML2 FREETYPE M17N_FLT LIBOTF XFT ZLIB TOOLKIT_SCROLL_BARS GTK3 X11 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. Features: (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)) From debbugs-submit-bounces@debbugs.gnu.org Mon Mar 10 08:06:33 2025 Received: (at 23403) by debbugs.gnu.org; 10 Mar 2025 12:06:33 +0000 Received: from localhost ([127.0.0.1]:36584 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1trbtw-0001K6-M8 for submit@debbugs.gnu.org; Mon, 10 Mar 2025 08:06:33 -0400 Received: from mail-pl1-x629.google.com ([2607:f8b0:4864:20::629]:55483) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1trbtr-0001Jo-05 for 23403@debbugs.gnu.org; Mon, 10 Mar 2025 08:06:27 -0400 Received: by mail-pl1-x629.google.com with SMTP id d9443c01a7336-2240b4de12bso63736575ad.2 for <23403@debbugs.gnu.org>; Mon, 10 Mar 2025 05:06:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1741608380; x=1742213180; darn=debbugs.gnu.org; h=content-transfer-encoding:subject:from:cc:to:content-language :user-agent:mime-version:date:message-id:from:to:cc:subject:date :message-id:reply-to; bh=Fp1pCFH1h3RdSCe5qoYhehDt3sM/6UAfDos/jXqVxfk=; b=eKE7bKuT0XNmliedGl7o62HGGx1ZYgqfg3Kf0vs1GqyBhw2OZg7X6ZBlW9HHP77NbJ TqpSc5Ar8OwwI0XT3MVA85cmWxIUJDgSSZCfP94z3da3Ksn2y6JOcp4IMBvKDRGc3lyU z4bpccAv/9yCOKlHmb086rSc4/33aEetMRLlHlTqfOfsSvizfdRTmc/irlzoROdVbYwW NuX9JzA7nrhwhUncQcFeIVVdz/JeyOkHcqFMmIsACgYbLddfezr3F7rA74c4QmH9VxqS hOxQjtQB4Xum5QJZ9d1zj09c0epcuTZVYSnvP1DD8V3uHzQ6DRIUS6L9Kvw5f+Iliiy0 4OWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741608380; x=1742213180; h=content-transfer-encoding:subject:from:cc:to:content-language :user-agent:mime-version:date:message-id:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=Fp1pCFH1h3RdSCe5qoYhehDt3sM/6UAfDos/jXqVxfk=; b=PxNqf+RzxSpCZ7iGQFS+cZj2mEhKu57MtsB15A3HNSF6ou2mv8tP6hj9BrsxmQD/GQ Z0CgvtwhVEBNyzxRPRzyhgzFyn0c1RRhEhW8txwB8yV1VGep/JvrUjaIQTv2bAUG+Dcl izxwQ110IDq26o5fCfDvkjT2XmyvP6Feo72MsqCRdKGG5y+92nFEAudg/4PeiRjkOuJ0 TP39ZdpWlBEuj+wR28UK1sd4fP9C0oRYrR2LqZQNOR/WcaWhC/2KkxPUEFJghjsPKR88 HxNmsWtAlupPHKW8GXVLSkWZgrt85ZJeuREXzB9BZkI4cnP9i/bgw7B/fmngkIBc0SVu 5EQA== X-Gm-Message-State: AOJu0YwggMALxRAJrB0I8vFviMan0Rk17ZK83K1NSxonXCkqKj758MKh HNKsDaofc1KKT/+Q6UYaNWuo5zpL3clnBKB5tpmSVQci1ACq1YPI6Ykn+Bj1 X-Gm-Gg: ASbGncvPTjkcMP25MZY7nNwjlHm0rUXRq2WcQ6MBoawjgxq7/ySjD0HMvRAx52yuV96 R9P6gdZIbwUW9okdTHDNnewa/olS0iTj909l3ysIzhGNaHS2WsmVdjFVTg475iz2WRdhPWfRvtS TIVXzOsmy3+mMy6HNfGXa4mNuvCcWFaHhDoeM/KklfSoK7SIpuR1vX5S6LwNJXqbaWlK1uHHTXf /T6UPf/3xJwR1Io2pYVIZ/JAVoj8/PWkJWqr90ZCjhQYLsa6BixcN/s6G0Bno0RJG1vY+d23Pp0 8fqzts5WEzHRm53Kg8pXSiPGoCogNCwfFe/kGpuDjtIyxOi3OUQ= X-Google-Smtp-Source: AGHT+IEBz7PoQnXiio3E2o89BfxnNZnpsfy1wM7Ax+EdfO+WI9lWr60iIuOkVz+QyGfuEnKhwsPWfg== X-Received: by 2002:a17:903:283:b0:21f:74ec:1ff0 with SMTP id d9443c01a7336-22428ab7961mr227388965ad.32.1741608379707; Mon, 10 Mar 2025 05:06:19 -0700 (PDT) Received: from [192.168.0.234] ([181.228.33.6]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-22410a91bdesm75959565ad.176.2025.03.10.05.06.16 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 10 Mar 2025 05:06:17 -0700 (PDT) Message-ID: <478f647a-5a67-4eb2-bdf8-f2e302661c6f@gmail.com> Date: Mon, 10 Mar 2025 09:06:14 -0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Content-Language: en-US To: 23403@debbugs.gnu.org From: Mauro Aranda Subject: Re: bug#23403: 25.1.50; cua-mode does not interact with cursor-face and themes well Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 23403 Cc: "Jeremy T. Braun" X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) "Jeremy T. Braun" writes: > 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: > https://www.gnu.org/software/emacs/manual/html_node/emacs/Cursor-Display.html > > 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 > post-command-hook. > > 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. > https://github.com/sellout/emacs-color-theme-solarized > > 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. IIUC, the issue here can be reproduced in a couple of ways. Here's one: emacs -Q M-x cua-mode M-x customize-set-variable RET cua-enable-cursor-indications RET y M-x load-theme RET deeper-blue Notice that the cursor is black.  Compare with: emacs -Q M-x load-theme RET deeper-blue M-x cua-mode M-x customize-set-variable RET cua-enable-cursor-indications RET y Now the cursor is green.  If you want, load any other theme, and see that the cursor color doesn't change: it stays green. > 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. Themes have pretty much no choice, since it seems to me that for a good user experience, they need to make sure all cua-*-cursor-color options interact well with their settings. > * 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 >     cursor-face)) >   And then the user can set/customize cua-normal-cursor-face to nil to >   allow the theme to control it. This idea seems like an improvement.  Allow nil for this option, so that it CUA understands it as "don't mess with the cursor color". Opinions? From debbugs-submit-bounces@debbugs.gnu.org Mon Mar 17 06:10:42 2025 Received: (at 23403) by debbugs.gnu.org; 17 Mar 2025 10:10:43 +0000 Received: from localhost ([127.0.0.1]:55766 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tu7Qe-0002Nd-Qf for submit@debbugs.gnu.org; Mon, 17 Mar 2025 06:10:42 -0400 Received: from mail-pl1-x631.google.com ([2607:f8b0:4864:20::631]:42314) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1tu7Qc-0002ME-1n for 23403@debbugs.gnu.org; Mon, 17 Mar 2025 06:10:39 -0400 Received: by mail-pl1-x631.google.com with SMTP id d9443c01a7336-223f4c06e9fso69242005ad.1 for <23403@debbugs.gnu.org>; Mon, 17 Mar 2025 03:10:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1742206231; x=1742811031; darn=debbugs.gnu.org; h=in-reply-to:content-language:references:cc:to:from:subject :user-agent:mime-version:date:message-id:from:to:cc:subject:date :message-id:reply-to; bh=FWqSq2JvL5d2rSWEDqK5GdpoQhdMO0uWODlpmEEfgrk=; b=PyJZmhh6g7vErVJc9iSFS2CCFFWmMvxokm5q4fVyAyI2kU8i7nq1wVX7T/GMZLZKgY 5lrd5eYwD8sbgQP0tktKGQ0sibVa8ZqWu5YVbic4W+AXye4TQ8pP0qHBa5gMf0Fl/UPG uI56aEwGf1d/e2dcKOtsVp+4VDaHuQpNnyXlZz2nOhcFrYzPnPBTUktmZm+BljnTQh5K eK+PqluL+0cdst42VV4XiYmSg9HyGM+FDPYSn3C1EoPzCvlCR1PsdfwxYWxvjpW2ctcp LNyT238RaautEtHm/j8qbOUqWc9doypfQB7nG4m/Yw17przX3HHD2Dp2oNN0e27Jk6O8 vGTg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1742206231; x=1742811031; h=in-reply-to:content-language:references:cc:to:from:subject :user-agent:mime-version:date:message-id:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=FWqSq2JvL5d2rSWEDqK5GdpoQhdMO0uWODlpmEEfgrk=; b=bHRfeSCP1W2HB3fE0YDViyiL6SpTbEt38h3K/AdJKR8pV9Xzhufy8AkJbA1Dx/tT2J S8EJp7+GNhlo/mPFZT3u2QlS7jwVgAC5Z0taVCSfU3ZTIAyohr9Zdkf97DuyDD/ZRS/T 2BDd4Wujp7bzdJpIRMtRQeeWaAkad5LO36NXpf1O4skDtxqDmijVBukuwSBmjkX2R+21 b8APqr0bK9SejsPWhGAyxIc0+TPX2NMjwUzsgm7RAOFqkXEWaq0Rw4A0M38Aykmmhmk2 Yf+paSddb0xwzE9t15U/Wqe2ayxXxt5Fj8sAqeK43NqZVbpVlBsAVcmuNZRqSi3u0OmA DIrA== X-Gm-Message-State: AOJu0YwP7tdgIvbDnoo3DeK+i6VKNlsdjNLsMWtEh6G+x2Andf4FuxFR Jfs/Xo1GXczTqUcZL75MvRuKD7nDHYCmQPnIyIYFXDDPYXcxk9BAntgUH1+y X-Gm-Gg: ASbGncsdbb1cOwjA3hFLEEkjn53p4IWKlctEk0QTG0/Qe7KqPBw+/PXBhYVbqHeomut Pqf+FeoXeO103dliXOi0rcQsydp8mzhSFCLjZZ2YlG/mWdqNIo0PQAk2xCGL0BHuJJKWJKFgZd4 bnXuXmNiQR7Jr5Y6UBwd4zJy/BMA6d1Zmz4VaTTc2Pkm0AzNRSXVGVIdlfIhUNGQTTRBu8Whs03 NDTSwQH5j6mWqeDvGv3cwvMzWujVGcEvWPY9sG+L8DReGWwADTuc+V6/9BLmo6dACsObaiXiAWJ 18ZTwBhL3m7bBkU2NP4CkQL9+STPjcsmESGlcEFzBOJT7aOFmFw= X-Google-Smtp-Source: AGHT+IENYbPgWrz5kV1qrvksAhjozarG/XyuTTkOHZ6SewLxV6m06mwO1gcjY1SxJ7x08SGaHuUztQ== X-Received: by 2002:a17:902:cf0a:b0:21f:53a5:19e0 with SMTP id d9443c01a7336-225c66317bfmr201895475ad.12.1742206231279; Mon, 17 Mar 2025 03:10:31 -0700 (PDT) Received: from [192.168.0.234] ([181.228.33.6]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-737115293c3sm7197894b3a.4.2025.03.17.03.10.29 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 17 Mar 2025 03:10:30 -0700 (PDT) Content-Type: multipart/mixed; boundary="------------kMKEHYWdQZhNOU6u3kbJqTN8" Message-ID: <5d956747-a866-4d31-86c7-83d6c69e8bfa@gmail.com> Date: Mon, 17 Mar 2025 07:10:28 -0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: bug#23403: 25.1.50; cua-mode does not interact with cursor-face and themes well From: Mauro Aranda To: 23403@debbugs.gnu.org References: <5723A59A.6020909@squidevil.net> <478f647a-5a67-4eb2-bdf8-f2e302661c6f@gmail.com> Content-Language: en-US In-Reply-To: <478f647a-5a67-4eb2-bdf8-f2e302661c6f@gmail.com> X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 23403 Cc: "Jeremy T. Braun" X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) This is a multi-part message in MIME format. --------------kMKEHYWdQZhNOU6u3kbJqTN8 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Mauro Aranda writes: > "Jeremy T. Braun" writes: > >> 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: >> > https://www.gnu.org/software/emacs/manual/html_node/emacs/Cursor-Display.html >> >> 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 >> post-command-hook. >> >> 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. >> https://github.com/sellout/emacs-color-theme-solarized >> >> 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. > > IIUC, the issue here can be reproduced in a couple of ways. Here's one: > emacs -Q > M-x cua-mode > M-x customize-set-variable RET cua-enable-cursor-indications RET y > M-x load-theme RET deeper-blue > > Notice that the cursor is black.  Compare with: > emacs -Q > M-x load-theme RET deeper-blue > M-x cua-mode > M-x customize-set-variable RET cua-enable-cursor-indications RET y > > Now the cursor is green.  If you want, load any other theme, and see > that the cursor color doesn't change: it stays green. > >> 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. > > Themes have pretty much no choice, since it seems to me that for a good > user experience, they need to make sure all cua-*-cursor-color options > interact well with their settings. > >> * 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 >>     cursor-face)) >>   And then the user can set/customize cua-normal-cursor-face to nil to >>   allow the theme to control it. > > This idea seems like an improvement.  Allow nil for this option, so that > it CUA understands it as "don't mess with the cursor color". > > > Opinions? Here's a patch. Question is, do we change the default value too? --------------kMKEHYWdQZhNOU6u3kbJqTN8 Content-Type: text/x-patch; charset=UTF-8; name="0001-Respect-customized-cursor-face-in-cua-mode.patch" Content-Disposition: attachment; filename="0001-Respect-customized-cursor-face-in-cua-mode.patch" Content-Transfer-Encoding: base64 RnJvbSAzNGZjNjgwZGIzZjQwZWRlMzkxYjg3MzcwZmUyMTBhZjcxY2UwYTk4IE1vbiBTZXAg MTcgMDA6MDA6MDAgMjAwMQpGcm9tOiBNYXVybyBBcmFuZGEgPG1hdXJvb2FyYW5kYUBnbWFp bC5jb20+CkRhdGU6IFN1biwgMTYgTWFyIDIwMjUgMTA6MDc6NTAgLTAzMDAKU3ViamVjdDog W1BBVENIXSBSZXNwZWN0IGN1c3RvbWl6ZWQgY3Vyc29yIGZhY2UgaW4gY3VhLW1vZGUKCiog bGlzcC9lbXVsYXRpb24vY3VhLWJhc2UuZWwgKGN1YS1ub3JtYWwtY3Vyc29yLWNvbG9yKTog QWNjZXB0Cm5pbCBhcyB2YWx1ZS4gIFVwZGF0ZSB2ZXJzaW9uLiAgKEJ1ZyMyMzQwMykKKiB0 ZXN0L2xpc3AvZW11bGF0aW9uL2N1YS1iYXNlLXRlc3RzLmVsOiBOZXcgZmlsZS4KLS0tCiBs aXNwL2VtdWxhdGlvbi9jdWEtYmFzZS5lbCAgICAgICAgICAgIHwgMTEgKysrKystLS0KIHRl c3QvbGlzcC9lbXVsYXRpb24vY3VhLWJhc2UtdGVzdHMuZWwgfCAzNiArKysrKysrKysrKysr KysrKysrKysrKysrKysKIDIgZmlsZXMgY2hhbmdlZCwgNDQgaW5zZXJ0aW9ucygrKSwgMyBk ZWxldGlvbnMoLSkKIGNyZWF0ZSBtb2RlIDEwMDY0NCB0ZXN0L2xpc3AvZW11bGF0aW9uL2N1 YS1iYXNlLXRlc3RzLmVsCgpkaWZmIC0tZ2l0IGEvbGlzcC9lbXVsYXRpb24vY3VhLWJhc2Uu ZWwgYi9saXNwL2VtdWxhdGlvbi9jdWEtYmFzZS5lbAppbmRleCBiYWVlMWE2OTY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