GNU bug report logs - #29716
25.1; Wrong brackground-mode on gnome-terminal

Previous Next

Package: emacs;

Reported by: semente <semente <at> riseup.net>

Date: Thu, 14 Dec 2017 22:34:03 UTC

Severity: minor

Tags: fixed

Found in version 25.1

Fixed in version 26.1

Done: Noam Postavsky <npostavs <at> users.sourceforge.net>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 29716 in the body.
You can then email your comments to 29716 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#29716; Package emacs. (Thu, 14 Dec 2017 22:34:03 GMT) Full text and rfc822 format available.

Acknowledgement sent to semente <semente <at> riseup.net>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Thu, 14 Dec 2017 22:34:03 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: semente <semente <at> riseup.net>
To: bug-gnu-emacs <at> gnu.org
Subject: 25.1; Wrong brackground-mode on gnome-terminal
Date: Thu, 14 Dec 2017 19:43:48 -0200
This bug report will be sent to the Bug-GNU-Emacs mailing list
and the GNU bug tracker at debbugs.gnu.org.  Please check that
the From: line contains a valid email address.  After a delay of 
up
to one day, you should receive an acknowledgment at that address.

Please write in English if possible, as the Emacs maintainers
usually do not have translators for other languages.

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':

On gnome-terminal 3.22.2 (Debian Stretch), for some reason, Emacs 
is
setting the background-mode to light when I'm running a dark
background. On xterm or ttys it works fine.

The only way I found to fix this is by forcing a dark mode, as for
example:

 (setq frame-background-mode 'dark)
 (set-background-color "black")
 (set-foreground-color "white")

Thanks,
semente

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
/usr/share/emacs/25.1/etc/DEBUG.


In GNU Emacs 25.1.1 (x86_64-pc-linux-gnu, GTK+ Version 3.22.11)
of 2017-09-15, modified by Debian built on trouble
System Description:     Debian GNU/Linux 9.3 (stretch)

Configured using:
'configure --build x86_64-linux-gnu --prefix=/usr
--sharedstatedir=/var/lib --libexecdir=/usr/lib
--localstatedir=/var/lib --infodir=/usr/share/info
--mandir=/usr/share/man --with-pop=yes
--enable-locallisppath=/etc/emacs25:/etc/emacs:/usr/local/share/emacs/25.1/site-lisp:/usr/loca\
l/share/emacs/site-lisp:/usr/share/emacs/25.1/site-lisp:/usr/share/emacs/site-lisp
--with-sound=alsa --build x86_64-linux-gnu --prefix=/usr
--sharedstatedir=/var/lib --libexecdir=/usr/lib
--localstatedir=/var/lib --infodir=/usr/share/info
--mandir=/usr/share/man --with-pop=yes
--enable-locallisppath=/etc/emacs25:/etc/emacs:/usr/local/share/emacs/25.1/site-lisp:/usr/loca\
l/share/emacs/site-lisp:/usr/share/emacs/25.1/site-lisp:/usr/share/emacs/site-lisp
--with-sound=alsa --with-x=yes --with-x-toolkit=gtk3
--with-toolkit-scroll-bars 'CFLAGS=-g -O2
-fdebug-prefix-map=/build/emacs25-wN2qS3/emacs25-25.1+1=. -fstack-protector-strong
-Wformat -Werror=format-security -Wall' 'CPPFLAGS=-Wdate-time
-D_FORTIFY_SOURCE=2' LDFLAGS=-Wl,-z,relro'

Configured features:
XPM JPEG TIFF GIF PNG RSVG IMAGEMAGICK SOUND GPM DBUS GCONF 
GSETTINGS
NOTIFY ACL LIBSELINUX GNUTLS LIBXML2 FREETYPE M17N_FLT LIBOTF XFT 
ZLIB
TOOLKIT_SCROLL_BARS GTK3 X11

Important settings:
 value of $LC_MONETARY: pt_BR.UTF-8
 value of $LC_NUMERIC: pt_BR.UTF-8
 value of $LC_TIME: pt_BR.UTF-8
 value of $LANG: en_US.UTF-8
 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
 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 dired format-spec rfc822 
mml
mml-sec password-cache epg epg-config gnus-util mm-decode 
mm-bodies
mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader 
sendmail
rfc2047 rfc2045 ietf-drums mm-util help-fns help-mode easymenu
cl-loaddefs pcase cl-lib mail-prsvr mail-utils term/xterm xterm
time-date mule-util tooltip eldoc electric uniquify ediff-hook 
vc-hooks
lisp-float-type mwheel 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 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 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 91298 7489)
(symbols 48 19941 0)
(miscs 40 46 172)
(strings 32 14764 4115)
(string-bytes 1 415527)
(vectors 16 9779)
(vector-slots 8 386436 16291)
(floats 8 166 523)
(intervals 56 251 0)
(buffers 976 20))




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#29716; Package emacs. (Fri, 15 Dec 2017 01:14:02 GMT) Full text and rfc822 format available.

