Bug 1159920 - Please switch default to bg=dark
Summary: Please switch default to bg=dark
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Fedora
Classification: Fedora
Component: vim
Version: 27
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Karsten Hopp
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard: https://fedoraproject.org/wiki/Common...
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2014-11-03 15:33 UTC by Lubomir Rintel
Modified: 2018-08-01 05:32 UTC (History)
22 users (show)

Fixed In Version: vim-7.4.640-4.fc22
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2018-08-01 05:32:20 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)
[PATCH] term: add support for querying background color from XTerm (6.85 KB, text/plain)
2015-06-01 12:15 UTC, Lubomir Rintel
no flags Details


Links
System ID Private Priority Status Summary Last Updated
Red Hat Bugzilla 1262837 0 unspecified CLOSED Tracker: make _remote_ vim doing the right decisions about 'set background' 2021-02-22 00:41:40 UTC

Internal Links: 1262837

Description Lubomir Rintel 2014-11-03 15:33:53 UTC
Description of problem:

In Fedora 21 GNOME switched default terminal background to black. Linux VTs already have black background by default since the beginning of time.

I'm quite aware that there's different default in e.g. xterm, and it's not possible to have a one-size-fits-all theme, however it would be nice if at least the Workstation spin looked sensible by default.

Thank you!

Comment 1 Fedora Update System 2015-02-26 14:21:30 UTC
vim-7.4.640-3.fc22 has been submitted as an update for Fedora 22.
https://admin.fedoraproject.org/updates/vim-7.4.640-3.fc22

Comment 2 Kevin Fenzi 2015-02-26 16:35:25 UTC
Related to this change, I am now getting: 

% vi *.spec
Error detected while processing /etc/vimrc:
line   62:
E488: Trailing characters: # rhbz 1159920
Press ENTER or type command to continue

Perhaps wrong comment char in /etc/vimrc? ;)

Comment 3 Fedora Update System 2015-02-26 17:42:27 UTC
Package vim-7.4.640-3.fc22:
* should fix your issue,
* was pushed to the Fedora 22 testing repository,
* should be available at your local mirror within two days.
Update it with:
# su -c 'yum update --enablerepo=updates-testing vim-7.4.640-3.fc22'
as soon as you are able to.
Please go to the following url:
https://admin.fedoraproject.org/updates/FEDORA-2015-2669/vim-7.4.640-3.fc22
then log in and leave karma (feedback).

Comment 4 Kashyap Chamarthy 2015-03-02 08:37:48 UTC
This bug still affects AArch64.

Despite the fixed version[1]:

  $ rpm -q vim-minimal
  vim-minimal-7.4.640-2.fc23.aarch64


I still notice `vim` fails with:

  $ vi foo.txt
  Error detected while processing /etc/virc:
  line   62:
  E488: Trailing characters: # rhbz 1159920
  Press ENTER or type command to continue


[1] arm.koji.fedoraproject.org/koji/buildinfo?buildID=263610

Comment 5 Fedora Update System 2015-03-02 23:07:47 UTC
Package vim-7.4.640-4.fc22:
* should fix your issue,
* was pushed to the Fedora 22 testing repository,
* should be available at your local mirror within two days.
Update it with:
# su -c 'yum update --enablerepo=updates-testing vim-7.4.640-4.fc22'
as soon as you are able to.
Please go to the following url:
https://admin.fedoraproject.org/updates/FEDORA-2015-2669/vim-7.4.640-4.fc22
then log in and leave karma (feedback).

Comment 6 Lokesh Mandvekar 2015-03-03 20:46:05 UTC
Hi, I was wondering if the rules for setting background for COLORTERM='gnome-terminal' could also be used for COLORTERM='rxvt-xpm' . The latter is what my COLORTERM is set to, and some text appears whited out.

I'm guessing I could get by with modifying my COLORTERM to be gnome-terminal though I don't know offhand if that'll cause other problems. BTW, my terminal emulator is rxvt-unicode.

Comment 7 Fedora Update System 2015-03-13 17:14:08 UTC
vim-7.4.640-4.fc22 has been pushed to the Fedora 22 stable repository.  If problems still persist, please make note of it in this bug report.

Comment 8 Paulo Andrade 2015-03-28 18:56:37 UTC
I had this issue:

$ vi
Error detected while processing /etc/vimrc:
line   62:
E488: Trailing characters: # rhbz 1159920
Press ENTER or type command to continue


