Bug 247248

Summary: editors/emacs: fix 24-bit colors in text mode
Product: Ports & Packages Reporter: Jan Beich <jbeich>
Component: Individual Port(s)Assignee: Jan Beich <jbeich>
Status: Closed FIXED    
Severity: Affects Only Me CC: emacs, jrm
Priority: --- Keywords: needs-qa, patch
Version: LatestFlags: jrm: maintainer-feedback+
Hardware: Any   
OS: Any   
Attachments:
Description Flags
v1
none
v1.1 (emacs)
none
v1.1 (emacs-devel) none

Description Jan Beich freebsd_committer freebsd_triage 2020-06-14 08:16:18 UTC
Created attachment 215536 [details]
v1

Base libncurses is stuck with termcap(5) but setb24/setf24 capabilities can only be expressed via terminfo(5). Work around via environ(7) variable that some terminal emulators define by default.

Disclaimer: I'm just looking for more testers while waiting for upstream review.

Wayland example:

  $ pkg install emacs-devel-nox alacritty libxkbcommon mesa-dri dejavu
  $ alacritty
  $ emacs -nw -Q -f list-colors-display

X11 example:

  $ pkg install emacs-devel-nox xterm
  $ xterm -tn xterm-256color
  $ export COLORTERM=truecolor
  $ emacs -nw -Q -f list-colors-display

Agnostic example:

  $ pkg install tmux
  $ tmux
  $ tmux set -g default-terminal tmux-256color
  $ tmux set -as terminal-overrides ',*256col*:Tc'
  $ emacs -nw -Q -f list-colors-display
Comment 1 Joseph Mingrone freebsd_committer freebsd_triage 2020-06-14 10:52:22 UTC
Thanks for submitting.  

Upstream report: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=41846
Comment 2 Jan Beich freebsd_committer freebsd_triage 2020-06-20 10:18:36 UTC
Created attachment 215806 [details]
v1.1 (emacs)

Landed upstream with minor formatting changes.
https://github.com/emacs-mirror/emacs/commit/50f489b5dc59

Can you approve now?
Comment 3 Jan Beich freebsd_committer freebsd_triage 2020-06-20 10:19:27 UTC
Created attachment 215807 [details]
v1.1 (emacs-devel)

Update emacs-devel instead of wasting time on cherry-picking.
https://github.com/emacs-mirror/emacs/compare/f4b99b3...3af631d
https://reviews.freebsd.org/P397 (poudriere testport)
Comment 4 Joseph Mingrone freebsd_committer freebsd_triage 2020-06-20 11:43:55 UTC
Sorry for the delay.  Both Ashish and I did spend a fair bit of time discussing and testing this.  It took some time (for me) to completely figure out what was going on because different terminals behaved differently.

Thanks again for this.
Comment 5 commit-hook freebsd_committer freebsd_triage 2020-06-20 13:39:57 UTC
A commit references this bug:

Author: jbeich
Date: Sat Jun 20 13:39:50 UTC 2020
New revision: 539734
URL: https://svnweb.freebsd.org/changeset/ports/539734

Log:
  editors/emacs: backport 24-bit color fix for tty mode

  libncurses in base system only supports termcap(5). RGB has 3 colors
  but termcap(5) supports at most 2 arguments e.g.,

    $ export TERMCAP="${TERM}:Co#0x1000000:AF=\E[38;2;%d;%d;%dm:AB=\E[48;2;%d;%d;%dm:tc=${TERM}:"
    $ tput AB 1 1 1
    tput: too many arguments (3) for capability `AB'

  To work around the limitation make Emacs check if environ(7) has
  COLORTERM=truecolor some terminal emulators define by default e.g.,

  - x11-toolkits/vte3 (gnome-terminal, sakura, ...)
  - x11/alacritty
  - x11/aminal
  - x11/kitty (bug 233010)
  - x11/konsole
  - x11/qterminal

  while others require defining COLORTERM=truecolor manually e.g.,

  - x11/cool-retro-term
  - x11/sterm
  - x11/xterm

  PR:		247248
  Approved by:	jrm
  Obtained from:	upstream

Changes:
  head/editors/emacs/Makefile
  head/editors/emacs/files/patch-tty-rgb
Comment 6 commit-hook freebsd_committer freebsd_triage 2020-06-20 13:40:58 UTC
A commit references this bug:

Author: jbeich
Date: Sat Jun 20 13:40:01 UTC 2020
New revision: 539735
URL: https://svnweb.freebsd.org/changeset/ports/539735

Log:
  editors/emacs-devel: update to 2020-06-20 commit 3af631d

  Pick up recent 24-bit color fix from upstream.

  Changes:	https://github.com/emacs-mirror/emacs/compare/f4b99b3...3af631d
  PR:		247248
  Approved by:	jrm

Changes:
  head/editors/emacs-devel/Makefile
  head/editors/emacs-devel/distinfo