Message #8 received at 29716 <at> debbugs.gnu.org (full text, mbox):

From: Noam Postavsky <npostavs <at> users.sourceforge.net>
To: semente <semente <at> riseup.net>
Cc: 29716 <at> debbugs.gnu.org
Subject: Re: bug#29716: 25.1; Wrong brackground-mode on gnome-terminal
Date: Thu, 14 Dec 2017 20:13:45 -0500
severity 29716 minor
severity 29473 minor
quit

semente <semente <at> riseup.net> writes:

> On gnome-terminal 3.22.2 (Debian Stretch), for some reason, Emacs is
> setting the background-mode to light when I'm running a dark
> background. On xterm or ttys it works fine.
>
> The only way I found to fix this is by forcing a dark mode, as for
> example:
>
>  (setq frame-background-mode 'dark)
>  (set-background-color "black")
>  (set-foreground-color "white")

What do you get from running

    printf '\e[>0c'

and

    printf '\e]11;?\e\'

in the shell from gnome-terminal?

See also https://debbugs.gnu.org/cgi/bugreport.cgi?users=emacs;bug=29473#11




Severity set to 'minor' from 'normal' Request was from Noam Postavsky <npostavs <at> users.sourceforge.net> to control <at> debbugs.gnu.org. (Fri, 15 Dec 2017 01:14:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#29716; Package emacs. (Fri, 15 Dec 2017 02:03:02 GMT) Full text and rfc822 format available.

Message #13 received at 29716 <at> debbugs.gnu.org (full text, mbox):

From: semente <semente <at> riseup.net>
To: Noam Postavsky <npostavs <at> users.sourceforge.net>
Cc: 29716 <at> debbugs.gnu.org
Subject: Re: bug#29716: 25.1; Wrong brackground-mode on gnome-terminal
Date: Thu, 14 Dec 2017 23:44:26 -0200
Noam Postavsky <npostavs <at> users.sourceforge.net> writes:

> What do you get from running
>     printf '\e[>0c'
> and
>     printf '\e]11;?\e\'
> in the shell from gnome-terminal?

Hi Noam, thanks for follow up!

$ printf '\e[>0c'
1;4601;0c

$ printf '\e]11;?\e\'
11;rgb:2323/2727/2929

$ echo $TERM
xterm-256color

--
semente




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#29716; Package emacs. (Fri, 15 Dec 2017 02:48:02 GMT) Full text and rfc822 format available.

Message #16 received at 29716 <at> debbugs.gnu.org (full text, mbox):

From: Noam Postavsky <npostavs <at> users.sourceforge.net>
To: semente <semente <at> riseup.net>
Cc: 29716 <at> debbugs.gnu.org
Subject: Re: bug#29716: 25.1; Wrong brackground-mode on gnome-terminal
Date: Thu, 14 Dec 2017 21:47:45 -0500
[Message part 1 (text/plain, inline)]
tags 29716 + patch
quit

semente <semente <at> riseup.net> writes:

> On gnome-terminal 3.22.2 (Debian Stretch), for some reason, Emacs is
> setting the background-mode to light when I'm running a dark
> background. On xterm or ttys it works fine.

> $ printf '\e[>0c'
> 1;4601;0c
>
> $ printf '\e]11;?\e\'
> 11;rgb:2323/2727/2929
>
> $ echo $TERM
> xterm-256color

I think the attached should do the trick then.  There are two other
xterm features that Emacs tries to use based on version number; I'm not
sure how to test if your version of gnome-terminal supports them or not
though (so I played it safe in the patch and use the query background
feature only).

    (defun xterm--version-handler ()
      ...
        ;; If version is 216 (the version when modifyOtherKeys was
        ;; introduced) or higher, initialize the
        ;; modifyOtherKeys support.
        (when (>= version 216)
          (xterm--init-modify-other-keys))
        ;; In version 203 support for accessing the X selection was
        ;; added.  Hterm reports itself as version 256 and supports it
        ;; as well.  gnome-terminal doesn't and is excluded by this
        ;; test.
        (when (>= version 203)
          ;; Most xterms seem to have it disabled by default, and if it's
          ;; disabled, C-y will incur a timeout, so we only use it if the user
          ;; explicitly requests it.
          ;;(xterm--init-activate-get-selection)
          (xterm--init-activate-set-selection))...)

[v1-0001-Query-background-for-gnome-terminal-version-3.22-.patch (text/x-diff, inline)]
From 34b6835f7581fb19f67fe134eab0b536af003dfa Mon Sep 17 00:00:00 2001
From: Noam Postavsky <npostavs <at> gmail.com>
Date: Thu, 14 Dec 2017 21:42:56 -0500
Subject: [PATCH v1] Query background for gnome terminal version 3.22
 (Bug#29716)

* lisp/term/xterm.el (xterm--version-handler): Use
xterm--report-background-handler for terminals reporting minor version
4000 and above.
---
 lisp/term/xterm.el | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/lisp/term/xterm.el b/lisp/term/xterm.el
index 4f79703833..df224757f9 100644
--- a/lisp/term/xterm.el
+++ b/lisp/term/xterm.el
@@ -670,9 +670,14 @@ xterm--version-handler
         (when (and (> version 2000) (equal (match-string 1 str) "1"))
           ;; Hack attack!  bug#16988: gnome-terminal reports "1;NNNN;0"
           ;; with a large NNNN but is based on a rather old xterm code.
-          ;; Gnome terminal 3.6.1 reports 1;3406;0
           ;; Gnome terminal 2.32.1 reports 1;2802;0
-          (setq version 200))
+          ;; Gnome terminal 3.6.1 reports 1;3406;0
+          (setq version 200)
+          ;; Gnome terminal 3.22.2 reports 1;4601;0 and *does* support
+          ;; background color querying (Bug#29716).
+          (when (> version 4000)
+            (xterm--query "\e]11;?\e\\"
+                          '(("\e]11;" .  xterm--report-background-handler)))))
         (when (equal (match-string 1 str) "83")
           ;; `screen' (which returns 83;40003;0) seems to also lack support for
           ;; some of these (bug#17607, bug#20356).
-- 
2.11.0


Added tag(s) patch. Request was from Noam Postavsky <npostavs <at> users.sourceforge.net> to control <at> debbugs.gnu.org. (Fri, 15 Dec 2017 02:48:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#29716; Package emacs. (Fri, 15 Dec 2017 08:53:01 GMT) Full text and rfc822 format available.

Message #21 received at 29716 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Noam Postavsky <npostavs <at> users.sourceforge.net>
Cc: 29716 <at> debbugs.gnu.org, semente <at> riseup.net
Subject: Re: bug#29716: 25.1; Wrong brackground-mode on gnome-terminal
Date: Fri, 15 Dec 2017 10:52:20 +0200
> From: Noam Postavsky <npostavs <at> users.sourceforge.net>
> Date: Thu, 14 Dec 2017 21:47:45 -0500
> Cc: 29716 <at> debbugs.gnu.org
> 
> I think the attached should do the trick then.

Thanks, this is okay for the release branch, assuming that it fixes
the problem.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#29716; Package emacs. (Mon, 25 Dec 2017 18:29:02 GMT) Full text and rfc822 format available.

Message #24 received at 29716 <at> debbugs.gnu.org (full text, mbox):

From: semente <semente <at> riseup.net>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 29716 <at> debbugs.gnu.org, Noam Postavsky <npostavs <at> users.sourceforge.net>
Subject: Re: bug#29716: 25.1; Wrong brackground-mode on gnome-terminal
Date: Mon, 25 Dec 2017 16:27:48 -0200
Hey Eli and Noam, sorry for the delay in give you a feedback but 
the patch unfortunately didn't work for me.

Thank you,
semente

Eli Zaretskii <eliz <at> gnu.org> writes:

>> From: Noam Postavsky <npostavs <at> users.sourceforge.net>
>> Date: Thu, 14 Dec 2017 21:47:45 -0500
>> Cc: 29716 <at> debbugs.gnu.org
>>
>> I think the attached should do the trick then.
>
> Thanks, this is okay for the release branch, assuming that it 
> fixes
> the problem.


--
semente




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#29716; Package emacs. (Mon, 01 Jan 2018 01:20:02 GMT) Full text and rfc822 format available.

Message #27 received at 29716 <at> debbugs.gnu.org (full text, mbox):

From: Noam Postavsky <npostavs <at> users.sourceforge.net>
To: semente <semente <at> riseup.net>
Cc: Eli Zaretskii <eliz <at> gnu.org>, 29716 <at> debbugs.gnu.org
Subject: Re: bug#29716: 25.1; Wrong brackground-mode on gnome-terminal
Date: Sun, 31 Dec 2017 20:19:29 -0500
semente <semente <at> riseup.net> writes:

> Hey Eli and Noam, sorry for the delay in give you a feedback but the
> patch unfortunately didn't work for me.

Hmm, what does the evaluating the following produce?  It should pop up a
buffer *bug29716* showing something like "background: rgb:ee00/e800/d500^[".

    (defun bug29716--report-background-handler ()
      (let ((str "")
            chr)
        ;; The reply should be: \e ] 11 ; rgb: NUMBER1 / NUMBER2 / NUMBER3 \e \\                           
        (while (and (setq chr (read-event nil nil 2)) (not (equal chr ?\\)))
          (setq str (concat str (string chr))))
        (with-current-buffer (get-buffer-create "*bug29716*")
          (insert (format "background: %s\n" str))
          (display-buffer (current-buffer)))))

    (xterm--query "\e]11;?\e\\"
                  '(("\e]11;" .  bug29716--report-background-handler)))

If that works, is it possible you didn't test the patch correctly?
(e.g., maybe you applied the patch, but didn't recompile?)

If it doesn't work, I'm a bit confused, given what you reported in #13.




Added tag(s) moreinfo; removed tag(s) patch. Request was from Noam Postavsky <npostavs <at> users.sourceforge.net> to control <at> debbugs.gnu.org. (Sun, 07 Jan 2018 00:25:01 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#29716; Package emacs. (Sun, 07 Jan 2018 23:26:02 GMT) Full text and rfc822 format available.

Message #32 received at 29716 <at> debbugs.gnu.org (full text, mbox):

From: semente <semente <at> riseup.net>
To: Noam Postavsky <npostavs <at> users.sourceforge.net>
Cc: Eli Zaretskii <eliz <at> gnu.org>, 29716 <at> debbugs.gnu.org
Subject: Re: bug#29716: 25.1; Wrong brackground-mode on gnome-terminal
Date: Sun, 07 Jan 2018 21:24:58 -0200
Got this:

   background: rgb:2323/2727/2929^[

Anyway, I might just have found the issue.

The patch set the version to 200 before evaluating the following 
code:

         (when (> version 4000)
           (xterm--query "\e]11;?\e\\"
                         '(("\e]11;" . 
                         xterm--report-background-handler))))

So the expression above is never evaluated.

I moved the `(setq version 200)' line to the line after the `(when 
...)' expression and it is working now but don't know if it is 
exactly what you would do.

Thank you once again!


Noam Postavsky <npostavs <at> users.sourceforge.net> writes:

> semente <semente <at> riseup.net> writes:
>
>> Hey Eli and Noam, sorry for the delay in give you a feedback 
>> but the
>> patch unfortunately didn't work for me.
>
> Hmm, what does the evaluating the following produce?  It should 
> pop up a
> buffer *bug29716* showing something like "background: 
> rgb:ee00/e800/d500^[".
>
>     (defun bug29716--report-background-handler ()
>       (let ((str "")
>             chr)
>         ;; The reply should be: \e ] 11 ; rgb: NUMBER1 / NUMBER2 
>         / NUMBER3 \e \\
>         (while (and (setq chr (read-event nil nil 2)) (not 
>         (equal chr ?\\)))
>           (setq str (concat str (string chr))))
>         (with-current-buffer (get-buffer-create "*bug29716*")
>           (insert (format "background: %s\n" str))
>           (display-buffer (current-buffer)))))
>
>     (xterm--query "\e]11;?\e\\"
>                   '(("\e]11;" . 
>                   bug29716--report-background-handler)))
>
> If that works, is it possible you didn't test the patch 
> correctly?
> (e.g., maybe you applied the patch, but didn't recompile?)
>
> If it doesn't work, I'm a bit confused, given what you reported 
> in #13.


--
semente




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#29716; Package emacs. (Mon, 08 Jan 2018 01:32:01 GMT) Full text and rfc822 format available.

Message #35 received at 29716 <at> debbugs.gnu.org (full text, mbox):

From: Noam Postavsky <npostavs <at> users.sourceforge.net>
To: semente <semente <at> riseup.net>
Cc: Eli Zaretskii <eliz <at> gnu.org>, 29716 <at> debbugs.gnu.org
Subject: Re: bug#29716: 25.1; Wrong brackground-mode on gnome-terminal
Date: Sun, 07 Jan 2018 20:30:57 -0500
tags 29716 = fixed
close 29716 26.1
quit

semente <semente <at> riseup.net> writes:

> Anyway, I might just have found the issue.
>
> The patch set the version to 200 before evaluating the following code:
>
>          (when (> version 4000)

Oh, you're absolutely correct.  What a silly mistake.

> I moved the `(setq version 200)' line to the line after the `(when
> ...)' expression and it is working now but don't know if it is exactly
> what you would do.

I've done exactly that, and pushed to emacs-26.  Thanks!

[1: 918a052a42]: 2018-01-07 20:21:46 -0500
  Query background for gnome terminal version 3.22 (Bug#29716)
  https://git.savannah.gnu.org/cgit/emacs.git/commit/?id=918a052a422c05b5f78fd7c702eb6e3ee189fa18




Added tag(s) fixed; removed tag(s) moreinfo. Request was from Noam Postavsky <npostavs <at> users.sourceforge.net> to control <at> debbugs.gnu.org. (Mon, 08 Jan 2018 01:32:02 GMT) Full text and rfc822 format available.

bug marked as fixed in version 26.1, send any further explanations to 29716 <at> debbugs.gnu.org and semente <semente <at> riseup.net> Request was from Noam Postavsky <npostavs <at> users.sourceforge.net> to control <at> debbugs.gnu.org. (Mon, 08 Jan 2018 01:32:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Mon, 05 Feb 2018 12:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 7 years and 198 days ago.

Previous Next


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