$ diff -u /etc/virc{,.rpmnew}
--- /etc/virc   2015-02-26 09:53:51.000000000 -0300
+++ /etc/virc.rpmnew    2015-03-01 22:34:46.000000000 -0300
@@ -59,7 +59,7 @@
      set t_Sf=m
 endif
 
-# rhbz 1159920
+" rhbz 1159920
 if $COLORTERM=="gnome-terminal"
      set background=light
 else

I can correct it manually, but likely will hit others.

Comment 9 Vít Ondruch 2015-05-25 12:46:10 UTC
Wonderful ... so now it breaks GVIM :/ can we revert this until you find out how to reliably detect that VIM is actually running in terminal and that there is dark or light theme used?

Comment 10 Vít Ondruch 2015-05-25 13:06:30 UTC
Moreover, it seems that $COLORTERM is not supported anymore by gnome terminal:

[1] https://bugzilla.redhat.com/show_bug.cgi?id=1166428

Comment 11 Vít Ondruch 2015-05-25 13:58:50 UTC
Also, there is already term_bg_default() in [1] to detect terminal background. If you really want to do something about it, this is probably the right place to start to tinker.


[1] https://code.google.com/p/vim/source/browse/src/option.c

Comment 12 Lubomir Rintel 2015-05-25 15:39:53 UTC
Ouch. term_bg_default() looks terribly hackish now. Possibly a more straightforward fix for now would be something along these lines?

if has("gui_running")
   set bg=light
else
   set bg=dark
endif

