From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Tim Landscheidt Newsgroups: gmane.emacs.bugs Subject: bug#29473: 25.3; 'background-mode is 'light on console with black background Date: Sat, 09 Dec 2017 05:35:30 +0000 Organization: http://www.tim-landscheidt.de/ Message-ID: <87efo4ihul.fsf@passepartout.tim-landscheidt.de> References: <87efoj3h91.fsf@passepartout.tim-landscheidt.de> <87a7z1jgn8.fsf@users.sourceforge.net> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1512797778 24633 195.159.176.226 (9 Dec 2017 05:36:18 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sat, 9 Dec 2017 05:36:18 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux) Cc: 29473@debbugs.gnu.org To: Noam Postavsky Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Dec 09 06:36:12 2017 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eNXo4-00065z-7I for geb-bug-gnu-emacs@m.gmane.org; Sat, 09 Dec 2017 06:36:12 +0100 Original-Received: from localhost ([::1]:40091 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eNXo6-0004Dn-RU for geb-bug-gnu-emacs@m.gmane.org; Sat, 09 Dec 2017 00:36:14 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:42696) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eNXny-0004De-H4 for bug-gnu-emacs@gnu.org; Sat, 09 Dec 2017 00:36:10 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eNXnv-00069b-Bp for bug-gnu-emacs@gnu.org; Sat, 09 Dec 2017 00:36:06 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:44384) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eNXnv-00069I-7X for bug-gnu-emacs@gnu.org; Sat, 09 Dec 2017 00:36:03 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1eNXnu-0001hK-L4 for bug-gnu-emacs@gnu.org; Sat, 09 Dec 2017 00:36:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Tim Landscheidt Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 09 Dec 2017 05:36:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 29473 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 29473-submit@debbugs.gnu.org id=B29473.15127977406499 (code B ref 29473); Sat, 09 Dec 2017 05:36:02 +0000 Original-Received: (at 29473) by debbugs.gnu.org; 9 Dec 2017 05:35:40 +0000 Original-Received: from localhost ([127.0.0.1]:53064 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eNXnY-0001gl-6C for submit@debbugs.gnu.org; Sat, 09 Dec 2017 00:35:40 -0500 Original-Received: from mezzogiorno.tim-landscheidt.de ([78.47.87.37]:59357) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eNXnW-0001gc-EQ for 29473@debbugs.gnu.org; Sat, 09 Dec 2017 00:35:39 -0500 Original-Received: from x4e369f73.dyn.telefonica.de ([78.54.159.115]:43604 helo=passepartout.tim-landscheidt.de) by mezzogiorno.tim-landscheidt.de with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1eNXnU-0003bI-74; Sat, 09 Dec 2017 05:35:36 +0000 In-Reply-To: <87a7z1jgn8.fsf@users.sourceforge.net> (Noam Postavsky's message of "Sat, 02 Dec 2017 10:25:47 -0500") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:140844 Archived-At: Noam Postavsky wrote: >> In newsticker tree view on a Linux console with black back- >> ground (both KDE's konsole application and "native" console >> (Alt-Ctrl-F2), all under Fedora), >> (frame-parameter nil 'background-mode) returns 'light. This >> also happens with Emacs' current master branch. >> After glancing at the manual, I'm unclear whether: >> 1. Emacs should set 'background-mode correctly by itself >> (and thus there is an error in the detection mechanism), >> 2. it is my duty to explicitly set background-mode (via >> initial-frame-alist?) when using Emacs on a console, or > I'm pretty sure it's #1, the manual explains that background-mode nil > should use automatic detection, and it sounds like that detection is > going wrong. > I don't see anything in lisp/term/linux.el that sets the background mode > at all. What does running 'echo $TERM' in a shell give you? > Looking at lisp/term/konsole.el, it looks like it uses the xterm > functions for everything. Could you try stepping through/adding > 'message' calls in terminal-init-xterm and see if/where it goes wrong? (For the moment, I retract my claim that this also happens on a "native" (Alt-Ctrl-F2) console because I can no longer reproduce it and cannot remember my test setup, so the fol- lowing is limited to konsole in Fedora 25.) In konsole, $TERM is set to "xterm-256color": | [tim@passepartout ~/src/emacs]$ echo $TERM | xterm-256color | [tim@passepartout ~/src/emacs]$ With interspersed message calls, I could find out that kon- sole's response to the "Secondary Device Attributes (DA)" query in terminal-init-xterm ("\e[>0c") is "^[[>0;115;0c": | [tim@passepartout ~/src/emacs]$ perl -we 'print "\e[>0c";'; sleep 1; echo | ^[[>0;115;0c | [tim@passepartout ~/src/emacs]$ This version number (115) falls short of the test "(>= version 242)" which would cause the background colour to be queried, and rightly so, because konsole does not re- spond to the query "\e]11;?\e\\": | [tim@passepartout ~/src/emacs]$ perl -we 'print "\e]11;?\e\\";'; sleep 1; echo | [tim@passepartout ~/src/emacs]$ (Sidenote: gnome-terminal reports back "^[[>1;4603;0c" and "^[]11;rgb:2323/2727/2929^[\" but the latter is never que- ried due to NUMBER1 being 1 and NUMBER2 being greater than 2000, so background-mode stills end up as 'light with gnome- terminal.) So then I tried to track down where background-mode's 'light is actually coming from, and it seems to originate in frame-set-background-mode's: | (default-bg-mode | (if (or (window-system frame) | (and tty-type | (string-match "^\\(xterm\\|\\rxvt\\|dtterm\\|eterm\\)" | tty-type))) | 'light | 'dark)) with tty-type being "xterm-256color". This logic was first introduced in: | commit 5ebc02b3656890d1d110c671129c64547bdbcdd6 | Author: Eli Zaretskii | Date: Sat Oct 28 18:48:08 2000 +0000 | (normal-top-level): If the value of $TERM indicates that | we are running from xterm or one of its work-alikes, default to a | light background mode. Curious, I installed xterm and indeed it has black fore- ground on white background which I had not only forgotten about, but also for example Wikipedia uses a black back- ground xterm to illustrate its article (https://en.wikipedia.org/wiki/Xterm). D'oh. My assumption now is that Emacs's detection mechanism cannot be "fixed" for konsole in Fedora 25 and I should manually set frame-background-mode to 'dark. But: In Fedora 26, konsole 17.04.1 (in contrast to Fedora 25's konsole 16.12.3) still returns "^[[>0;115;0c" as version number, /but/ "\^[]11;rgb:0000/0000/0000^G" for the background colour. So one possible improvement could be to query the background colour either unconditionally or also on "(= version 115)". This would increase the start-up time by (at most) two se- conds (xterm-query-timeout) for terminals that do not sup- port this query AFAIUI. (So that I don't forget: I used: | [tim@passepartout ~/src/emacs]$ make && ./src/emacs -Q -L $PWD -nw --eval '(switch-to-buffer "*Messages*")' for testing.)