Comment 13 Vít Ondruch 2015-05-26 05:23:39 UTC
(In reply to Lubomir Rintel from comment #12)
> Ouch. term_bg_default() looks terribly hackish now. Possibly a more
> straightforward fix for now would be something along these lines?
> 
> if has("gui_running")
>    set bg=light
> else
>    set bg=dark
> endif

Would be definitely better for GVIM, but I am still using light theme for terminal, as it was previously default for ages. So this is not going to help. The best would be either to stick to VIM defaults or improve the detection algorithm. Otherwise there will be always somebody dissatisfied.

Comment 14 Roman Kagan 2015-05-26 11:44:37 UTC
(In reply to Vít Ondruch from comment #13)
> The best would be either to stick to VIM defaults or improve the
> detection algorithm.

+1

And, in the latter case, please make sure to submit it upstream.

Deviating from upstream should normally have a very high bar to be accepted in Fedora.

I suggest to revert the change for now, and let the interested people work with the upstream on a smarter background detection.

Comment 15 Pete Zaitcev 2015-05-28 20:59:08 UTC
I opened a separate bug 1225652 for gvim, before I saw that Vit reopened
this in comment #9. Should I dup it into this?

Comment 16 Roman Kagan 2015-05-28 23:39:56 UTC
Just took a look at the vim sources.

In GUI case it uses gui_bg_default() which is pretty reliable, so in has("gui_running") case you're just defeating that detection.

Yes term_bg_default() is not perfect (in particular, because there's no API to query terminal colors) but it's still better than your unconditional bg=dark, and anyway it's something people have got used to.

So please revert the change.

Comment 17 Lubomir Rintel 2015-05-29 07:48:26 UTC
(In reply to Roman Kagan from comment #16)
> Just took a look at the vim sources.
> 
> In GUI case it uses gui_bg_default() which is pretty reliable, so in
> has("gui_running") case you're just defeating that detection.

That's a good point.

> Yes term_bg_default() is not perfect (in particular, because there's no API
> to query terminal colors) but it's still better

It's precisely completely useless and nothing more.

> than your unconditional
> bg=dark,

No, our default terminal is dark. Dark default for VIM makes sense.

> and anyway it's something people have got used to.

We haven't. Terminal got switched to dark only a release ago.

> So please revert the change.

That makes no sense -- it's going to break the out-of-box experience for terminal vim again.

" rhbz 1159920
if !has("gui_running")
     if $COLORTERM=="gnome-terminal"
         set background=light
     else
         set background=dark
     endif
endif

Something like this seems like an obvious solution (unless someone wants to "do the right thing", design a specification about querying the terminal colors and make the terminal emulators use it).

Comment 18 Till Maas 2015-05-29 09:34:56 UTC
IMHO making vim show unreadable colors by default for all but one terminal should be mentioned in the release notes, since it is an important tool for a lot of users.

Comment 19 Roman Kagan 2015-05-29 11:01:55 UTC
(In reply to Lubomir Rintel from comment #17)
> (In reply to Roman Kagan from comment #16)
> > Yes term_bg_default() is not perfect (in particular, because there's no API
> > to query terminal colors) but it's still better
> 
> It's precisely completely useless and nothing more.

It covers correctly linux console and rxvt derivatives who set $COLORFGBG.  That's already more useful than what's done by this change.

> > So please revert the change.
> 
> That makes no sense -- it's going to break the out-of-box experience for
> terminal vim again.

Disagreed.

You solve a problem for people running vim in the default configuration of gnome terminal, who didn't do this before and who don't know how to tweak it.

Now you break

- people using different terminal emulators (xterm, rxvt, konsole, xfce terminal, etc.); note that rxvt and konsole set $COLORFGBG so for them you defeat the smarter logic of term_bg_default()

- people who've already done adjustments in their setups

- people who ssh to / from different OSes and get different behavior


Please realize that deviating from the upstream is a bad thing in general.  When things don't work for someone, tweaks done in the system configuration by a packager who happened to have different taste from the upstream is the least expected place to look for problems.  People start with searching on the internet or reading the manuals.  Now every such document should contain a special case for the unfortunate sitting on Fedora 22, right?

If you're really up to it submit a patch to vte to set $COLORFGBG corresponding to the color scheme used, and you'll do a big favor not only to vim but to all curses-based programs.

Comment 20 Lubomir Rintel 2015-06-01 09:15:26 UTC
(In reply to Roman Kagan from comment #19)
> If you're really up to it submit a patch to vte to set $COLORFGBG
> corresponding to the color scheme used, and you'll do a big favor not only
> to vim but to all curses-based programs.

Not sure why you're assuming COLORFGBG is a good idea. Seems terrible to me; close to no terminal emulators support it and it's arguably badly designed -- can't react to color scheme changes. An escape code would probably be a better idea; too bad there's no standard one.

Comment 21 Lubomir Rintel 2015-06-01 12:15:54 UTC
Created attachment 1033306 [details]
[PATCH] term: add support for querying background color from XTerm

(In reply to Lubomir Rintel from comment #20)
> (In reply to Roman Kagan from comment #19)
> > If you're really up to it submit a patch to vte to set $COLORFGBG
> > corresponding to the color scheme used, and you'll do a big favor not only
> > to vim but to all curses-based programs.
> 
> Not sure why you're assuming COLORFGBG is a good idea. Seems terrible to me;
> close to no terminal emulators support it and it's arguably badly designed
> -- can't react to color scheme changes. An escape code would probably be a
> better idea; too bad there's no standard one.

Oh, I'm probably a bit retarded: there indeed is an escape sequence for that, implemented by xterm and gnome-terminal; which is good enough for me. I've created a patch for that.

I can't seem to be able to submit it to the list though -- it just bounces back. If anyone knows how to submit a patch for Vim, please feel fee to send it...

Comment 22 Jan Pokorný [poki] 2015-06-01 18:42:19 UTC
For the record, tried Lubomír's patch + enabled termresponse debugging
and it seems that vte may not handle the BG request well per both guake
and lxterminal:

  0.000000: NV setting crv_status to CRV_GET
  0.243374: CL Sending U7 request
  0.243441: CL Sending BG request
  0.245391: NV Sending CRV
  0.260506: NV Received U7 status
  0.260513: NV Received CRV
  0.260524: NV Enable checking for XT codes
  0.260526: NV Requesting XT 0: Co
  0.260527: NV Requesting XT 1: ku
  0.260529: NV Requesting XT 2: kd
  0.260530: NV Requesting XT 3: kr
  0.260531: NV Requesting XT 4: kl
  0.260532: NV Requesting XT 5: #2
  0.260534: NV Requesting XT 6: #4
  0.260535: NV Requesting XT 7: %i
  0.260536: NV Requesting XT 8: *7
  0.260537: NV Requesting XT 9: k1
  0.678088: NV normal character
  0.925835: NV normal character
  0.965814: NV normal character
  1.021590: NV normal character

No idea what's wrong or if anything at all, just my observation.
Let me know if I can help in any way.

(Was affected by "the new behaviour", too).

Comment 23 Jan Pokorný [poki] 2015-06-01 18:46:15 UTC
For the time being, I put following to my .vimrc:

> set background=light

Comment 24 Bradley 2015-06-02 02:46:57 UTC
xfce's terminal sets COLORTERM to xfce-terminal - I edited /etc/vimrc to check for that too. Otherwise perl looks like bright yellow on white, which is unusable...

Comment 25 Panu Matilainen 2015-06-04 11:37:19 UTC
Another freshly updated F22 user here, the new default truly looks terrible (black-on-white xfce-terminal here). Working around in ~/.vimrc is easy enough but it is somewhat annoying to have to work around some supposedly gnome-terminal specific change when I'm specifically NOT using that terminal.

Comment 26 Vít Ondruch 2015-06-08 11:54:57 UTC
(In reply to Lubomir Rintel from comment #17)
> " rhbz 1159920
> if !has("gui_running")
>      if $COLORTERM=="gnome-terminal"
>          set background=light
>      else
>          set background=dark
>      endif
> endif

This is wrong patch, since $COLORTERM was deprecated and is not set anymore by gnoem-terminal. Please let term_bg_default() do its job and fix this function if needed.

Comment 27 Jakob Hirsch 2015-06-08 13:22:38 UTC
Vit is probably right with comment#26.

In the meantime, please think of the mate users and apply this:

-if $COLORTERM=="gnome-terminal"
+if $COLORTERM=="gnome-terminal" || $COLORTERM=="mate-terminal"

or maybe even

+if $COLORTERM =~ "-terminal$"

Or, to also satisfy GVim users

+if has("gui_running") || $COLORTERM =~ "-terminal$"

Comment 28 Lubomir Rintel 2015-07-10 17:57:41 UTC
The offending snipped has now been removed for F23 as Rawhide Vim detects this itself.

Comment 29 Vít Ondruch 2015-07-14 07:01:29 UTC
(In reply to Lubomir Rintel from comment #28)
> The offending snipped has now been removed for F23 as Rawhide Vim detects
> this itself.

Thanks for the upstream patch \ó/

Comment 30 Mike McCune 2016-03-28 22:51:39 UTC
This bug was accidentally moved from POST to MODIFIED via an error in automation, please see mmccune with any questions

Comment 31 Fedora End Of Life 2016-07-19 12:21:42 UTC
Fedora 22 changed to end-of-life (EOL) status on 2016-07-19. Fedora 22 is
no longer maintained, which means that it will not receive any further
security or bug fix updates. As a result we are closing this bug.

If you can reproduce this bug against a currently maintained version of
Fedora please feel free to reopen this bug against that version. If you
are unable to reopen this bug, please file a new report against the
current release. If you experience problems, please add a comment to this
bug.

Thank you for reporting this bug and we are sorry it could not be fixed.

Comment 32 Pavel Raiskup 2017-04-26 13:05:35 UTC
(In reply to Lubomir Rintel from comment #21)
> Created attachment 1033306 [details]
> [PATCH] term: add support for querying background color from XTerm

After some time that this worked for me on F25, I noticed after some time
that vim-enhanced-8.0.562-1.fc25.x86_64 regressed back and that Lubomír
patch doesn't work for some reason.  IOW, that vim and terminal are not
able to automatically agree on correct background color (in my case, I
should have 'set bg=dark', but I have the wrong 'set bg=light').

Note that I have F25 server (not yet updated) where I have the old
vim-enhanced-8.0.514-1.fc25.x86_64, and that (also remote) vim is able to
chat with my local terminal (konsole in KDE5) and the background is set
correctly.

So the bug is vim (not in my terminal).  Let me know if we need more info.

Comment 33 Pavel Raiskup 2017-04-26 13:08:08 UTC
Reproduced in gnome-terminal.  Note that in KDE's konsole you need to first
unset COLORFGBG variable to be able to reproduce this bug.

Comment 34 Jan Kurik 2018-05-31 09:03:04 UTC
This bug is currently reported against a Fedora version which is already unsuported.
I am changing the version to '27', the latest supported release.

Please check whether this bug is still an issue on the '27' release.
If you find this bug not being applicable on this release, please close it.

Comment 35 Pavel Raiskup 2018-08-01 05:32:20 UTC
It is working fine again, on f28.


Note You need to log in before you can comment on or make changes to this bug.