GNU logs - #62994, boring messages


Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#62994: Support styled underlines on TTY frames
Resent-From: Mohsin Kaleem <mohkale@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Fri, 21 Apr 2023 14:30:02 +0000
Resent-Message-ID: <handler.62994.B.168208734930664 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: report 62994
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: 
To: 62994 <at> debbugs.gnu.org
X-Debbugs-Original-To: bug-gnu-emacs@HIDDEN
Received: via spool by submit <at> debbugs.gnu.org id=B.168208734930664
          (code B ref -1); Fri, 21 Apr 2023 14:30:02 +0000
Received: (at submit) by debbugs.gnu.org; 21 Apr 2023 14:29:09 +0000
Received: from localhost ([127.0.0.1]:40888 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1pprl7-0007yV-E4
	for submit <at> debbugs.gnu.org; Fri, 21 Apr 2023 10:29:09 -0400
Received: from lists.gnu.org ([209.51.188.17]:52394)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <mohkale@HIDDEN>) id 1pprl4-0007yL-TY
 for submit <at> debbugs.gnu.org; Fri, 21 Apr 2023 10:29:07 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10])
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <mohkale@HIDDEN>)
 id 1pprl4-000633-Jb
 for bug-gnu-emacs@HIDDEN; Fri, 21 Apr 2023 10:29:06 -0400
Received: from 119.ip-51-38-65.eu ([51.38.65.119] helo=mail.kisara.moe)
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <mohkale@HIDDEN>)
 id 1pprl2-0008Cd-S9
 for bug-gnu-emacs@HIDDEN; Fri, 21 Apr 2023 10:29:06 -0400
Received: from mk-deck (unknown [146.70.132.151])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange ECDHE (prime256v1) server-signature ECDSA (prime256v1)
 server-digest SHA256) (No client certificate requested)
 by mail.kisara.moe (Postfix) with ESMTPSA id 60CD5A0FB5
 for <bug-gnu-emacs@HIDDEN>; Fri, 21 Apr 2023 16:29:03 +0200 (CEST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kisara.moe;
 s=default; t=1682087343;
 bh=7Z/qBttNDOYr4v4iSaQSEkrNmVcg3Ditk4IGKVYIuCg=;
 h=From:To:Subject:Date:From;
 b=eXbHf9vy79vFxKwVSUOhZdyr0llPOAcweySoELfYYyimcdj4ryhUnZwH9JEjOoVo+
 9+H3PSiTRE3ZD8eMNpUy8EHblenkGHz9B6ukfXud9tdwTvDKnJuyaUhkCUc7dpeB6G
 jSLyW6Z/8q7NrswKWcOAxqxR8fj7WGcE4erow9yv/5Ed8LXTYlvqR5JPb7V54BoJeg
 lQjCdK3OKcsZEhAiVdjVuYU4coSBrHgynvgjrxdXnvB61AmJvRauKL4PlfGZia68D3
 ADPrznBWKaxPZBYfSnBk7PNqaNj8vt3Njqk9NrOcDGmMa/A1mPgPYBsgWZBHqP15rm
 FPWww1ZIzMgtg==
From: Mohsin Kaleem <mohkale@HIDDEN>
Date: Fri, 21 Apr 2023 15:29:03 +0100
Message-ID: <87pm7x5mxc.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain
Received-SPF: pass client-ip=51.38.65.119; envelope-from=mohkale@HIDDEN;
 helo=mail.kisara.moe
X-Spam_score_int: -6
X-Spam_score: -0.7
X-Spam_bar: /
X-Spam_report: (-0.7 / 5.0 requ) BAYES_00=-1.9, DKIM_INVALID=0.1,
 DKIM_SIGNED=0.1, RDNS_DYNAMIC=0.982, SPF_HELO_NONE=0.001, SPF_PASS=-0.001,
 T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no
X-Spam_action: no action
X-Spam-Score: -1.3 (-)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -2.3 (--)


Hi,

Support for styled underlines double, wave, dotted and dashed is a
relatively recent inclusion for newer terminal emulators. It's exposed
through either the Smulx or Su termcap (the former being an escape
sequence and the latter just a flag). Furthermore. despite not having a
dedicated termcap, these extensions also support colored underlines
through a separate escape sequence; making it possible to have an
underline with a different color to the foreground.

I'd like to add support for these to Emacs. Looking on the mailing list
it seems there's some prior efforts for this but none seem to have had
any traction. I've been working on a patch for these and will submit it
in reply to this message chain.

For testing I've been using kitty. If building with this patch series
you can view the underlines in the scratch buffer like so:

  ./src/emacs -nw -q --eval '(set-face-attribute (quote font-lock-comment-delimiter-face) nil :underline (list :style (quote wave) :color "blue"))'

-- 
Mohsin Kaleem




Message sent:


Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
MIME-Version: 1.0
X-Mailer: MIME-tools 5.505 (Entity 5.505)
Content-Type: text/plain; charset=utf-8
X-Loop: help-debbugs@HIDDEN
From: help-debbugs@HIDDEN (GNU bug Tracking System)
To: Mohsin Kaleem <mohkale@HIDDEN>
Subject: bug#62994: Acknowledgement (Support styled underlines on TTY frames)
Message-ID: <handler.62994.B.168208734930664.ack <at> debbugs.gnu.org>
References: <87pm7x5mxc.fsf@HIDDEN>
X-Gnu-PR-Message: ack 62994
X-Gnu-PR-Package: emacs
Reply-To: 62994 <at> debbugs.gnu.org
Date: Fri, 21 Apr 2023 14:30:02 +0000

Thank you for filing a new bug report with debbugs.gnu.org.

This is an automatically generated reply to let you know your message
has been received.

Your message is being forwarded to the package maintainers and other
interested parties for their attention; they will reply in due course.

Your message has been sent to the package maintainer(s):
 bug-gnu-emacs@HIDDEN

If you wish to submit further information on this problem, please
send it to 62994 <at> debbugs.gnu.org.

Please do not send mail to help-debbugs@HIDDEN unless you wish
to report a problem with the Bug-tracking system.

--=20
62994: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D62994
GNU Bug Tracking System
Contact help-debbugs@HIDDEN with problems


Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#62994: [PATCH 3/3] Add support for colored underlines on tty frames
Resent-From: mohkale@HIDDEN
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Fri, 21 Apr 2023 14:35:02 +0000
Resent-Message-ID: <handler.62994.B62994.16820877008176 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 62994
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: 
To: 62994 <at> debbugs.gnu.org
Cc: Mohsin Kaleem <mohkale@HIDDEN>
Received: via spool by 62994-submit <at> debbugs.gnu.org id=B62994.16820877008176
          (code B ref 62994); Fri, 21 Apr 2023 14:35:02 +0000
Received: (at 62994) by debbugs.gnu.org; 21 Apr 2023 14:35:00 +0000
Received: from localhost ([127.0.0.1]:40896 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1pprqm-00027m-6t
	for submit <at> debbugs.gnu.org; Fri, 21 Apr 2023 10:35:00 -0400
Received: from 119.ip-51-38-65.eu ([51.38.65.119]:50934 helo=mail.kisara.moe)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <mohkale@HIDDEN>) id 1pprqk-00027M-5O
 for 62994 <at> debbugs.gnu.org; Fri, 21 Apr 2023 10:34:58 -0400
Received: from localhost.localdomain (unknown [146.70.132.151])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256)
 (No client certificate requested)
 by mail.kisara.moe (Postfix) with ESMTPSA id 592EAA2628;
 Fri, 21 Apr 2023 16:34:57 +0200 (CEST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kisara.moe;
 s=default; t=1682087697;
 bh=t33oX0sXqUq7T1CcDC/ciaAy8AR7Q6aYzgRroQUbh/Y=;
 h=From:To:Cc:Subject:Date:In-Reply-To:References:From;
 b=uXzqlvfyrja53qzjV9tv5yq/7POmg5vcUE+JY4il0FjXw2rT2RaZr1lK8n4Es/u7/
 tkuCiO4NbHwj297F5qRhLG5AiddVTvgytDtZHDEU993TWBtgYrckweGx5Wvy3Ni3eg
 4ZH/D6RZQeKoGOEhStSiFhJWQWGLJ8bv1TkPl1CvgbGJoamwzkXhEDAWID5VScstm9
 tgp80krcXPuWNIlsiwnzapx+xm1QbIQowtfvawQWVzrNASVZYK5+r93dW3FfgLoH4E
 6gtbhLADsrmcJLVk03YuoEpxCnpHj/Tn3VF883EE280tXP17moI4wKuxvwhmD5HuSC
 KU0W1FJT7rm9g==
From: mohkale@HIDDEN
Date: Fri, 21 Apr 2023 15:34:48 +0100
Message-Id: <20230421143448.339022-4-mohkale@HIDDEN>
X-Mailer: git-send-email 2.40.0
In-Reply-To: <20230421143448.339022-1-mohkale@HIDDEN>
References: <handler.62994.B.168208734930664.ack <at> debbugs.gnu.org>
 <20230421143448.339022-1-mohkale@HIDDEN>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
X-Spam-Score: 0.4 (/)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.6 (/)

From: Mohsin Kaleem <mohkale@HIDDEN>

* src/term.c (turn_on_face, init_tty): Output escape sequence to set
underline color when set in the face and supported by the tty. Save
a default value for this sequence on init_tty when styled underlines
are supported.
* src/termchar.c (tty_display_info): Add an entry for the escape
sequence to set the underline color on terminal frames.
* src/xfaces.c (tty_supports_face_attributes_p, realize_tty_face):
Assert whether colored underlines are supported by the current terminal
on display-supports-face-attributes-p checks. Load and save the color
of the underline from the face spec when realizing a face.
---
 etc/NEWS       | 11 +++++++----
 src/term.c     | 11 +++++++++++
 src/termchar.h |  3 +++
 src/xfaces.c   | 16 +++++++++++++---
 4 files changed, 34 insertions(+), 7 deletions(-)

diff --git a/etc/NEWS b/etc/NEWS
index 9f34927dfad..46b2b0e25c5 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -1917,20 +1917,23 @@ exist, the command creates it first.  You can use this command if you
 inadvertently delete the "*scratch*" buffer.
 
 ---
-** Support for 'styled-underline' face attributes on TTY frames
+** Support for 'styled' and 'colored' underline face attributes on TTY frames
 If your terminals termcap or terminfo database entry has the 'Su' or
 'Smulx' capability defined, Emacs will now emit the prescribed escape
 sequence necessary to render faces with styled underlines on TTY
 frames.
 
 Styled underlines are any underlines containing a non-default
-underline style.  The available underline styles for TTY frames are
-'double', 'wave', 'dotted', and 'dashed'.
+underline style or a color other than the foreground-color.
+The available underline styles for TTY frames are 'double', 'wave',
+'dotted', and 'dashed'.
 
 The 'Smulx' capability should define the actual sequence needed to
 render styled underlines. If ommitted, but the 'Su' flag is defined,
 then a default sequence will be used. It's recommended to use 'Smulx'
-instead of 'Su', with priority being given to 'Smulx'.
+instead of 'Su', with priority being given to 'Smulx'.  Support for
+colored underlines is automatically enabled with a default escape
+sequence when styled underline are supported.
 
 ** Debugging
 
diff --git a/src/term.c b/src/term.c
index 0f0393780eb..a1eb1961fad 100644
--- a/src/term.c
+++ b/src/term.c
@@ -1984,6 +1984,14 @@ turn_on_face (struct frame *f, int face_id)
 	  OUTPUT (tty, p);
 	  xfree (p);
 	}
+
+      ts = tty->TF_set_underline_color;
+      if (ts && face->underline_color)
+	{
+          p = tparam (ts, NULL, 0, face->underline_color, 0, 0, 0);
+	  OUTPUT (tty, p);
+	  xfree (p);
+	}
     }
 }
 
@@ -4277,6 +4285,9 @@ init_tty (const char *name, const char *terminal_type, bool must_succeed)
   if (!tty->TF_set_underline_style && tgetflag("Su"))
     tty->TF_set_underline_style = "\x1b[4:%p1%dm";
 
+  if (tty->TF_set_underline_style)
+    tty->TF_set_underline_color = "\x1b[58:2::%p1%{65536}%/%d:%p1%{256}%/%{255}%&%d:%p1%{255}%&%dm";
+
 #else /* DOS_NT */
 #ifdef WINDOWSNT
   {
diff --git a/src/termchar.h b/src/termchar.h
index 319c2319fba..563cde715ec 100644
--- a/src/termchar.h
+++ b/src/termchar.h
@@ -175,6 +175,9 @@ #define EMACS_TERMCHAR_H
                                            style based on the parameter. Param should
                                            be one of: 0 (none), 1 (straight), 2 (double),
                                            3 (wave), 4 (dotted), or 5 (dashed). */
+  const char *TF_set_underline_color;   /* Enabled when TF_set_underline_style is set:
+                                           Sets the color of the underline. Accepts a
+                                           single parameter, the color index. */
 
   int RPov;                     /* # chars to start a TS_repeat */
 
diff --git a/src/xfaces.c b/src/xfaces.c
index 2c6c554d01d..c547a0b92f3 100644
--- a/src/xfaces.c
+++ b/src/xfaces.c
@@ -5407,7 +5407,7 @@ tty_supports_face_attributes_p (struct frame *f,
   if (!UNSPECIFIEDP (val))
     {
       if (STRINGP (val))
-	return false;		/* ttys can't use colored underlines */
+	test_caps |= TTY_CAP_UNDERLINE_STYLED;
       else if (EQ (CAR_SAFE (val), QCstyle))
     {
         if (!(EQ (CAR_SAFE (CDR_SAFE (val)), Qline) ||
@@ -6510,14 +6510,18 @@ realize_tty_face (struct face_cache *cache,
   underline = attrs[LFACE_UNDERLINE_INDEX];
   if (NILP (underline)) {
     face->tty_underline = FACE_NO_UNDERLINE;
+    face->underline_color = 0;
   } else if (EQ (underline, Qt)) {
     face->tty_underline = FACE_UNDER_LINE;
+    face->underline_color = 0;
   } else if (STRINGP (underline)) {
     face->tty_underline = FACE_UNDER_LINE;
+	face->underline_color = load_color (f, face, underline, LFACE_UNDERLINE_INDEX);
   } else if (CONSP (underline)) {
-    /* `(:style STYLE)'.
+    /* `(:color COLOR :style STYLE)'.
        STYLE being one of `line', `double', `wave', `dotted' or `dashed'. */
     face->tty_underline = FACE_UNDER_LINE;
+    face->underline_color = 0;
 
     while (CONSP (underline)) {
       Lisp_Object keyword, value;
@@ -6530,7 +6534,13 @@ realize_tty_face (struct face_cache *cache,
       value = XCAR (underline);
       underline = XCDR (underline);
 
-      if (EQ (keyword, QCstyle)) {
+      if (EQ (keyword, QCcolor)) {
+        if (EQ (value, Qforeground_color))
+          face->underline_color = 0;
+        else if (STRINGP (value))
+          face->underline_color = load_color (f, face, value, LFACE_UNDERLINE_INDEX);
+      }
+      else if (EQ (keyword, QCstyle)) {
         if (EQ (value, Qline))
           face->tty_underline = FACE_UNDER_LINE;
         else if (EQ (value, Qdouble))
-- 
2.40.0





Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#62994: [PATCH 1/3] Add face definitions for more underline styles
Resent-From: mohkale@HIDDEN
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Fri, 21 Apr 2023 14:35:02 +0000
Resent-Message-ID: <handler.62994.B62994.16820877018183 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 62994
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: 
To: 62994 <at> debbugs.gnu.org
Cc: Mohsin Kaleem <mohkale@HIDDEN>
Received: via spool by 62994-submit <at> debbugs.gnu.org id=B62994.16820877018183
          (code B ref 62994); Fri, 21 Apr 2023 14:35:02 +0000
Received: (at 62994) by debbugs.gnu.org; 21 Apr 2023 14:35:01 +0000
Received: from localhost ([127.0.0.1]:40898 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1pprqm-00027p-Mr
	for submit <at> debbugs.gnu.org; Fri, 21 Apr 2023 10:35:01 -0400
Received: from 119.ip-51-38-65.eu ([51.38.65.119]:50922 helo=mail.kisara.moe)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <mohkale@HIDDEN>) id 1pprqk-00027K-DF
 for 62994 <at> debbugs.gnu.org; Fri, 21 Apr 2023 10:34:58 -0400
Received: from localhost.localdomain (unknown [146.70.132.151])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256)
 (No client certificate requested)
 by mail.kisara.moe (Postfix) with ESMTPSA id EF084A0FFD;
 Fri, 21 Apr 2023 16:34:56 +0200 (CEST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kisara.moe;
 s=default; t=1682087697;
 bh=MACAnbePtzTXRa64Wk+6bZen9m50SG7jCDxm0mEHB3A=;
 h=From:To:Cc:Subject:Date:In-Reply-To:References:From;
 b=NkLO6Zq5ITdE6XuUooHs0DImO3YYZIVkzSLeJL6b1d/sdB0Desd3dyRjT+8sn2k34
 LspsUXoRu16BjSNHEwZFFu0lt8VhcopCdK/ooefDCMT+KanT6su4HzeJXQRMSVRceP
 +kRra1Hf29KuuLPSvOYp7JuO3pQXnNrc2NGQEHax+tkXeiWxMaNYqxlOm99xiMikKv
 ZDc0immIHcCure5MyAWsrKavGo1k/t2AGYpeUjHzJJepwqtEDsygPqDz2ItkyNIyhs
 o7mMtSTAgkVr3r5oiICIqGusk5cgsdH+2CFRQ/NNkqKCyZXyV5r+OPZ0NZEuAkXmZz
 QMSR2XphbzHyw==
From: mohkale@HIDDEN
Date: Fri, 21 Apr 2023 15:34:46 +0100
Message-Id: <20230421143448.339022-2-mohkale@HIDDEN>
X-Mailer: git-send-email 2.40.0
In-Reply-To: <20230421143448.339022-1-mohkale@HIDDEN>
References: <handler.62994.B.168208734930664.ack <at> debbugs.gnu.org>
 <20230421143448.339022-1-mohkale@HIDDEN>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
X-Spam-Score: 0.4 (/)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.6 (/)

From: Mohsin Kaleem <mohkale@HIDDEN>

* src/dispextern.h (face_underline_type, syms_of_xfacse,
internal-set-lisp-face-attribute, gui_supports_face_attributes_p):
Add definitions for new underline styles of Double, Dotted and Dashed.
* lisp/cus-face.el (custom-face-attributes): Add entries for Double,
Dotted and Dashed so they can be set through `customize'.
---
 lisp/cus-face.el |  5 ++++-
 src/dispextern.h |  8 ++++++--
 src/xfaces.c     | 21 ++++++++++++++++++++-
 3 files changed, 30 insertions(+), 4 deletions(-)

diff --git a/lisp/cus-face.el b/lisp/cus-face.el
index ec89b4f7ff6..2d6e6c7b73e 100644
--- a/lisp/cus-face.el
+++ b/lisp/cus-face.el
@@ -141,7 +141,10 @@ custom-face-attributes
 		   (const :format "" :value :style)
 		   (choice :tag "Style"
 			   (const :tag "Line" line)
-			   (const :tag "Wave" wave))
+			   (const :tag "Double" double)
+			   (const :tag "Wave" wave)
+			   (const :tag "Dotted" dotted)
+			   (const :tag "Dashed" dashed))
                    (const :format "" :value :position)
                    (choice :tag "Position"
                            (const :tag "At Default Position" nil)
diff --git a/src/dispextern.h b/src/dispextern.h
index 4dcab113ea2..1dc84e32efc 100644
--- a/src/dispextern.h
+++ b/src/dispextern.h
@@ -1653,9 +1653,13 @@ #define FONT_TOO_HIGH(ft)						\
 
 enum face_underline_type
 {
+  // Note: Order matches the order of the Smulx terminfo extension.
   FACE_NO_UNDERLINE = 0,
   FACE_UNDER_LINE,
-  FACE_UNDER_WAVE
+  FACE_DOUBLE_UNDER_LINE,
+  FACE_UNDER_WAVE,
+  FACE_DOTTED_UNDER_LINE,
+  FACE_DASHED_UNDER_LINE,
 };
 
 /* Structure describing a realized face.
@@ -1737,7 +1741,7 @@ #define FONT_TOO_HIGH(ft)						\
   ENUM_BF (face_box_type) box : 2;
 
   /* Style of underlining. */
-  ENUM_BF (face_underline_type) underline : 2;
+  ENUM_BF (face_underline_type) underline : 3;
 
   /* If `box' above specifies a 3D type, true means use box_color for
      drawing shadows.  */
diff --git a/src/xfaces.c b/src/xfaces.c
index 37b703984be..cfbb89d2ae2 100644
--- a/src/xfaces.c
+++ b/src/xfaces.c
@@ -3255,7 +3255,11 @@ DEFUN ("internal-set-lisp-face-attribute", Finternal_set_lisp_face_attribute,
                 }
 
               else if (EQ (key, QCstyle)
-                       && !(EQ (val, Qline) || EQ (val, Qwave)))
+                       && !(EQ (val, Qline) ||
+                            EQ (val, Qdouble) ||
+                            EQ (val, Qwave) ||
+                            EQ (val, Qdotted) ||
+                            EQ (val, Qdashed)))
                 {
                   valid_p = false;
                   break;
@@ -5204,6 +5208,7 @@ gui_supports_face_attributes_p (struct frame *f,
                                 Lisp_Object attrs[LFACE_VECTOR_SIZE],
                                 struct face *def_face)
 {
+  Lisp_Object val;
   Lisp_Object *def_attrs = def_face->lface;
   Lisp_Object lattrs[LFACE_VECTOR_SIZE];
 
@@ -5298,6 +5303,17 @@ gui_supports_face_attributes_p (struct frame *f,
       return false;
     }
 
+  /* Check supported underline styles. */
+  val = attrs[LFACE_UNDERLINE_INDEX];
+  if (!UNSPECIFIEDP (val)) {
+    if (EQ (CAR_SAFE (val), QCstyle)) {
+      if (!(EQ (CAR_SAFE (CDR_SAFE (val)), Qline) ||
+            EQ (CAR_SAFE (CDR_SAFE (val)), Qwave))) {
+        return false; /* Unsupported underline style */
+      }
+    }
+  }
+
   /* Everything checks out, this face is supported.  */
   return true;
 }
@@ -7165,6 +7181,9 @@ syms_of_xfaces (void)
   DEFSYM (QCposition, ":position");
   DEFSYM (Qline, "line");
   DEFSYM (Qwave, "wave");
+  DEFSYM (Qdouble, "double");
+  DEFSYM (Qdotted, "dotted");
+  DEFSYM (Qdashed, "dashed");
   DEFSYM (Qreleased_button, "released-button");
   DEFSYM (Qpressed_button, "pressed-button");
   DEFSYM (Qflat_button, "flat-button");
-- 
2.40.0





Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#62994: [PATCH 0/3] Support styled underlines on tty Emacs frames
Resent-From: mohkale@HIDDEN
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Fri, 21 Apr 2023 14:35:03 +0000
Resent-Message-ID: <handler.62994.B62994.16820877018199 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 62994
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: 
To: 62994 <at> debbugs.gnu.org
Cc: Mohsin Kaleem <mohkale@HIDDEN>
Received: via spool by 62994-submit <at> debbugs.gnu.org id=B62994.16820877018199
          (code B ref 62994); Fri, 21 Apr 2023 14:35:03 +0000
Received: (at 62994) by debbugs.gnu.org; 21 Apr 2023 14:35:01 +0000
Received: from localhost ([127.0.0.1]:40900 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1pprqn-00027w-4H
	for submit <at> debbugs.gnu.org; Fri, 21 Apr 2023 10:35:01 -0400
Received: from 119.ip-51-38-65.eu ([51.38.65.119]:50920 helo=mail.kisara.moe)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <mohkale@HIDDEN>) id 1pprqk-00027I-FC
 for 62994 <at> debbugs.gnu.org; Fri, 21 Apr 2023 10:34:59 -0400
Received: from localhost.localdomain (unknown [146.70.132.151])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256)
 (No client certificate requested)
 by mail.kisara.moe (Postfix) with ESMTPSA id C0213A0FB5;
 Fri, 21 Apr 2023 16:34:56 +0200 (CEST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kisara.moe;
 s=default; t=1682087696;
 bh=XFpsSx02gDB45l8XVNct2F+AzVVDJGogGaWWgFucaWk=;
 h=From:To:Cc:Subject:Date:In-Reply-To:References:From;
 b=Fv5xda+DVjWoTVu9r9JwjKs9uFKfaSUqQd5/aj24jyjb9u8t5dHO0npw1+P1d+Tli
 UI9BPABY/MUPBDIvdWoS3ikRfWFg2ErRPiBXOe5ybIGqQ778nOSHwgY6WZlFiu32O+
 bxGPp3xWM2j6z2Zczy05U2q/PM7L1jxRVYw/vAY6owwXFuTJuisUeuGfR5KE00Co3H
 WdiPvrszrDzHnafuJSJKHsINE4lJ9GgTSCt1dq77Rcsf8LwZV5tbAvNGB6gI3fm9Ui
 0E1xJH/cHlLfQSiGoO3oaXiouKI7SMgXlwALEMZ6PgGqf08V/jumo+EwR9ZqELELdi
 4CNwozqlTxrdg==
From: mohkale@HIDDEN
Date: Fri, 21 Apr 2023 15:34:45 +0100
Message-Id: <20230421143448.339022-1-mohkale@HIDDEN>
X-Mailer: git-send-email 2.40.0
In-Reply-To: <handler.62994.B.168208734930664.ack <at> debbugs.gnu.org>
References: <handler.62994.B.168208734930664.ack <at> debbugs.gnu.org>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
X-Spam-Score: 0.4 (/)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.6 (/)

From: Mohsin Kaleem <mohkale@HIDDEN>

Modern terminals (such as kitty) support setting the style of an
underline with the escape sequence exposed in the Smulx termcap.
This allows for (among others) wavy underlines on terminals.
These terminals also support setting the color of these underlines
using a separate escape sequence that to the best of my knowledge
is not exposed as a termcap but has been adopted by other terminal
supporting editors like neovim.

Mohsin Kaleem (3):
  Add face definitions for more underline styles
  Add support for styled underlines on tty frames
  Add support for colored underlines on tty frames

 etc/NEWS         | 19 ++++++++++
 lisp/cus-face.el |  5 ++-
 src/dispextern.h | 11 ++++--
 src/term.c       | 46 +++++++++++++++++++++---
 src/termchar.h   |  7 ++++
 src/xfaces.c     | 93 ++++++++++++++++++++++++++++++++++++++++++++----
 6 files changed, 167 insertions(+), 14 deletions(-)

-- 
2.40.0





Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#62994: [PATCH 2/3] Add support for styled underlines on tty frames
Resent-From: mohkale@HIDDEN
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Fri, 21 Apr 2023 14:35:03 +0000
Resent-Message-ID: <handler.62994.B62994.16820877028214 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 62994
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: 
To: 62994 <at> debbugs.gnu.org
Cc: Mohsin Kaleem <mohkale@HIDDEN>
Received: via spool by 62994-submit <at> debbugs.gnu.org id=B62994.16820877028214
          (code B ref 62994); Fri, 21 Apr 2023 14:35:03 +0000
Received: (at 62994) by debbugs.gnu.org; 21 Apr 2023 14:35:02 +0000
Received: from localhost ([127.0.0.1]:40902 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1pprqn-00028A-JW
	for submit <at> debbugs.gnu.org; Fri, 21 Apr 2023 10:35:02 -0400
Received: from 119.ip-51-38-65.eu ([51.38.65.119]:50928 helo=mail.kisara.moe)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <mohkale@HIDDEN>) id 1pprqk-00027L-DE
 for 62994 <at> debbugs.gnu.org; Fri, 21 Apr 2023 10:34:59 -0400
Received: from localhost.localdomain (unknown [146.70.132.151])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256)
 (No client certificate requested)
 by mail.kisara.moe (Postfix) with ESMTPSA id 29B47A1048;
 Fri, 21 Apr 2023 16:34:57 +0200 (CEST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kisara.moe;
 s=default; t=1682087697;
 bh=DYJ5stR2mmjQ0R3OxuHOQBosBW2qKtAgRGPApbR9KR0=;
 h=From:To:Cc:Subject:Date:In-Reply-To:References:From;
 b=HThfDmCuKEFwwQmN4LLn/BsMraHTkpyYl2g5p5KwUh0fHwJmY7EAEWZ419m/kL47b
 u0m73LH0y/Pi/KEUVWz1VGYT/UEW5FBqvkyxWRV4Tv5UhgLn0P2t6azoKeTMhhi2X1
 MhRHC3bCXxwHHjhiODF3iJUJOs18woNzQT76PrjI1QgV9YqkIRe44w/R6xbkCAdwa7
 Zt+t7G6APw1YSUkXzGQQuRe2EhheckGVit4tTb5zb/eITjDvybkGab037vxZv5I88h
 8Hp6hSi5VJK94LEUcQdTZuNRFvpAxXC7dQKSeFRsVUILRMQ50gs/fDRErgzDdQPzZN
 VrdECm2GMXDmg==
From: mohkale@HIDDEN
Date: Fri, 21 Apr 2023 15:34:47 +0100
Message-Id: <20230421143448.339022-3-mohkale@HIDDEN>
X-Mailer: git-send-email 2.40.0
In-Reply-To: <20230421143448.339022-1-mohkale@HIDDEN>
References: <handler.62994.B.168208734930664.ack <at> debbugs.gnu.org>
 <20230421143448.339022-1-mohkale@HIDDEN>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
X-Spam-Score: 0.4 (/)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.6 (/)

From: Mohsin Kaleem <mohkale@HIDDEN>

* src/dispextern.h (face): Convert tty_underline_p from bool to a
face_underline_type enumeration. Add a flag to check whether styled
underlines are available.
* src/termchar.c (tty_display_info): Add an entry for the escape
sequence to set the underline style on terminal frames.
* src/term.c (init_tty, tty_capable_p, turn_on_face): Read and save the
underline style escape sequence from the Smulx termcap (alternatively if
the Su flag is set use a default sequence). Allow checking for support
of styled underlines in the current terminal frame. Output the necessary
escape sequences to activate a styled underline on turn_on_face; this is
currently only used for the new special underline styles, a default
straight underline will still use the "us" termcap.
* src/xfaces.c (tty_supports_face_attributes_p, realize_tty_face):
Assert whether styled underlines are supported by the current terminal
on display-supports-face-attributes-p checks. Populate the correct
underline style in the face spec when realizing a face.
---
 etc/NEWS         | 16 +++++++++++++
 src/dispextern.h |  3 ++-
 src/term.c       | 35 ++++++++++++++++++++++++----
 src/termchar.h   |  4 ++++
 src/xfaces.c     | 60 ++++++++++++++++++++++++++++++++++++++++++++----
 5 files changed, 109 insertions(+), 9 deletions(-)

diff --git a/etc/NEWS b/etc/NEWS
index 62d2fdcd3a4..9f34927dfad 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -1916,6 +1916,22 @@ This command switches to the "*scratch*" buffer.  If "*scratch*" doesn't
 exist, the command creates it first.  You can use this command if you
 inadvertently delete the "*scratch*" buffer.
 
+---
+** Support for 'styled-underline' face attributes on TTY frames
+If your terminals termcap or terminfo database entry has the 'Su' or
+'Smulx' capability defined, Emacs will now emit the prescribed escape
+sequence necessary to render faces with styled underlines on TTY
+frames.
+
+Styled underlines are any underlines containing a non-default
+underline style.  The available underline styles for TTY frames are
+'double', 'wave', 'dotted', and 'dashed'.
+
+The 'Smulx' capability should define the actual sequence needed to
+render styled underlines. If ommitted, but the 'Su' flag is defined,
+then a default sequence will be used. It's recommended to use 'Smulx'
+instead of 'Su', with priority being given to 'Smulx'.
+
 ** Debugging
 
 ---
diff --git a/src/dispextern.h b/src/dispextern.h
index 1dc84e32efc..6ea6f6170e4 100644
--- a/src/dispextern.h
+++ b/src/dispextern.h
@@ -1773,7 +1773,7 @@ #define FONT_TOO_HIGH(ft)						\
      string meaning the default color of the TTY.  */
   bool_bf tty_bold_p : 1;
   bool_bf tty_italic_p : 1;
-  bool_bf tty_underline_p : 1;
+  ENUM_BF (face_underline_type) tty_underline : 3;
   bool_bf tty_reverse_p : 1;
   bool_bf tty_strike_through_p : 1;
 
@@ -3365,6 +3365,7 @@ #define TTY_CAP_BOLD		0x04
 #define TTY_CAP_DIM		0x08
 #define TTY_CAP_ITALIC  	0x10
 #define TTY_CAP_STRIKE_THROUGH	0x20
+#define TTY_CAP_UNDERLINE_STYLED	0x32 & TTY_CAP_UNDERLINE
 
 
 /***********************************************************************
diff --git a/src/term.c b/src/term.c
index 53ba2a231e4..0f0393780eb 100644
--- a/src/term.c
+++ b/src/term.c
@@ -1948,8 +1948,17 @@ turn_on_face (struct frame *f, int face_id)
 	OUTPUT1 (tty, tty->TS_enter_dim_mode);
     }
 
-  if (face->tty_underline_p && MAY_USE_WITH_COLORS_P (tty, NC_UNDERLINE))
-    OUTPUT1_IF (tty, tty->TS_enter_underline_mode);
+  if (face->tty_underline && MAY_USE_WITH_COLORS_P (tty, NC_UNDERLINE)) {
+    if (face->tty_underline == FACE_UNDER_LINE ||
+        !tty->TF_set_underline_style) {
+      OUTPUT1_IF (tty, tty->TS_enter_underline_mode);
+    } else if (tty->TF_set_underline_style) {
+      char *p;
+      p = tparam(tty->TF_set_underline_style, NULL, 0, face->tty_underline, 0, 0, 0);
+      OUTPUT (tty, p);
+      xfree (p);
+    }
+  }
 
   if (face->tty_strike_through_p
       && MAY_USE_WITH_COLORS_P (tty, NC_STRIKE_THROUGH))
@@ -1995,7 +2004,7 @@ turn_off_face (struct frame *f, int face_id)
       if (face->tty_bold_p
 	  || face->tty_italic_p
 	  || face->tty_reverse_p
-	  || face->tty_underline_p
+	  || face->tty_underline
 	  || face->tty_strike_through_p)
 	{
 	  OUTPUT1_IF (tty, tty->TS_exit_attribute_mode);
@@ -2007,7 +2016,7 @@ turn_off_face (struct frame *f, int face_id)
     {
       /* If we don't have "me" we can only have those appearances
 	 that have exit sequences defined.  */
-      if (face->tty_underline_p)
+      if (face->tty_underline)
 	OUTPUT_IF (tty, tty->TS_exit_underline_mode);
     }
 
@@ -2036,6 +2045,9 @@ #define TTY_CAPABLE_P_TRY(tty, cap, TS, NC_bit)				\
   TTY_CAPABLE_P_TRY (tty,
 		     TTY_CAP_UNDERLINE,	  tty->TS_enter_underline_mode,
 		     NC_UNDERLINE);
+  TTY_CAPABLE_P_TRY (tty,
+		     TTY_CAP_UNDERLINE_STYLED,	  tty->TF_set_underline_style,
+             NC_UNDERLINE);
   TTY_CAPABLE_P_TRY (tty,
 		     TTY_CAP_BOLD,	  tty->TS_enter_bold_mode, NC_BOLD);
   TTY_CAPABLE_P_TRY (tty,
@@ -4250,6 +4262,21 @@ init_tty (const char *name, const char *terminal_type, bool must_succeed)
   tty->TF_underscore = tgetflag ("ul");
   tty->TF_teleray = tgetflag ("xt");
 
+  // Styled underlines.
+  //
+  // Support for this is provided either by the escape sequence in
+  // Smulx or the Su flag. The latter results in a common default
+  // escape sequence and is not recommended.
+#ifdef TERMINFO
+  tty->TF_set_underline_style = tigetstr("Smulx");
+  if (tty->TF_set_underline_style == (char *) (intptr_t) -1)
+    tty->TF_set_underline_style = NULL;
+#else
+  tty->TF_set_underline_style = tgetstr("Smulx", address);
+#endif
+  if (!tty->TF_set_underline_style && tgetflag("Su"))
+    tty->TF_set_underline_style = "\x1b[4:%p1%dm";
+
 #else /* DOS_NT */
 #ifdef WINDOWSNT
   {
diff --git a/src/termchar.h b/src/termchar.h
index 5c47679a994..319c2319fba 100644
--- a/src/termchar.h
+++ b/src/termchar.h
@@ -171,6 +171,10 @@ #define EMACS_TERMCHAR_H
                                    non-blank position.  Must clear before writing _.  */
   int TF_teleray;               /* termcap xt flag: many weird consequences.
                                    For t1061. */
+  const char *TF_set_underline_style;   /* termcap Smulx entry: Switches the underline
+                                           style based on the parameter. Param should
+                                           be one of: 0 (none), 1 (straight), 2 (double),
+                                           3 (wave), 4 (dotted), or 5 (dashed). */
 
   int RPov;                     /* # chars to start a TS_repeat */
 
diff --git a/src/xfaces.c b/src/xfaces.c
index cfbb89d2ae2..2c6c554d01d 100644
--- a/src/xfaces.c
+++ b/src/xfaces.c
@@ -5408,8 +5408,18 @@ tty_supports_face_attributes_p (struct frame *f,
     {
       if (STRINGP (val))
 	return false;		/* ttys can't use colored underlines */
-      else if (EQ (CAR_SAFE (val), QCstyle) && EQ (CAR_SAFE (CDR_SAFE (val)), Qwave))
-	return false;		/* ttys can't use wave underlines */
+      else if (EQ (CAR_SAFE (val), QCstyle))
+    {
+        if (!(EQ (CAR_SAFE (CDR_SAFE (val)), Qline) ||
+              EQ (CAR_SAFE (CDR_SAFE (val)), Qdouble) ||
+              EQ (CAR_SAFE (CDR_SAFE (val)), Qwave) ||
+              EQ (CAR_SAFE (CDR_SAFE (val)), Qdotted) ||
+              EQ (CAR_SAFE (CDR_SAFE (val)), Qdashed))) {
+            return false; /* Unsupported underline style */
+        }
+
+	    test_caps |= TTY_CAP_UNDERLINE_STYLED;
+    }
       else if (face_attr_equal_p (val, def_attrs[LFACE_UNDERLINE_INDEX]))
 	return false;		/* same as default */
       else
@@ -6335,6 +6345,8 @@ realize_gui_face (struct face_cache *cache, Lisp_Object attrs[LFACE_VECTOR_SIZE]
                 face->underline = FACE_UNDER_LINE;
               else if (EQ (value, Qwave))
                 face->underline = FACE_UNDER_WAVE;
+              else
+                face->underline = FACE_UNDER_LINE;
             }
 	  else if (EQ (keyword, QCposition))
 	    {
@@ -6469,6 +6481,7 @@ realize_tty_face (struct face_cache *cache,
 {
   struct face *face;
   int weight, slant;
+  Lisp_Object underline;
   bool face_colors_defaulted = false;
   struct frame *f = cache->f;
 
@@ -6488,13 +6501,52 @@ realize_tty_face (struct face_cache *cache,
     face->tty_bold_p = true;
   if (slant != 100)
     face->tty_italic_p = true;
-  if (!NILP (attrs[LFACE_UNDERLINE_INDEX]))
-    face->tty_underline_p = true;
   if (!NILP (attrs[LFACE_INVERSE_INDEX]))
     face->tty_reverse_p = true;
   if (!NILP (attrs[LFACE_STRIKE_THROUGH_INDEX]))
     face->tty_strike_through_p = true;
 
+  /* Text underline.  */
+  underline = attrs[LFACE_UNDERLINE_INDEX];
+  if (NILP (underline)) {
+    face->tty_underline = FACE_NO_UNDERLINE;
+  } else if (EQ (underline, Qt)) {
+    face->tty_underline = FACE_UNDER_LINE;
+  } else if (STRINGP (underline)) {
+    face->tty_underline = FACE_UNDER_LINE;
+  } else if (CONSP (underline)) {
+    /* `(:style STYLE)'.
+       STYLE being one of `line', `double', `wave', `dotted' or `dashed'. */
+    face->tty_underline = FACE_UNDER_LINE;
+
+    while (CONSP (underline)) {
+      Lisp_Object keyword, value;
+
+      keyword = XCAR (underline);
+      underline = XCDR (underline);
+
+      if (!CONSP (underline))
+        break;
+      value = XCAR (underline);
+      underline = XCDR (underline);
+
+      if (EQ (keyword, QCstyle)) {
+        if (EQ (value, Qline))
+          face->tty_underline = FACE_UNDER_LINE;
+        else if (EQ (value, Qdouble))
+          face->tty_underline = FACE_DOUBLE_UNDER_LINE;
+        else if (EQ (value, Qwave))
+          face->tty_underline = FACE_UNDER_WAVE;
+        else if (EQ (value, Qdotted))
+          face->tty_underline = FACE_DOTTED_UNDER_LINE;
+        else if (EQ (value, Qdashed))
+          face->tty_underline = FACE_DASHED_UNDER_LINE;
+        else
+          face->tty_underline = FACE_UNDER_LINE;
+      }
+    }
+  }
+
   /* Map color names to color indices.  */
   map_tty_color (f, face, LFACE_FOREGROUND_INDEX, &face_colors_defaulted);
   map_tty_color (f, face, LFACE_BACKGROUND_INDEX, &face_colors_defaulted);
-- 
2.40.0





Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#62994: [PATCH 0/3] Support styled underlines on tty Emacs frames
Resent-From: Eli Zaretskii <eliz@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Fri, 21 Apr 2023 15:53:02 +0000
Resent-Message-ID: <handler.62994.B62994.168209235417389 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 62994
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: 
To: mohkale@HIDDEN
Cc: 62994 <at> debbugs.gnu.org
Received: via spool by 62994-submit <at> debbugs.gnu.org id=B62994.168209235417389
          (code B ref 62994); Fri, 21 Apr 2023 15:53:02 +0000
Received: (at 62994) by debbugs.gnu.org; 21 Apr 2023 15:52:34 +0000
Received: from localhost ([127.0.0.1]:40988 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1ppt3p-0004WP-Tl
	for submit <at> debbugs.gnu.org; Fri, 21 Apr 2023 11:52:34 -0400
Received: from eggs.gnu.org ([209.51.188.92]:58560)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1ppt3o-0004WB-0y
 for 62994 <at> debbugs.gnu.org; Fri, 21 Apr 2023 11:52:32 -0400
Received: from fencepost.gnu.org ([2001:470:142:3::e])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1ppt3i-0002M3-7O; Fri, 21 Apr 2023 11:52:26 -0400
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date:
 mime-version; bh=TdxjjGi9UqH8WmMnJnzxDV8FM7t9KypZYNip9dgYGIM=; b=pk8VWhS+GsLu
 fiPbW1KdFDe06lAJKgXPr3Vwc2kKDt/cQjSHB/6zVAanvUQVVBKAZTskcadteZjhVvXJ1EdMRypTq
 LSkSXCjROuPPlOktpWxsJc6JNyvXdHsY4CBKaIGCSBO0WtgL4nAw9qAlq7R+IZzGnrBTQdJy3+Skl
 akQf8ELZ8+oLk3w07+iVbsY8SSHf0ZW8rKTNFdctFFPXHd+pd6naup46FaIwHUvWBQnX1tPAyrdtS
 XddfpZ6JfszqkmlMOv1On2Iv1EndBVTtsg8C87KFECZWapqG1Abdx7XqjSqJGVjYcZ0ONG/5BApfL
 pLlSqWvaXyZCbvhM1Bd8pA==;
Received: from [87.69.77.57] (helo=home-c4e4a596f7)
 by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1ppt3h-00059Y-JS; Fri, 21 Apr 2023 11:52:25 -0400
Date: Fri, 21 Apr 2023 18:52:43 +0300
Message-Id: <831qkd44hg.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
In-Reply-To: <20230421143448.339022-1-mohkale@HIDDEN>
References: <handler.62994.B.168208734930664.ack <at> debbugs.gnu.org>
 <20230421143448.339022-1-mohkale@HIDDEN>
X-Spam-Score: -2.3 (--)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> Cc: Mohsin Kaleem <mohkale@HIDDEN>
> From: mohkale@HIDDEN
> Date: Fri, 21 Apr 2023 15:34:45 +0100
> 
> From: Mohsin Kaleem <mohkale@HIDDEN>
> 
> Modern terminals (such as kitty) support setting the style of an
> underline with the escape sequence exposed in the Smulx termcap.
> This allows for (among others) wavy underlines on terminals.
> These terminals also support setting the color of these underlines
> using a separate escape sequence that to the best of my knowledge
> is not exposed as a termcap but has been adopted by other terminal
> supporting editors like neovim.

Thanks.

Please note up front that we must wait for the completion of your
legal paperwork before we can accept significant contributions (such
as this one) from you.

I will send a few comments to each of the patches separately.




Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#62994: [PATCH 1/3] Add face definitions for more underline styles
Resent-From: Eli Zaretskii <eliz@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Fri, 21 Apr 2023 15:59:02 +0000
Resent-Message-ID: <handler.62994.B62994.168209271018230 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 62994
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: 
To: mohkale@HIDDEN
Cc: 62994 <at> debbugs.gnu.org
Received: via spool by 62994-submit <at> debbugs.gnu.org id=B62994.168209271018230
          (code B ref 62994); Fri, 21 Apr 2023 15:59:02 +0000
Received: (at 62994) by debbugs.gnu.org; 21 Apr 2023 15:58:30 +0000
Received: from localhost ([127.0.0.1]:41002 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1ppt9a-0004jy-E2
	for submit <at> debbugs.gnu.org; Fri, 21 Apr 2023 11:58:30 -0400
Received: from eggs.gnu.org ([209.51.188.92]:33902)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1ppt9Z-0004jl-Ga
 for 62994 <at> debbugs.gnu.org; Fri, 21 Apr 2023 11:58:30 -0400
Received: from fencepost.gnu.org ([2001:470:142:3::e])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1ppt9U-0003Rq-2L; Fri, 21 Apr 2023 11:58:24 -0400
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date:
 mime-version; bh=Sq2q31KX7xys5OQwXaaUutn7X2uwcq3DWHXpnVhEsD4=; b=dOEuwB9o5XPa
 p5NeFkji0a/+h8IbIRfdsu5Sv20j3F2LbY+HJgcWQvdVsCTvvJiMtXQinQbq3NHOwCGn6QQ0WaKYx
 b6kmg0v6KQWjWpmbNX1E7K+376Y9U5ag4K02iM2pweoYx/YtCT4YWwpA1jMOK4iJlNGVYFsd3Uqe+
 LXUoa0zuvwsHifmw6cfNwXfYm3whjfPmDlS7kf3PJBvxJ8NE5XSGF9+uMc6ykkeCPQXkkTapdAEl0
 5ZQMsIi3gbZun+LGN2l99dodw6Eqo9/GxnEy1cjgr1xhSOu7vvfd9gFurdl4CIHX6LoCBec18LlVz
 TL8Hgbx70R5XzrBZs4iAnw==;
Received: from [87.69.77.57] (helo=home-c4e4a596f7)
 by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1ppt9T-0001iR-5e; Fri, 21 Apr 2023 11:58:23 -0400
Date: Fri, 21 Apr 2023 18:58:39 +0300
Message-Id: <83zg712pn4.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
In-Reply-To: <20230421143448.339022-2-mohkale@HIDDEN>
References: <handler.62994.B.168208734930664.ack <at> debbugs.gnu.org>
 <20230421143448.339022-1-mohkale@HIDDEN>
 <20230421143448.339022-2-mohkale@HIDDEN>
X-Spam-Score: -2.3 (--)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> Cc: Mohsin Kaleem <mohkale@HIDDEN>
> From: mohkale@HIDDEN
> Date: Fri, 21 Apr 2023 15:34:46 +0100
> 
> From: Mohsin Kaleem <mohkale@HIDDEN>
> 
> --- a/src/dispextern.h
> +++ b/src/dispextern.h
> @@ -1653,9 +1653,13 @@ #define FONT_TOO_HIGH(ft)						\
>  
>  enum face_underline_type
>  {
> +  // Note: Order matches the order of the Smulx terminfo extension.

Please use the C style of comments, /* Like this. */, not the C++
style.

>    FACE_NO_UNDERLINE = 0,
>    FACE_UNDER_LINE,
> -  FACE_UNDER_WAVE
> +  FACE_DOUBLE_UNDER_LINE,
> +  FACE_UNDER_WAVE,
> +  FACE_DOTTED_UNDER_LINE,
> +  FACE_DASHED_UNDER_LINE,

Is it really necessary to change the numerical value of
FACE_UNDER_WAVE?  Can it be left at its original value?

> --- a/src/xfaces.c
> +++ b/src/xfaces.c
> @@ -3255,7 +3255,11 @@ DEFUN ("internal-set-lisp-face-attribute", Finternal_set_lisp_face_attribute,
>                  }
>  
>                else if (EQ (key, QCstyle)
> -                       && !(EQ (val, Qline) || EQ (val, Qwave)))
> +                       && !(EQ (val, Qline) ||
> +                            EQ (val, Qdouble) ||
> +                            EQ (val, Qwave) ||
> +                            EQ (val, Qdotted) ||
> +                            EQ (val, Qdashed)))

Our style is to put the operators ("||" in this case) at the beginning
of the line, not at its end.

> +  /* Check supported underline styles. */
> +  val = attrs[LFACE_UNDERLINE_INDEX];
> +  if (!UNSPECIFIEDP (val)) {
> +    if (EQ (CAR_SAFE (val), QCstyle)) {
> +      if (!(EQ (CAR_SAFE (CDR_SAFE (val)), Qline) ||
> +            EQ (CAR_SAFE (CDR_SAFE (val)), Qwave))) {
> +        return false; /* Unsupported underline style */

Likewise here.




Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#62994: [PATCH 2/3] Add support for styled underlines on tty frames
Resent-From: Eli Zaretskii <eliz@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Fri, 21 Apr 2023 16:08:02 +0000
Resent-Message-ID: <handler.62994.B62994.168209324819151 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 62994
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: 
To: mohkale@HIDDEN
Cc: 62994 <at> debbugs.gnu.org
Received: via spool by 62994-submit <at> debbugs.gnu.org id=B62994.168209324819151
          (code B ref 62994); Fri, 21 Apr 2023 16:08:02 +0000
Received: (at 62994) by debbugs.gnu.org; 21 Apr 2023 16:07:28 +0000
Received: from localhost ([127.0.0.1]:41015 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1pptIG-0004yp-Ar
	for submit <at> debbugs.gnu.org; Fri, 21 Apr 2023 12:07:28 -0400
Received: from eggs.gnu.org ([209.51.188.92]:38570)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1pptID-0004yZ-7U
 for 62994 <at> debbugs.gnu.org; Fri, 21 Apr 2023 12:07:26 -0400
Received: from fencepost.gnu.org ([2001:470:142:3::e])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1pptI7-0005fs-Om; Fri, 21 Apr 2023 12:07:19 -0400
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date:
 mime-version; bh=YX0DS3Fwyreo6viyPSgN7izv0GTHI9UOQIfUrh6TR5c=; b=a6x9Pg1kBEOg
 2tFDdYqe2Qzr1Q+h9+MFzSrM3VYjvP3L/0E6u/oyD64lkT9L2pP72Cxjbx3KAljBESr/vM8G/l4wB
 qDf3/XkEzXJ8KClw0sOrGBfR7EMMEvfMturuU1dzP3Tfv582J10paOj0PFooGrbK7Zak0kBFsqhYB
 jok5cDHq5wJIJmkSQH0OuJ8rvrWUFnvhKwjVvxLil2heB2OWMvbFJG9v8+8ubD1zZHLBJRQAPajfP
 joflUdOdUXouh0cnJIqE1mLwjFUT3eUAE+sV3vw2XO0B47MPU5FGFlB3g0CrEMXkuc98ouoUawIy/
 zRp2dS3/5PKuyYF3rQN7iA==;
Received: from [87.69.77.57] (helo=home-c4e4a596f7)
 by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1pptI7-0002HG-96; Fri, 21 Apr 2023 12:07:19 -0400
Date: Fri, 21 Apr 2023 19:07:33 +0300
Message-Id: <83y1ml2p8a.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
In-Reply-To: <20230421143448.339022-3-mohkale@HIDDEN>
References: <handler.62994.B.168208734930664.ack <at> debbugs.gnu.org>
 <20230421143448.339022-1-mohkale@HIDDEN>
 <20230421143448.339022-3-mohkale@HIDDEN>
X-Spam-Score: -2.3 (--)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> Cc: Mohsin Kaleem <mohkale@HIDDEN>
> From: mohkale@HIDDEN
> Date: Fri, 21 Apr 2023 15:34:47 +0100
> 
> diff --git a/etc/NEWS b/etc/NEWS
> index 62d2fdcd3a4..9f34927dfad 100644
> --- a/etc/NEWS
> +++ b/etc/NEWS
> @@ -1916,6 +1916,22 @@ This command switches to the "*scratch*" buffer.  If "*scratch*" doesn't
>  exist, the command creates it first.  You can use this command if you
>  inadvertently delete the "*scratch*" buffer.
>  
> +---
> +** Support for 'styled-underline' face attributes on TTY frames
> +If your terminals termcap or terminfo database entry has the 'Su' or
> +'Smulx' capability defined, Emacs will now emit the prescribed escape
> +sequence necessary to render faces with styled underlines on TTY
> +frames.
> +
> +Styled underlines are any underlines containing a non-default
> +underline style.  The available underline styles for TTY frames are
> +'double', 'wave', 'dotted', and 'dashed'.
> +
> +The 'Smulx' capability should define the actual sequence needed to
> +render styled underlines. If ommitted, but the 'Su' flag is defined,
> +then a default sequence will be used. It's recommended to use 'Smulx'
> +instead of 'Su', with priority being given to 'Smulx'.

I think the last paragraph is unnecessary in NEWS, since there's
nothing users can do about the capabilities exposed by their terminfo
database.  In any case, please observe our convention of leaving two
spaces between sentences, not one.

> --- a/src/dispextern.h
> +++ b/src/dispextern.h
> @@ -1773,7 +1773,7 @@ #define FONT_TOO_HIGH(ft)						\
>       string meaning the default color of the TTY.  */
>    bool_bf tty_bold_p : 1;
>    bool_bf tty_italic_p : 1;
> -  bool_bf tty_underline_p : 1;
> +  ENUM_BF (face_underline_type) tty_underline : 3;
>    bool_bf tty_reverse_p : 1;
>    bool_bf tty_strike_through_p : 1;

Is there any reason for separate tty_* face attribute bits? why cannot
we use the same bits on both TTY and GUI frames?

> --- a/src/term.c
> +++ b/src/term.c
> @@ -1948,8 +1948,17 @@ turn_on_face (struct frame *f, int face_id)
>  	OUTPUT1 (tty, tty->TS_enter_dim_mode);
>      }
>  
> -  if (face->tty_underline_p && MAY_USE_WITH_COLORS_P (tty, NC_UNDERLINE))
> -    OUTPUT1_IF (tty, tty->TS_enter_underline_mode);
> +  if (face->tty_underline && MAY_USE_WITH_COLORS_P (tty, NC_UNDERLINE)) {
> +    if (face->tty_underline == FACE_UNDER_LINE ||
> +        !tty->TF_set_underline_style) {
> +      OUTPUT1_IF (tty, tty->TS_enter_underline_mode);
> +    } else if (tty->TF_set_underline_style) {

Please use our style of braces and placing of operators in continued
lines.  The brace should be on their own lines, alone.

> +  // Styled underlines.
> +  //
> +  // Support for this is provided either by the escape sequence in
> +  // Smulx or the Su flag. The latter results in a common default
> +  // escape sequence and is not recommended.

Comment style again: please use the C style.

> +#ifdef TERMINFO
> +  tty->TF_set_underline_style = tigetstr("Smulx");
> +  if (tty->TF_set_underline_style == (char *) (intptr_t) -1)
> +    tty->TF_set_underline_style = NULL;
> +#else
> +  tty->TF_set_underline_style = tgetstr("Smulx", address);
> +#endif
> +  if (!tty->TF_set_underline_style && tgetflag("Su"))
> +    tty->TF_set_underline_style = "\x1b[4:%p1%dm";

Any pointers to where this standard escape sequence is defined?  I'd
like to have that in a comment to this line.

> +      else if (EQ (CAR_SAFE (val), QCstyle))
> +    {
> +        if (!(EQ (CAR_SAFE (CDR_SAFE (val)), Qline) ||
> +              EQ (CAR_SAFE (CDR_SAFE (val)), Qdouble) ||
> +              EQ (CAR_SAFE (CDR_SAFE (val)), Qwave) ||
> +              EQ (CAR_SAFE (CDR_SAFE (val)), Qdotted) ||
> +              EQ (CAR_SAFE (CDR_SAFE (val)), Qdashed))) {

Continuation line style again.

> +            return false; /* Unsupported underline style */

Comments should be complete sentences, and should end in a period and
2 spaces.

> +  /* Text underline.  */
> +  underline = attrs[LFACE_UNDERLINE_INDEX];
> +  if (NILP (underline)) {
> +    face->tty_underline = FACE_NO_UNDERLINE;
> +  } else if (EQ (underline, Qt)) {
> +    face->tty_underline = FACE_UNDER_LINE;
> +  } else if (STRINGP (underline)) {
> +    face->tty_underline = FACE_UNDER_LINE;
> +  } else if (CONSP (underline)) {

Style of braces again.

> +    while (CONSP (underline)) {
> +      Lisp_Object keyword, value;

And here.

> +      if (EQ (keyword, QCstyle)) {

And here.




Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#62994: [PATCH 1/3] Add face definitions for more underline styles
Resent-From: Mohsin Kaleem <mohkale@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Fri, 21 Apr 2023 16:09:01 +0000
Resent-Message-ID: <handler.62994.B62994.168209332219266 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 62994
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: 
To: Eli Zaretskii <eliz@HIDDEN>
Cc: 62994 <at> debbugs.gnu.org
Received: via spool by 62994-submit <at> debbugs.gnu.org id=B62994.168209332219266
          (code B ref 62994); Fri, 21 Apr 2023 16:09:01 +0000
Received: (at 62994) by debbugs.gnu.org; 21 Apr 2023 16:08:42 +0000
Received: from localhost ([127.0.0.1]:41019 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1pptJR-00050g-Ud
	for submit <at> debbugs.gnu.org; Fri, 21 Apr 2023 12:08:42 -0400
Received: from 119.ip-51-38-65.eu ([51.38.65.119]:54760 helo=mail.kisara.moe)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <mohkale@HIDDEN>) id 1pptJQ-00050Y-Ef
 for 62994 <at> debbugs.gnu.org; Fri, 21 Apr 2023 12:08:40 -0400
Received: from mk-deck (unknown [146.70.132.151])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange ECDHE (prime256v1) server-signature ECDSA (prime256v1)
 server-digest SHA256) (No client certificate requested)
 by mail.kisara.moe (Postfix) with ESMTPSA id 3117BA0FB5;
 Fri, 21 Apr 2023 18:08:39 +0200 (CEST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kisara.moe;
 s=default; t=1682093319;
 bh=5kduxa1kXIdu6+crl/rJkOGFXOF08o9fTJaDuLZd3dE=;
 h=From:To:Cc:Subject:In-Reply-To:References:Date:From;
 b=OZaAdc110SWP00rv65fayY61AjSaSxmoGftjHeCBME5tSMZeLJOhjkH0sHDvhATEk
 QTvOLeBGjIOQMyfd4R8syBR1hMjvaZ3BchHLQvlgO/EqoLG0eXnQ1wYtHzdmVHrNVK
 chwJtWw2kijMZNa+XNNjVW7NgKZhBzGR6l0mJau5OZLCPwiNsughPIVUFRhz9ptPxE
 p4CNIti5Y1VJI5l4Ce49b5ndq9i+gVxTcftEsH7fsFOBlrr+24jVTB0LAOlfr3eQte
 5Ax/ytGfMy3U7JXh6HoA7v5k3wBMPenMv2KkP6SBrMeDF6ocg8WuGHu5ZN5b4UwA1p
 zBDNq0cKuHboQ==
From: Mohsin Kaleem <mohkale@HIDDEN>
In-Reply-To: <83zg712pn4.fsf@HIDDEN>
References: <handler.62994.B.168208734930664.ack <at> debbugs.gnu.org>
 <20230421143448.339022-1-mohkale@HIDDEN>
 <20230421143448.339022-2-mohkale@HIDDEN> <83zg712pn4.fsf@HIDDEN>
Date: Fri, 21 Apr 2023 17:08:39 +0100
Message-ID: <87leil5ibc.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: 0.4 (/)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.6 (/)

Eli Zaretskii <eliz@HIDDEN> writes:

> Is it really necessary to change the numerical value of
> FACE_UNDER_WAVE?  Can it be left at its original value?

If consistency with Smulx is desirable then I think it is. Otherwise
when we populate the escape sequence for the underline we'll need to map
from the face underline style to the sequence underline style.
Reordering like this makes them match so we don't have to do any extra
processing later, but if preferable I can retain the original order and
add a helper function to map to the sequence value.

-- 
Mohsin Kaleem




Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#62994: [PATCH 0/3] Support styled underlines on tty Emacs frames
Resent-From: Mohsin Kaleem <mohkale@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Fri, 21 Apr 2023 16:11:02 +0000
Resent-Message-ID: <handler.62994.B62994.168209343819454 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 62994
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: 
To: Eli Zaretskii <eliz@HIDDEN>
Cc: 62994 <at> debbugs.gnu.org
Received: via spool by 62994-submit <at> debbugs.gnu.org id=B62994.168209343819454
          (code B ref 62994); Fri, 21 Apr 2023 16:11:02 +0000
Received: (at 62994) by debbugs.gnu.org; 21 Apr 2023 16:10:38 +0000
Received: from localhost ([127.0.0.1]:41023 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1pptLK-00053h-Da
	for submit <at> debbugs.gnu.org; Fri, 21 Apr 2023 12:10:38 -0400
Received: from 119.ip-51-38-65.eu ([51.38.65.119]:36924 helo=mail.kisara.moe)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <mohkale@HIDDEN>) id 1pptLI-00053a-Q3
 for 62994 <at> debbugs.gnu.org; Fri, 21 Apr 2023 12:10:37 -0400
Received: from mk-deck (unknown [146.70.132.151])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange ECDHE (prime256v1) server-signature ECDSA (prime256v1)
 server-digest SHA256) (No client certificate requested)
 by mail.kisara.moe (Postfix) with ESMTPSA id 123C7A0FB5;
 Fri, 21 Apr 2023 18:10:36 +0200 (CEST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kisara.moe;
 s=default; t=1682093436;
 bh=cdN7imo57LTAiT7//yCNNLNWZI37NQOK2oG3fjp6Acg=;
 h=From:To:Cc:Subject:In-Reply-To:References:Date:From;
 b=xhGqeaGJhZgOTtUEQiAMgQZuLevy2jUUaEHxjM1qZl6UKLOKUDdVEBGfgT8YUen1P
 ux2Z734gLSFBmm7uAO9wLgUh6L+7UBWg9xx4R8YNce7jbuL34awrTd4P0PsiMdBLH5
 XPcc5bjECY5lFH/i3IcGCF57aIW7iZpwyWPQXbJHIX9/y/AHiEovNy34af1m9IAljj
 Vwy/p5s1Aomohq4l4M4zZmWxiDE5Na0tUWQkFhBfikbEYMmeMgTnAJQlwdkwNlm91u
 +fJuPXuDJUu9Ird9P/u6elI3Qzh2ySLr9hbRHfcmmL+VV+VLy2oRKTTClIkXP0VHVv
 MBj7s1UFeirJw==
From: Mohsin Kaleem <mohkale@HIDDEN>
In-Reply-To: <831qkd44hg.fsf@HIDDEN>
References: <handler.62994.B.168208734930664.ack <at> debbugs.gnu.org>
 <20230421143448.339022-1-mohkale@HIDDEN> <831qkd44hg.fsf@HIDDEN>
Date: Fri, 21 Apr 2023 17:10:36 +0100
Message-ID: <87ildp5i83.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: 0.4 (/)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.6 (/)

Eli Zaretskii <eliz@HIDDEN> writes:

> Please note up front that we must wait for the completion of your
> legal paperwork before we can accept significant contributions (such
> as this one) from you.

Yep, I'm aware. I've already reached out to Craig at the FSF help desk.
I don't think there's anything more needed from me or my employer so I'm
just waiting on a confirmation response. Otherwise I'm OK keeping this
patch dormant until it's ready. I'd like to just get it in a state where
it's good to merge, then when the paperwork is signed we can merge.

> I will send a few comments to each of the patches separately.

Much appreciated, thanks Eli :-).

-- 
Mohsin Kaleem




Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#62994: [PATCH 3/3] Add support for colored underlines on tty frames
Resent-From: Eli Zaretskii <eliz@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Fri, 21 Apr 2023 16:13:01 +0000
Resent-Message-ID: <handler.62994.B62994.168209356719657 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 62994
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: 
To: mohkale@HIDDEN
Cc: 62994 <at> debbugs.gnu.org
Received: via spool by 62994-submit <at> debbugs.gnu.org id=B62994.168209356719657
          (code B ref 62994); Fri, 21 Apr 2023 16:13:01 +0000
Received: (at 62994) by debbugs.gnu.org; 21 Apr 2023 16:12:47 +0000
Received: from localhost ([127.0.0.1]:41029 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1pptNO-00056y-Tz
	for submit <at> debbugs.gnu.org; Fri, 21 Apr 2023 12:12:47 -0400
Received: from eggs.gnu.org ([209.51.188.92]:53316)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1pptNM-00056j-Po
 for 62994 <at> debbugs.gnu.org; Fri, 21 Apr 2023 12:12:45 -0400
Received: from fencepost.gnu.org ([2001:470:142:3::e])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1pptNH-0007Dl-8I; Fri, 21 Apr 2023 12:12:39 -0400
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date:
 mime-version; bh=LqmaJj66XLf+Aexkj4CLKLUpXeJExQ+HSwyEKoOqLgQ=; b=U20EyR6/o5zm
 0qY4VtUJ8VnbERH+UIPsErhyBureztl7pLi1hKLDi3MRRlBfdWC4im3IzmmQSJl8/MWqOIUoWhIAV
 wWxQpVcEoBTVVNPGKFtjMcgaIKnxzuyMEGUcBmy/6kXhDBd7w+6WXXW084J6BgAraUVSVjsoLMXLI
 dHbTtwA1bXQPPBbwKxIql/RPG0eL+M3Diu5Ev0fc6628hKivQmMyJXxxDY3w1tmjgOHYhK3gt2bzm
 9puKQca732liopCZ6koZ4/pM2yrj4xRlS0R/mG+PArfTDl7nU+NkRIqlqR6pyqrEeTYCzJYJzaJk7
 +SHzUbVWkdcCVSuIbLAy/g==;
Received: from [87.69.77.57] (helo=home-c4e4a596f7)
 by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1pptNG-00032W-EI; Fri, 21 Apr 2023 12:12:38 -0400
Date: Fri, 21 Apr 2023 19:12:54 +0300
Message-Id: <83wn252ozd.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
In-Reply-To: <20230421143448.339022-4-mohkale@HIDDEN>
References: <handler.62994.B.168208734930664.ack <at> debbugs.gnu.org>
 <20230421143448.339022-1-mohkale@HIDDEN>
 <20230421143448.339022-4-mohkale@HIDDEN>
X-Spam-Score: -2.3 (--)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> Cc: Mohsin Kaleem <mohkale@HIDDEN>
> From: mohkale@HIDDEN
> Date: Fri, 21 Apr 2023 15:34:48 +0100
> 
> diff --git a/etc/NEWS b/etc/NEWS
> index 9f34927dfad..46b2b0e25c5 100644
> --- a/etc/NEWS
> +++ b/etc/NEWS
> @@ -1917,20 +1917,23 @@ exist, the command creates it first.  You can use this command if you
>  inadvertently delete the "*scratch*" buffer.
>  
>  ---
> -** Support for 'styled-underline' face attributes on TTY frames
> +** Support for 'styled' and 'colored' underline face attributes on TTY frames
>  If your terminals termcap or terminfo database entry has the 'Su' or
>  'Smulx' capability defined, Emacs will now emit the prescribed escape
>  sequence necessary to render faces with styled underlines on TTY
>  frames.
>  
>  Styled underlines are any underlines containing a non-default
> -underline style.  The available underline styles for TTY frames are
> -'double', 'wave', 'dotted', and 'dashed'.
> +underline style or a color other than the foreground-color.
> +The available underline styles for TTY frames are 'double', 'wave',
> +'dotted', and 'dashed'.
>  
>  The 'Smulx' capability should define the actual sequence needed to
>  render styled underlines. If ommitted, but the 'Su' flag is defined,
>  then a default sequence will be used. It's recommended to use 'Smulx'
> -instead of 'Su', with priority being given to 'Smulx'.
> +instead of 'Su', with priority being given to 'Smulx'.  Support for
> +colored underlines is automatically enabled with a default escape
> +sequence when styled underline are supported.

Please don't break the changeset into several patches, not in this
case: this changeset introduces a feature that there's no reason to
break into several sub-features, so making a single patch will make it
easier to review the changes.

> +      ts = tty->TF_set_underline_color;
> +      if (ts && face->underline_color)
> +	{
> +          p = tparam (ts, NULL, 0, face->underline_color, 0, 0, 0);

It looks like your edits use indentation with only spaces.  Our style
in C sources is to use TABs and spaces, so please set up your Emacs to
follow our style (it should happen automatically if you let Emacs read
and follow the .dir-locals.el file in the Emacs repository).

> +  if (tty->TF_set_underline_style)
> +    tty->TF_set_underline_color = "\x1b[58:2::%p1%{65536}%/%d:%p1%{256}%/%{255}%&%d:%p1%{255}%&%dm";

What is the source for this escape sequence? can you mention it in a
comment?

Thanks.




Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#62994: [PATCH 2/3] Add support for styled underlines on tty frames
Resent-From: Eli Zaretskii <eliz@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Fri, 21 Apr 2023 17:50:02 +0000
Resent-Message-ID: <handler.62994.B62994.168209935230025 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 62994
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: 
To: Mohsin Kaleem <mohkale@HIDDEN>
Cc: 62994 <at> debbugs.gnu.org
Received: via spool by 62994-submit <at> debbugs.gnu.org id=B62994.168209935230025
          (code B ref 62994); Fri, 21 Apr 2023 17:50:02 +0000
Received: (at 62994) by debbugs.gnu.org; 21 Apr 2023 17:49:12 +0000
Received: from localhost ([127.0.0.1]:41090 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1ppusi-0007oC-AP
	for submit <at> debbugs.gnu.org; Fri, 21 Apr 2023 13:49:12 -0400
Received: from eggs.gnu.org ([209.51.188.92]:60620)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1ppusg-0007nz-U4
 for 62994 <at> debbugs.gnu.org; Fri, 21 Apr 2023 13:49:11 -0400
Received: from fencepost.gnu.org ([2001:470:142:3::e])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1ppusY-0007rp-Rf; Fri, 21 Apr 2023 13:49:02 -0400
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date:
 mime-version; bh=qcHPyT7gT7wVWB84sGQdftrXuHIWrUYaim+Nc4sMpN4=; b=heCjEmDqS47f
 02+NLPXz8FuMZc4lBw9TEj78lIgMp/Gd3q5GfyjZaXnjCRY/PC/yHaeBoo3hxdhOEFTct2hifwBQg
 0QBMqFPfzIJnOPKjzqXB80/BgzmNDLttsaR4NqOAdo5bdi+TsZfGaApbbcA5Vy9+p3KsgvXzVdasp
 qLA/wpLQbNRn7D4JJFvbyuzwd15R+VyBpYupnB7QsbCjHwSF1EASLOPfEDi5yU7WRes/cQXRYs//1
 X1EDC4P1vOe5a+eREpxoORYOUPXUro1aUGXx0W1dunJmROWuvF85l0BocTEyZLrv9e6/hg7KYNTBO
 xbPHOscuD8pQCz9Z7vK7ew==;
Received: from [87.69.77.57] (helo=home-c4e4a596f7)
 by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1ppusY-0007D6-Bq; Fri, 21 Apr 2023 13:49:02 -0400
Date: Fri, 21 Apr 2023 20:49:19 +0300
Message-Id: <83sfct2kio.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
In-Reply-To: <878rel5fqr.fsf@HIDDEN> (message from Mohsin Kaleem on Fri,
 21 Apr 2023 18:04:12 +0100)
References: <handler.62994.B.168208734930664.ack <at> debbugs.gnu.org>
 <20230421143448.339022-1-mohkale@HIDDEN>
 <20230421143448.339022-3-mohkale@HIDDEN> <83y1ml2p8a.fsf@HIDDEN>
 <878rel5fqr.fsf@HIDDEN>
X-Spam-Score: -2.3 (--)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

[Please use Reply All to keep the bug address on the CC list.]

> From: Mohsin Kaleem <mohkale@HIDDEN>
> Date: Fri, 21 Apr 2023 18:04:12 +0100
> 
> Eli Zaretskii <eliz@HIDDEN> writes:
> 
> > I think the last paragraph is unnecessary in NEWS, since there's
> > nothing users can do about the capabilities exposed by their terminfo
> > database.
> 
> I kinda disagree, I think mentioning this can help users debug why
> certain termcaps aren't being processed correctly or to direct requests
> to fix the processing directly to the terminal emulator instead of to
> Emacs first. I'll go ahead and remove it for now.

This is stuff for etc/PROBLEMS, not for NEWS.  And we only add it to
PROBLEMS if someone actually reports the relevant problems.

> > Please use our style of braces and placing of operators in continued
> > lines.  The brace should be on their own lines, alone.
> 
> For future reference is this style documented anywhere?

Yes, in standards.info.  This is the GNU recommended style.

> > Any pointers to where this standard escape sequence is defined?  I'd
> > like to have that in a comment to this line.
> 
> For the underline style I think kitty is a good reference since it was
> the first to support it. That documentation is here [1]. The sequence
> for color is also documented there... but I find the way its described
> at best confusing and at worst unhelpful. I've been using the neovim
> source code [2] as a reference for the implementation and color sequence
> alongside trial and error.
> 
> [1]: https://sw.kovidgoyal.net/kitty/underlines/
> [2]: https://github.com/neovim/neovim/commit/42f492ac99058bd1cd56c3c7871e7e464b2a5e24

Did Kitty invent that?  If not, there must be some reference that is
not the source code of a terminal emulator.




Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#62994: [PATCH 3/3] Add support for colored underlines on tty frames
Resent-From: Eli Zaretskii <eliz@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Fri, 21 Apr 2023 17:57:02 +0000
Resent-Message-ID: <handler.62994.B62994.168209977231278 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 62994
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: 
To: Mohsin Kaleem <mohkale@HIDDEN>
Cc: 62994 <at> debbugs.gnu.org
Received: via spool by 62994-submit <at> debbugs.gnu.org id=B62994.168209977231278
          (code B ref 62994); Fri, 21 Apr 2023 17:57:02 +0000
Received: (at 62994) by debbugs.gnu.org; 21 Apr 2023 17:56:12 +0000
Received: from localhost ([127.0.0.1]:41095 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1ppuzU-00088P-98
	for submit <at> debbugs.gnu.org; Fri, 21 Apr 2023 13:56:12 -0400
Received: from eggs.gnu.org ([209.51.188.92]:52298)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1ppuzP-00087t-L5
 for 62994 <at> debbugs.gnu.org; Fri, 21 Apr 2023 13:56:11 -0400
Received: from fencepost.gnu.org ([2001:470:142:3::e])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1ppuzK-0002Nw-5n; Fri, 21 Apr 2023 13:56:02 -0400
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date:
 mime-version; bh=ZAmgfLRRO+p+dj2fL5gnoCpPWf6YVzCizW/RRpvov1k=; b=nmMXW1ztle6T
 NWptVwGt67jdTg84yGXJIS73V/akc474I4pT1u58zwqrquNYw0vzi9n2XNurktLA2eg0mk3kFhJ7V
 JrhmtGtxdE/sB0E69m7c8M41AYjXsOn0d/dorDuzd/LrPDH487AmTa94XOAuQ5Xi3wyyBGqqOwHDI
 jLCmJjNMT8v5owjS6VnwlySwZexiRsTWY2jP88MRdTJSFheOfLG4UPTzP8lzltrPdgkDiQIz/c2V0
 xnJoPSf25sgmOLNfHKmzhW5NKJjkFD/M3FAUxAyRZ2QGUF6V5CMwAxKH3noT6tLGzXFFNIxR66BC9
 bvBx6bH/l8ZnmKwMlbplwA==;
Received: from [87.69.77.57] (helo=home-c4e4a596f7)
 by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1ppuzJ-000892-KB; Fri, 21 Apr 2023 13:56:01 -0400
Date: Fri, 21 Apr 2023 20:56:18 +0300
Message-Id: <83r0sd2k71.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
In-Reply-To: <875y9p5fg0.fsf@HIDDEN> (message from Mohsin Kaleem on Fri,
 21 Apr 2023 18:10:39 +0100)
References: <handler.62994.B.168208734930664.ack <at> debbugs.gnu.org>
 <20230421143448.339022-1-mohkale@HIDDEN>
 <20230421143448.339022-4-mohkale@HIDDEN> <83wn252ozd.fsf@HIDDEN>
 <875y9p5fg0.fsf@HIDDEN>
X-Spam-Score: -2.3 (--)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> From: Mohsin Kaleem <mohkale@HIDDEN>
> Date: Fri, 21 Apr 2023 18:10:39 +0100
> 
> > It looks like your edits use indentation with only spaces.  Our style
> > in C sources is to use TABs and spaces, so please set up your Emacs to
> > follow our style (it should happen automatically if you let Emacs read
> > and follow the .dir-locals.el file in the Emacs repository).
> 
> Looks like .dir-locals.el won't work for me since I use c-ts-mode and it
> hooks into c-mode only.

You are right, I've just fixed that.

> >> +  if (tty->TF_set_underline_style)
> >> +    tty->TF_set_underline_color = "\x1b[58:2::%p1%{65536}%/%d:%p1%{256}%/%{255}%&%d:%p1%{255}%&%dm";
> >
> > What is the source for this escape sequence? can you mention it in a
> > comment?
> 
> The form here is nonstandard. It's adapted from the same escape sequence
> used by neovim [1]. The difference here is that this form accepts a
> single color parameter whereas that one accepts three different
> parameters for the color range. Since this form is how the existing
> foreground and background sequences are set AND the sequence doesn't
> come from a termcap I figured it was okay to adapt it to a form Emacs
> can already substitute.
> 
> [1]: https://github.com/neovim/neovim/blob/42f492ac99058bd1cd56c3c7871e7e464b2a5e24/src/nvim/tui/tui.c#L1932

This should all be in a comment there, thanks.




Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#62994: [PATCH 2/3] Add support for styled underlines on tty frames
Resent-From: Mohsin Kaleem <mohkale@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Fri, 21 Apr 2023 18:05:01 +0000
Resent-Message-ID: <handler.62994.B62994.168210025932155 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 62994
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: 
To: Eli Zaretskii <eliz@HIDDEN>
Cc: 62994 <at> debbugs.gnu.org
Received: via spool by 62994-submit <at> debbugs.gnu.org id=B62994.168210025932155
          (code B ref 62994); Fri, 21 Apr 2023 18:05:01 +0000
Received: (at 62994) by debbugs.gnu.org; 21 Apr 2023 18:04:19 +0000
Received: from localhost ([127.0.0.1]:41101 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1ppv7L-0008MZ-9A
	for submit <at> debbugs.gnu.org; Fri, 21 Apr 2023 14:04:19 -0400
Received: from 119.ip-51-38-65.eu ([51.38.65.119]:58344 helo=mail.kisara.moe)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <mohkale@HIDDEN>) id 1ppv7G-0008MN-6o
 for 62994 <at> debbugs.gnu.org; Fri, 21 Apr 2023 14:04:17 -0400
Received: from mk-deck (unknown [146.70.132.151])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange ECDHE (prime256v1) server-signature ECDSA (prime256v1)
 server-digest SHA256) (No client certificate requested)
 by mail.kisara.moe (Postfix) with ESMTPSA id EFCD8A0FB5;
 Fri, 21 Apr 2023 20:04:12 +0200 (CEST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kisara.moe;
 s=default; t=1682100253;
 bh=FMDAO+UKO86dWHyfyNoJqqV6liVQvWbrA1S9lqiKrcA=;
 h=From:To:Cc:Subject:In-Reply-To:References:Date:From;
 b=aafbXx+WvOxJ8noTQAWp8M9AOwK1Q+zF/ZcMcOfCx78KSSiHFshFRFnKpK9t/ZTNg
 VyLDRE6cvyoJ5H45Pm4dYwhHRvBI/H/iyNmx35YHd1uKher3ohYvHGysB3f1A7TWyG
 a3VqjjzH4Z9fhKU8eP58b9G99jNHoRocfNEAVgznhx1GKt8ZTmL/6Qdjqe9mEphLiR
 GJjVJe3GvmOgk+O6uiAMYsjDNOUdjaeyFFV7c+I1NKQXPGm4KpH19u260xAJwYt4Bh
 vh52cMXoN2/GcaHcTgL7WVazfN/3R5Lq5KXbGcYqVB7g0KF5Cc14Dbe/af8Yg/3G4s
 A6guh7egoxSqA==
From: Mohsin Kaleem <mohkale@HIDDEN>
In-Reply-To: <83sfct2kio.fsf@HIDDEN>
References: <handler.62994.B.168208734930664.ack <at> debbugs.gnu.org>
 <20230421143448.339022-1-mohkale@HIDDEN>
 <20230421143448.339022-3-mohkale@HIDDEN> <83y1ml2p8a.fsf@HIDDEN>
 <878rel5fqr.fsf@HIDDEN> <83sfct2kio.fsf@HIDDEN>
Date: Fri, 21 Apr 2023 19:04:13 +0100
Message-ID: <87354t5cyq.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: 0.4 (/)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.6 (/)

Eli Zaretskii <eliz@HIDDEN> writes:

> [Please use Reply All to keep the bug address on the CC list.]

Thought I did, my bad. Sorry.

> This is stuff for etc/PROBLEMS, not for NEWS.  And we only add it to
> PROBLEMS if someone actually reports the relevant problems.

Good enough :-).

> Yes, in standards.info.  This is the GNU recommended style.

Cool, doesn't seem to be in the Emacs repo but I'm guessing it's this
[1]. I'll try to adapt to it.

[1]: https://www.gnu.org/prep/standards/standards.html#Formatting

> Did Kitty invent that?  If not, there must be some reference that is
> not the source code of a terminal emulator.

I think it did. What I've found online indicates kitty invented it, used
Su for the termcap, this lead to an issue on tmux which suggested
changing it to Smulx [2]. That's why the termcap for it is inconsistent.
I can't find any reference for support before kitty.

[2]: https://github.com/tmux/tmux/issues/1492

-- 
Mohsin Kaleem




Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#62994: [PATCH 2/3] Add support for styled underlines on tty frames
Resent-From: Mohsin Kaleem <mohkale@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Fri, 21 Apr 2023 18:44:02 +0000
Resent-Message-ID: <handler.62994.B62994.16821025913635 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 62994
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: 
To: Eli Zaretskii <eliz@HIDDEN>
Cc: 62994 <at> debbugs.gnu.org
Received: via spool by 62994-submit <at> debbugs.gnu.org id=B62994.16821025913635
          (code B ref 62994); Fri, 21 Apr 2023 18:44:02 +0000
Received: (at 62994) by debbugs.gnu.org; 21 Apr 2023 18:43:11 +0000
Received: from localhost ([127.0.0.1]:41150 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1ppvix-0000wZ-I4
	for submit <at> debbugs.gnu.org; Fri, 21 Apr 2023 14:43:11 -0400
Received: from 119.ip-51-38-65.eu ([51.38.65.119]:33450 helo=mail.kisara.moe)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <mohkale@HIDDEN>) id 1ppviu-0000wP-J7
 for 62994 <at> debbugs.gnu.org; Fri, 21 Apr 2023 14:43:09 -0400
Received: from mk-deck (unknown [146.70.132.151])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange ECDHE (prime256v1) server-signature ECDSA (prime256v1)
 server-digest SHA256) (No client certificate requested)
 by mail.kisara.moe (Postfix) with ESMTPSA id 3404FA0FB5;
 Fri, 21 Apr 2023 20:43:07 +0200 (CEST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kisara.moe;
 s=default; t=1682102587;
 bh=3y7Uas78c2m71Th50H7kOMOF9t98Jf0Y2aWK183bF20=;
 h=From:To:Cc:Subject:In-Reply-To:References:Date:From;
 b=1y6KU9vG8ZUMpdGsqNm+RRWYCjgwlr5RbpPuB29E/UpX8UT0uP8i7JMlwZ8OfI4Rm
 BBS/caQoQ464A7erIbnXwowoH54/yJSZLRk6jQUeD6fSfBQ4UE7Ok5iYsRxLNeUn/z
 AlAdu3nkI3Qshyluisx1IEKBC2cmAX/MEXn+HYubbv9hDR5Qm3VDqIwHpse1r7FNXN
 Q95XCdsTk8QeR4GZ+Hc32+a/ecepa+KyUE6FZ+S4K2N2HQNLStBAGUjFZTZgQcg+Qd
 U6a3IFZI0fWPq8gQmA5r+Rn2awck1SB6RQ4S90ct63dlDjzhTII4hS4ZIUmXWW3dPU
 JiNca9KvC/32A==
From: Mohsin Kaleem <mohkale@HIDDEN>
In-Reply-To: <87354t5cyq.fsf@HIDDEN>
References: <handler.62994.B.168208734930664.ack <at> debbugs.gnu.org>
 <20230421143448.339022-1-mohkale@HIDDEN>
 <20230421143448.339022-3-mohkale@HIDDEN> <83y1ml2p8a.fsf@HIDDEN>
 <878rel5fqr.fsf@HIDDEN> <83sfct2kio.fsf@HIDDEN>
 <87354t5cyq.fsf@HIDDEN>
Date: Fri, 21 Apr 2023 19:43:07 +0100
Message-ID: <87zg713wlg.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: 0.4 (/)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.6 (/)

Mohsin Kaleem <mohkale@HIDDEN> writes:

> Cool, doesn't seem to be in the Emacs repo but I'm guessing it's this
> [1]. I'll try to adapt to it.

I still don't get how to apply this to this repo Eli. You mentioned using
tabs and spaces but every lines aside from a nested expression starts
with 2 spaces. Some times there's 3 levels deep of expressions all
indented with spaces and then one tab width just wide enough at 8
characters to appear like it's indented with spaces atop the previous
scope.

Can I just do leading indent with tabs matching current indentation
level, curly braces 2 space ahead of the parent indent, and spaces ahead
of tabs to align a parenthesized expression or multi line condition with
the previous line?

-- 
Mohsin Kaleem




Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#62994: [PATCH v2 0/1] Support styled underlines on tty Emacs frames
Resent-From: mohkale@HIDDEN
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Fri, 21 Apr 2023 19:25:01 +0000
Resent-Message-ID: <handler.62994.B62994.16821050818270 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 62994
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: 
To: Eli Zaretskii <eliz@HIDDEN>, 62994 <at> debbugs.gnu.org
Cc: Mohsin Kaleem <mohkale@HIDDEN>
Received: via spool by 62994-submit <at> debbugs.gnu.org id=B62994.16821050818270
          (code B ref 62994); Fri, 21 Apr 2023 19:25:01 +0000
Received: (at 62994) by debbugs.gnu.org; 21 Apr 2023 19:24:41 +0000
Received: from localhost ([127.0.0.1]:41168 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1ppwN7-00029K-G1
	for submit <at> debbugs.gnu.org; Fri, 21 Apr 2023 15:24:41 -0400
Received: from 119.ip-51-38-65.eu ([51.38.65.119]:35940 helo=mail.kisara.moe)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <mohkale@HIDDEN>) id 1ppwN5-00029B-KG
 for 62994 <at> debbugs.gnu.org; Fri, 21 Apr 2023 15:24:40 -0400
Received: from localhost.localdomain (unknown [146.70.132.151])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256)
 (No client certificate requested)
 by mail.kisara.moe (Postfix) with ESMTPSA id 65B23A0FB5;
 Fri, 21 Apr 2023 21:24:38 +0200 (CEST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kisara.moe;
 s=default; t=1682105078;
 bh=i57P11yBj/cjk+R5yhu47yBft06LG9MEpAOAQb4v2zQ=;
 h=From:To:Cc:Subject:Date:In-Reply-To:References:From;
 b=F28vm/o+VKNoyDmNIaBB3z93Dv2WZ+30AhAJqxkbRxB3hv+cjbnhL0Jr/gDlW1Pa3
 8ddtbW41iwEpFiPb1jx0+oHjlTDzVpIHNTtqf0yWORfu4H6k+WSv9AZqeR2UNsTTKf
 uGfCK4ogWZ3/dwwxrMUc9w7c7MHxvguKzP+/uAREJTW+XBhU1/+QCM2eltGB2Jdozo
 K0SoBH7PqVjFtL/0hvelNtNFc6Q5jmwiFTDoyGOdgVjgh5PA5baJBfsVe3IHfhE6cP
 UO6AHl47R4zj4OPlF1Gmw9moVK5Lfb4sN/9ukB/kRqvsD5cRmhYnBppCE5ZquTIKko
 xNviYDxKYic1g==
From: mohkale@HIDDEN
Date: Fri, 21 Apr 2023 20:24:32 +0100
Message-Id: <20230421192433.579140-1-mohkale@HIDDEN>
X-Mailer: git-send-email 2.40.0
In-Reply-To: <handler.62994.B.168208734930664.ack <at> debbugs.gnu.org>
References: <handler.62994.B.168208734930664.ack <at> debbugs.gnu.org>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
X-Spam-Score: 0.4 (/)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.6 (/)

From: Mohsin Kaleem <mohkale@HIDDEN>

Modern terminals (such as kitty) support setting the style of an
underline with the escape sequence exposed in the Smulx termcap.
This allows for (among others) wavy underlines on terminals.
These terminals also support setting the color of these underlines
using a separate escape sequence that to the best of my knowledge
is not exposed as a termcap but has been adopted by other terminal
supporting editors like neovim.

Version 2: This should've acted on all the comments on the last patch.
The only thing I'm not sure about is the formatting. I've tried my best
to get something consistent with what's already their or the style guide
reference I found online but it's probably broken in a few places.

Mohsin Kaleem (1):
  Add support for colored and styled underlines on tty frames

 etc/NEWS         |  12 +++++
 lisp/cus-face.el |   5 +-
 src/dispextern.h |  10 ++--
 src/term.c       |  54 +++++++++++++++++++--
 src/termchar.h   |   7 +++
 src/xfaces.c     | 121 ++++++++++++++++++++++++++++++++++++++++++-----
 6 files changed, 189 insertions(+), 20 deletions(-)

-- 
2.40.0





Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#62994: [PATCH v2 1/1] Add support for colored and styled underlines on tty frames
Resent-From: mohkale@HIDDEN
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Fri, 21 Apr 2023 19:25:02 +0000
Resent-Message-ID: <handler.62994.B62994.16821050858286 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 62994
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: 
To: Eli Zaretskii <eliz@HIDDEN>, 62994 <at> debbugs.gnu.org
Cc: Mohsin Kaleem <mohkale@HIDDEN>
Received: via spool by 62994-submit <at> debbugs.gnu.org id=B62994.16821050858286
          (code B ref 62994); Fri, 21 Apr 2023 19:25:02 +0000
Received: (at 62994) by debbugs.gnu.org; 21 Apr 2023 19:24:45 +0000
Received: from localhost ([127.0.0.1]:41170 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1ppwNA-00029Z-Q9
	for submit <at> debbugs.gnu.org; Fri, 21 Apr 2023 15:24:45 -0400
Received: from 119.ip-51-38-65.eu ([51.38.65.119]:35950 helo=mail.kisara.moe)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <mohkale@HIDDEN>) id 1ppwN5-00029C-KH
 for 62994 <at> debbugs.gnu.org; Fri, 21 Apr 2023 15:24:42 -0400
Received: from localhost.localdomain (unknown [146.70.132.151])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256)
 (No client certificate requested)
 by mail.kisara.moe (Postfix) with ESMTPSA id A633DA0FFD;
 Fri, 21 Apr 2023 21:24:38 +0200 (CEST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kisara.moe;
 s=default; t=1682105078;
 bh=emSN6lk9rXQNBzLtz+0qWb5MiKxC4t7OHCIaI6d3AEQ=;
 h=From:To:Cc:Subject:Date:In-Reply-To:References:From;
 b=Wizuzv/uvG0+I9ScLACvEGFEZmCgYZq4+LJ3L6h6FY13CQD9/7lRkcUiIOLBOTR28
 FxoJd/xqwmA1mhOx3icZFed84Klva1IUwBMr8+nl1LbWaCdd16hpgS8dgBUlvonuvX
 Sp/cfwejUeJ4okHzSIITd3bOmqEKXtePisjaMCbkFq0dKitZ08woxQT9d1u8/MLwNu
 WcIJyWnhOCpmIY+GWjk0nO3RvUb7ZQKwtXrCw2mKzfYi9sMbjjAxRUwm+zSJoJvDOn
 ADyLufZIafLb3u6MTV3crqXI2E1tFxi+bkWfFZyaZI50t60TkfxTP+AXuyYA41z5hR
 iCO5WPzGb4cEQ==
From: mohkale@HIDDEN
Date: Fri, 21 Apr 2023 20:24:33 +0100
Message-Id: <20230421192433.579140-2-mohkale@HIDDEN>
X-Mailer: git-send-email 2.40.0
In-Reply-To: <20230421192433.579140-1-mohkale@HIDDEN>
References: <handler.62994.B.168208734930664.ack <at> debbugs.gnu.org>
 <20230421192433.579140-1-mohkale@HIDDEN>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
X-Spam-Score: 0.4 (/)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.6 (/)

From: Mohsin Kaleem <mohkale@HIDDEN>

* src/dispextern.h (face, face_underline_type, syms_of_xfacse,
internal-set-lisp-face-attribute, gui_supports_face_attributes_p):
Add definitions for new underline styles of Double, Dotted and Dashed.
Delete tty_underline_p from the face struct and use just underline going
forward.  Add a flag to check whether styled underlines are available.
* lisp/cus-face.el (custom-face-attributes): Add entries for Double,
Dotted and Dashed so they can be set through `customize'.
* src/termchar.c (tty_display_info): Add an entry for the escape
sequence to set the underline style and color on terminal frames.
* src/term.c (init_tty, tty_capable_p, turn_on_face): Read and save the
underline style escape sequence from the Smulx termcap (alternatively if
the Su flag is set use a default sequence).  Allow checking for support
of styled underlines in the current terminal frame.  Output the necessary
escape sequences to activate a styled underline on turn_on_face; this is
currently only used for the new special underline styles, a default
straight underline will still use the "us" termcap.  Output escape
sequence to set underline color when set in the face and supported by
the tty.  Save a default value for this sequence on init_tty when styled
underlines are supported.
* src/xfaces.c (tty_supports_face_attributes_p, realize_tty_face):
Assert whether styled underlines are supported by the current terminal
on display-supports-face-attributes-p checks.  Populate the correct
underline style and color in the face spec when realizing a face.
---
 etc/NEWS         |  12 +++++
 lisp/cus-face.el |   5 +-
 src/dispextern.h |  10 ++--
 src/term.c       |  54 +++++++++++++++++++--
 src/termchar.h   |   7 +++
 src/xfaces.c     | 121 ++++++++++++++++++++++++++++++++++++++++++-----
 6 files changed, 189 insertions(+), 20 deletions(-)

diff --git a/etc/NEWS b/etc/NEWS
index 62d2fdcd3a4..e0798687bf4 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -1916,6 +1916,18 @@ This command switches to the "*scratch*" buffer.  If "*scratch*" doesn't
 exist, the command creates it first.  You can use this command if you
 inadvertently delete the "*scratch*" buffer.
 
+---
+** Support for 'styled' and 'colored' underline face attributes on TTY frames
+If your terminals termcap or terminfo database entry has the 'Su' or
+'Smulx' capability defined, Emacs will now emit the prescribed escape
+sequence necessary to render faces with styled underlines on TTY
+frames.
+
+Styled underlines are any underlines containing a non-default
+underline style or a color other than the foreground-color.
+The available underline styles for TTY frames are 'double', 'wave',
+'dotted', and 'dashed'.
+
 ** Debugging
 
 ---
diff --git a/lisp/cus-face.el b/lisp/cus-face.el
index ec89b4f7ff6..2d6e6c7b73e 100644
--- a/lisp/cus-face.el
+++ b/lisp/cus-face.el
@@ -141,7 +141,10 @@ custom-face-attributes
 		   (const :format "" :value :style)
 		   (choice :tag "Style"
 			   (const :tag "Line" line)
-			   (const :tag "Wave" wave))
+			   (const :tag "Double" double)
+			   (const :tag "Wave" wave)
+			   (const :tag "Dotted" dotted)
+			   (const :tag "Dashed" dashed))
                    (const :format "" :value :position)
                    (choice :tag "Position"
                            (const :tag "At Default Position" nil)
diff --git a/src/dispextern.h b/src/dispextern.h
index 4dcab113ea2..753bee446f1 100644
--- a/src/dispextern.h
+++ b/src/dispextern.h
@@ -1653,9 +1653,13 @@ #define FONT_TOO_HIGH(ft)						\
 
 enum face_underline_type
 {
+	/* Note: Order matches the order of the Smulx terminfo extension. */
   FACE_NO_UNDERLINE = 0,
   FACE_UNDER_LINE,
-  FACE_UNDER_WAVE
+  FACE_DOUBLE_UNDER_LINE,
+  FACE_UNDER_WAVE,
+  FACE_DOTTED_UNDER_LINE,
+  FACE_DASHED_UNDER_LINE,
 };
 
 /* Structure describing a realized face.
@@ -1737,7 +1741,7 @@ #define FONT_TOO_HIGH(ft)						\
   ENUM_BF (face_box_type) box : 2;
 
   /* Style of underlining. */
-  ENUM_BF (face_underline_type) underline : 2;
+  ENUM_BF (face_underline_type) underline : 3;
 
   /* If `box' above specifies a 3D type, true means use box_color for
      drawing shadows.  */
@@ -1769,7 +1773,6 @@ #define FONT_TOO_HIGH(ft)						\
      string meaning the default color of the TTY.  */
   bool_bf tty_bold_p : 1;
   bool_bf tty_italic_p : 1;
-  bool_bf tty_underline_p : 1;
   bool_bf tty_reverse_p : 1;
   bool_bf tty_strike_through_p : 1;
 
@@ -3361,6 +3364,7 @@ #define TTY_CAP_BOLD		0x04
 #define TTY_CAP_DIM		0x08
 #define TTY_CAP_ITALIC  	0x10
 #define TTY_CAP_STRIKE_THROUGH	0x20
+#define TTY_CAP_UNDERLINE_STYLED	0x32 & TTY_CAP_UNDERLINE
 
 
 /***********************************************************************
diff --git a/src/term.c b/src/term.c
index 53ba2a231e4..2c1d44bff7a 100644
--- a/src/term.c
+++ b/src/term.c
@@ -1948,8 +1948,19 @@ turn_on_face (struct frame *f, int face_id)
 	OUTPUT1 (tty, tty->TS_enter_dim_mode);
     }
 
-  if (face->tty_underline_p && MAY_USE_WITH_COLORS_P (tty, NC_UNDERLINE))
-    OUTPUT1_IF (tty, tty->TS_enter_underline_mode);
+  if (face->underline && MAY_USE_WITH_COLORS_P (tty, NC_UNDERLINE))
+    {
+	if (face->underline == FACE_UNDER_LINE
+	    || !tty->TF_set_underline_style)
+		OUTPUT1_IF (tty, tty->TS_enter_underline_mode);
+	else if (tty->TF_set_underline_style)
+	  {
+		char *p;
+		p = tparam(tty->TF_set_underline_style, NULL, 0, face->underline, 0, 0, 0);
+		OUTPUT (tty, p);
+		xfree (p);
+	  }
+    }
 
   if (face->tty_strike_through_p
       && MAY_USE_WITH_COLORS_P (tty, NC_STRIKE_THROUGH))
@@ -1975,6 +1986,14 @@ turn_on_face (struct frame *f, int face_id)
 	  OUTPUT (tty, p);
 	  xfree (p);
 	}
+
+      ts = tty->TF_set_underline_color;
+      if (ts && face->underline_color)
+	{
+	  p = tparam (ts, NULL, 0, face->underline_color, 0, 0, 0);
+	  OUTPUT (tty, p);
+	  xfree (p);
+	}
     }
 }
 
@@ -1995,7 +2014,7 @@ turn_off_face (struct frame *f, int face_id)
       if (face->tty_bold_p
 	  || face->tty_italic_p
 	  || face->tty_reverse_p
-	  || face->tty_underline_p
+	  || face->underline
 	  || face->tty_strike_through_p)
 	{
 	  OUTPUT1_IF (tty, tty->TS_exit_attribute_mode);
@@ -2007,7 +2026,7 @@ turn_off_face (struct frame *f, int face_id)
     {
       /* If we don't have "me" we can only have those appearances
 	 that have exit sequences defined.  */
-      if (face->tty_underline_p)
+      if (face->underline)
 	OUTPUT_IF (tty, tty->TS_exit_underline_mode);
     }
 
@@ -2036,6 +2055,9 @@ #define TTY_CAPABLE_P_TRY(tty, cap, TS, NC_bit)				\
   TTY_CAPABLE_P_TRY (tty,
 		     TTY_CAP_UNDERLINE,	  tty->TS_enter_underline_mode,
 		     NC_UNDERLINE);
+  TTY_CAPABLE_P_TRY (tty,
+		     TTY_CAP_UNDERLINE_STYLED,	  tty->TF_set_underline_style,
+		     NC_UNDERLINE);
   TTY_CAPABLE_P_TRY (tty,
 		     TTY_CAP_BOLD,	  tty->TS_enter_bold_mode, NC_BOLD);
   TTY_CAPABLE_P_TRY (tty,
@@ -4250,6 +4272,30 @@ init_tty (const char *name, const char *terminal_type, bool must_succeed)
   tty->TF_underscore = tgetflag ("ul");
   tty->TF_teleray = tgetflag ("xt");
 
+  /* Styled underlines.  Support for this is provided either by the
+     escape sequence in Smulx or the Su flag.  The latter results in a
+     common default escape sequence and is not recommended.  */
+#ifdef TERMINFO
+	tty->TF_set_underline_style = tigetstr("Smulx");
+	if (tty->TF_set_underline_style == (char *) (intptr_t) -1)
+		tty->TF_set_underline_style = NULL;
+#else
+	tty->TF_set_underline_style = tgetstr("Smulx", address);
+#endif
+	if (!tty->TF_set_underline_style && tgetflag("Su"))
+		/* Default to the kitty escape sequence.  See
+		   https://sw.kovidgoyal.net/kitty/underlines/ */
+		tty->TF_set_underline_style = "\x1b[4:%p1%dm";
+
+	if (tty->TF_set_underline_style)
+		/* This escape sequence for setting the underline color is
+		   consistent with the one described in kitty (see above) and
+		   adapted from the one used by neovim.  This sequence has
+		   been altered from the neovim sequence at
+		   https://github.com/neovim/neovim/blob/42f492ac99058bd1cd56c3c7871e7e464b2a5e24/src/nvim/tui/tui.c
+		   to require only a single parameter, the color index.  */
+		tty->TF_set_underline_color = "\x1b[58:2::%p1%{65536}%/%d:%p1%{256}%/%{255}%&%d:%p1%{255}%&%dm";
+
 #else /* DOS_NT */
 #ifdef WINDOWSNT
   {
diff --git a/src/termchar.h b/src/termchar.h
index 5c47679a994..946ffb344d9 100644
--- a/src/termchar.h
+++ b/src/termchar.h
@@ -171,6 +171,13 @@ #define EMACS_TERMCHAR_H
                                    non-blank position.  Must clear before writing _.  */
   int TF_teleray;               /* termcap xt flag: many weird consequences.
                                    For t1061. */
+  const char *TF_set_underline_style; /* termcap Smulx entry: Switches the underline
+                                         style based on the parameter.  Param should
+                                         be one of: 0 (none), 1 (straight), 2 (double),
+                                         3 (wave), 4 (dotted), or 5 (dashed).  */
+  const char *TF_set_underline_color; /* Enabled when TF_set_underline_style is set:
+                                         Sets the color of the underline.  Accepts a
+                                         single parameter, the color index.  */
 
   int RPov;                     /* # chars to start a TS_repeat */
 
diff --git a/src/xfaces.c b/src/xfaces.c
index 37b703984be..65118ff020e 100644
--- a/src/xfaces.c
+++ b/src/xfaces.c
@@ -3255,7 +3255,11 @@ DEFUN ("internal-set-lisp-face-attribute", Finternal_set_lisp_face_attribute,
                 }
 
               else if (EQ (key, QCstyle)
-                       && !(EQ (val, Qline) || EQ (val, Qwave)))
+                       && !(EQ (val, Qline)
+                            || EQ (val, Qdouble)
+                            || EQ (val, Qwave)
+                            || EQ (val, Qdotted)
+                            || EQ (val, Qdashed)))
                 {
                   valid_p = false;
                   break;
@@ -5204,6 +5208,7 @@ gui_supports_face_attributes_p (struct frame *f,
                                 Lisp_Object attrs[LFACE_VECTOR_SIZE],
                                 struct face *def_face)
 {
+  Lisp_Object val;
   Lisp_Object *def_attrs = def_face->lface;
   Lisp_Object lattrs[LFACE_VECTOR_SIZE];
 
@@ -5298,6 +5303,20 @@ gui_supports_face_attributes_p (struct frame *f,
       return false;
     }
 
+  /* Check supported underline styles. */
+  val = attrs[LFACE_UNDERLINE_INDEX];
+  if (!UNSPECIFIEDP (val))
+    {
+	if (EQ (CAR_SAFE (val), QCstyle))
+	  {
+		if (!(EQ (CAR_SAFE (CDR_SAFE (val)), Qline)
+		      || EQ (CAR_SAFE (CDR_SAFE (val)), Qwave)))
+		  {
+			return false; /* Unsupported underline style */
+		  }
+	  }
+    }
+
   /* Everything checks out, this face is supported.  */
   return true;
 }
@@ -5390,15 +5409,26 @@ tty_supports_face_attributes_p (struct frame *f,
   val = attrs[LFACE_UNDERLINE_INDEX];
   if (!UNSPECIFIEDP (val))
     {
-      if (STRINGP (val))
-	return false;		/* ttys can't use colored underlines */
-      else if (EQ (CAR_SAFE (val), QCstyle) && EQ (CAR_SAFE (CDR_SAFE (val)), Qwave))
-	return false;		/* ttys can't use wave underlines */
-      else if (face_attr_equal_p (val, def_attrs[LFACE_UNDERLINE_INDEX]))
-	return false;		/* same as default */
-      else
-	test_caps |= TTY_CAP_UNDERLINE;
-    }
+	if (STRINGP (val))
+		test_caps |= TTY_CAP_UNDERLINE_STYLED;
+	else if (EQ (CAR_SAFE (val), QCstyle))
+	  {
+	if (!(EQ (CAR_SAFE (CDR_SAFE (val)), Qline)
+	      || EQ (CAR_SAFE (CDR_SAFE (val)), Qdouble)
+	      || EQ (CAR_SAFE (CDR_SAFE (val)), Qwave)
+	      || EQ (CAR_SAFE (CDR_SAFE (val)), Qdotted)
+	      || EQ (CAR_SAFE (CDR_SAFE (val)), Qdashed)))
+	  {
+		return false; /* Face uses an unsupported underline style.  */
+	  }
+
+	test_caps |= TTY_CAP_UNDERLINE_STYLED;
+	  }
+	else if (face_attr_equal_p (val, def_attrs[LFACE_UNDERLINE_INDEX]))
+		return false;  /* same as default */
+	else
+		test_caps |= TTY_CAP_UNDERLINE;
+  }
 
   /* inverse video */
   val = attrs[LFACE_INVERSE_INDEX];
@@ -6319,6 +6349,8 @@ realize_gui_face (struct face_cache *cache, Lisp_Object attrs[LFACE_VECTOR_SIZE]
                 face->underline = FACE_UNDER_LINE;
               else if (EQ (value, Qwave))
                 face->underline = FACE_UNDER_WAVE;
+              else
+                face->underline = FACE_UNDER_LINE;
             }
 	  else if (EQ (keyword, QCposition))
 	    {
@@ -6453,6 +6485,7 @@ realize_tty_face (struct face_cache *cache,
 {
   struct face *face;
   int weight, slant;
+  Lisp_Object underline;
   bool face_colors_defaulted = false;
   struct frame *f = cache->f;
 
@@ -6472,13 +6505,74 @@ realize_tty_face (struct face_cache *cache,
     face->tty_bold_p = true;
   if (slant != 100)
     face->tty_italic_p = true;
-  if (!NILP (attrs[LFACE_UNDERLINE_INDEX]))
-    face->tty_underline_p = true;
   if (!NILP (attrs[LFACE_INVERSE_INDEX]))
     face->tty_reverse_p = true;
   if (!NILP (attrs[LFACE_STRIKE_THROUGH_INDEX]))
     face->tty_strike_through_p = true;
 
+  /* Text underline.  */
+  underline = attrs[LFACE_UNDERLINE_INDEX];
+  if (NILP (underline))
+    {
+	face->underline = FACE_NO_UNDERLINE;
+	face->underline_color = 0;
+    }
+  else if (EQ (underline, Qt))
+    {
+	face->underline = FACE_UNDER_LINE;
+	face->underline_color = 0;
+    }
+  else if (STRINGP (underline))
+    {
+	face->underline = FACE_UNDER_LINE;
+	face->underline_color = load_color (f, face, underline, LFACE_UNDERLINE_INDEX);
+    }
+  else if (CONSP (underline))
+    {
+	/* `(:color COLOR :style STYLE)'.
+	   STYLE being one of `line', `double', `wave', `dotted' or `dashed'.  */
+	face->underline = FACE_UNDER_LINE;
+	face->underline_color = 0;
+
+	while (CONSP (underline))
+	  {
+		Lisp_Object keyword, value;
+
+		keyword = XCAR (underline);
+		underline = XCDR (underline);
+
+		if (!CONSP (underline))
+			break;
+		value = XCAR (underline);
+		underline = XCDR (underline);
+
+		if (EQ (keyword, QCcolor))
+		  {
+			if (EQ (value, Qforeground_color))
+				face->underline_color = 0;
+			else if (STRINGP (value))
+				face->underline_color
+				    = load_color (f, face, value,
+				                  LFACE_UNDERLINE_INDEX);
+		  }
+		else if (EQ (keyword, QCstyle))
+		  {
+			if (EQ (value, Qline))
+				face->underline = FACE_UNDER_LINE;
+			else if (EQ (value, Qdouble))
+				face->underline = FACE_DOUBLE_UNDER_LINE;
+			else if (EQ (value, Qwave))
+				face->underline = FACE_UNDER_WAVE;
+			else if (EQ (value, Qdotted))
+				face->underline = FACE_DOTTED_UNDER_LINE;
+			else if (EQ (value, Qdashed))
+				face->underline = FACE_DASHED_UNDER_LINE;
+			else
+				face->underline = FACE_UNDER_LINE;
+		  }
+	  }
+    }
+
   /* Map color names to color indices.  */
   map_tty_color (f, face, LFACE_FOREGROUND_INDEX, &face_colors_defaulted);
   map_tty_color (f, face, LFACE_BACKGROUND_INDEX, &face_colors_defaulted);
@@ -7165,6 +7259,9 @@ syms_of_xfaces (void)
   DEFSYM (QCposition, ":position");
   DEFSYM (Qline, "line");
   DEFSYM (Qwave, "wave");
+  DEFSYM (Qdouble, "double");
+  DEFSYM (Qdotted, "dotted");
+  DEFSYM (Qdashed, "dashed");
   DEFSYM (Qreleased_button, "released-button");
   DEFSYM (Qpressed_button, "pressed-button");
   DEFSYM (Qflat_button, "flat-button");
-- 
2.40.0





Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#62994: [PATCH 2/3] Add support for styled underlines on tty frames
Resent-From: Eli Zaretskii <eliz@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Sat, 22 Apr 2023 06:48:01 +0000
Resent-Message-ID: <handler.62994.B62994.168214602418491 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 62994
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: 
To: Mohsin Kaleem <mohkale@HIDDEN>
Cc: 62994 <at> debbugs.gnu.org
Received: via spool by 62994-submit <at> debbugs.gnu.org id=B62994.168214602418491
          (code B ref 62994); Sat, 22 Apr 2023 06:48:01 +0000
Received: (at 62994) by debbugs.gnu.org; 22 Apr 2023 06:47:04 +0000
Received: from localhost ([127.0.0.1]:41552 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1pq71T-0004oB-N5
	for submit <at> debbugs.gnu.org; Sat, 22 Apr 2023 02:47:04 -0400
Received: from eggs.gnu.org ([209.51.188.92]:48960)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1pq71Q-0004ng-EM
 for 62994 <at> debbugs.gnu.org; Sat, 22 Apr 2023 02:47:01 -0400
Received: from fencepost.gnu.org ([2001:470:142:3::e])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1pq71K-0001hl-UK; Sat, 22 Apr 2023 02:46:54 -0400
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date:
 mime-version; bh=YvjaBYSYaHzkheO9q6MLf0sAhimoxJ4DZcS80LvyZ+Y=; b=JonGi7Y8K2XS
 rLNXYbTVd098qJBbvk6BCWHvJRgAOcwyEVGysqHCzYxZ0B/55pjjZsWLOlvB+ir3zlol61SsYQ47G
 nC/ZFh3OWGJDK2lALP2cCXt4KaeO/zgAdqUlVD1XsJ9HslPVO8JansyyCjB8NFuGaauym43wNDUI1
 iwkBzOxbBAPxjq3Rz5JP4J9WVl3ypTfBJX9PkqR0Xug/9HPCTi0246JC4DrwF5bWrPJNSK+F9ZSyJ
 8xl6Ob8+cEDD7Dryj0esbxVjKj622Xv/nLUd4X32LWYyeIgBh6DMW41vCi+kpYxHGKOxmXSWGB04Z
 w33FCvfAnceMewkOb4L8xA==;
Received: from [87.69.77.57] (helo=home-c4e4a596f7)
 by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1pq71J-0003Z7-T4; Sat, 22 Apr 2023 02:46:54 -0400
Date: Sat, 22 Apr 2023 09:47:12 +0300
Message-Id: <83leik2z2n.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
In-Reply-To: <87354t5cyq.fsf@HIDDEN> (message from Mohsin Kaleem on Fri,
 21 Apr 2023 19:04:13 +0100)
References: <handler.62994.B.168208734930664.ack <at> debbugs.gnu.org>
 <20230421143448.339022-1-mohkale@HIDDEN>
 <20230421143448.339022-3-mohkale@HIDDEN> <83y1ml2p8a.fsf@HIDDEN>
 <878rel5fqr.fsf@HIDDEN> <83sfct2kio.fsf@HIDDEN>
 <87354t5cyq.fsf@HIDDEN>
X-Spam-Score: -2.3 (--)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> From: Mohsin Kaleem <mohkale@HIDDEN>
> Cc: 62994 <at> debbugs.gnu.org
> Date: Fri, 21 Apr 2023 19:04:13 +0100
> 
> Eli Zaretskii <eliz@HIDDEN> writes:
> 
> > Yes, in standards.info.  This is the GNU recommended style.
> 
> Cool, doesn't seem to be in the Emacs repo but I'm guessing it's this
> [1].

Yes.

> I'll try to adapt to it.

It should be easier now, since .dir-locals.el now does that for
c-ts-mode as well, not just for c-mode.

> > Did Kitty invent that?  If not, there must be some reference that is
> > not the source code of a terminal emulator.
> 
> I think it did. What I've found online indicates kitty invented it, used
> Su for the termcap, this lead to an issue on tmux which suggested
> changing it to Smulx [2]. That's why the termcap for it is inconsistent.
> I can't find any reference for support before kitty.

Are there any terminal emulators besides Kitty which support these
attributes?  They should perhaps be mentioned in the NEWS entry.




Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#62994: [PATCH 2/3] Add support for styled underlines on tty frames
Resent-From: Eli Zaretskii <eliz@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Sat, 22 Apr 2023 07:01:02 +0000
Resent-Message-ID: <handler.62994.B62994.168214683720606 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 62994
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: 
To: Mohsin Kaleem <mohkale@HIDDEN>
Cc: 62994 <at> debbugs.gnu.org
Received: via spool by 62994-submit <at> debbugs.gnu.org id=B62994.168214683720606
          (code B ref 62994); Sat, 22 Apr 2023 07:01:02 +0000
Received: (at 62994) by debbugs.gnu.org; 22 Apr 2023 07:00:37 +0000
Received: from localhost ([127.0.0.1]:41562 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1pq7Ea-0005MH-Kx
	for submit <at> debbugs.gnu.org; Sat, 22 Apr 2023 03:00:36 -0400
Received: from eggs.gnu.org ([209.51.188.92]:50686)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1pq7EY-0005M4-EW
 for 62994 <at> debbugs.gnu.org; Sat, 22 Apr 2023 03:00:35 -0400
Received: from fencepost.gnu.org ([2001:470:142:3::e])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1pq7ES-0004Fe-QQ; Sat, 22 Apr 2023 03:00:28 -0400
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date:
 mime-version; bh=E8bpFYoj9NusJExsNx3oMdxJoY4cZymYPRg8yxeh0AY=; b=hBx/ONjpvPTx
 +oeLxscqpgmUL0bXdhBS8jrIIeCQj9VCHop/6AF1dCgMX39s4S6faL4aP5ZEXCfdQzGGikHvyLaZ6
 bhNFcUsxzcj+urfTwmMmiGz8C0tpG9KmS2LPOZSFGfGwK94bxbMWL/wbf1cXLk7NoHi8MqU1UbL1G
 4ehIqCO9YnHA4S3hpA8b0qWKZ0AS8aK7h9z7uulPAgl9+46TIOmxfxAh8YePVnuTzmHWIvs0PegVL
 wI0vOa+ZuPf23M7C+QJSAWF2IJerK4fKXSX5sNgbffUBzAP+V7Q0CFWUNbYbd6Xmhzs4HhRSuveCo
 t0xDfHIyBCcW/yDkYkIvPw==;
Received: from [87.69.77.57] (helo=home-c4e4a596f7)
 by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1pq7ES-0001QX-8I; Sat, 22 Apr 2023 03:00:28 -0400
Date: Sat, 22 Apr 2023 10:00:46 +0300
Message-Id: <83ildo2yg1.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
In-Reply-To: <87zg713wlg.fsf@HIDDEN> (message from Mohsin Kaleem on Fri,
 21 Apr 2023 19:43:07 +0100)
References: <handler.62994.B.168208734930664.ack <at> debbugs.gnu.org>
 <20230421143448.339022-1-mohkale@HIDDEN>
 <20230421143448.339022-3-mohkale@HIDDEN> <83y1ml2p8a.fsf@HIDDEN>
 <878rel5fqr.fsf@HIDDEN> <83sfct2kio.fsf@HIDDEN>
 <87354t5cyq.fsf@HIDDEN> <87zg713wlg.fsf@HIDDEN>
X-Spam-Score: -2.3 (--)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> From: Mohsin Kaleem <mohkale@HIDDEN>
> Cc: 62994 <at> debbugs.gnu.org
> Date: Fri, 21 Apr 2023 19:43:07 +0100
> 
> Mohsin Kaleem <mohkale@HIDDEN> writes:
> 
> > Cool, doesn't seem to be in the Emacs repo but I'm guessing it's this
> > [1]. I'll try to adapt to it.
> 
> I still don't get how to apply this to this repo Eli. You mentioned using
> tabs and spaces but every lines aside from a nested expression starts
> with 2 spaces. Some times there's 3 levels deep of expressions all
> indented with spaces and then one tab width just wide enough at 8
> characters to appear like it's indented with spaces atop the previous
> scope.
> 
> Can I just do leading indent with tabs matching current indentation
> level, curly braces 2 space ahead of the parent indent, and spaces ahead
> of tabs to align a parenthesized expression or multi line condition with
> the previous line?

Why are you doing this manually?  Emacs does that for you, as soon as
you set indent-tabs-mode to a non-nil value.  .dir-locals.el in the
Emacs Git repository should do that automatically; it already does on
the release branch and soon will be doing that on the master branch as
well.  And to reformat existing code, make a region around it and
invoke "M-x tabify".

There should be no need to insert tabs and spaces manually.




Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#62994: [PATCH 2/3] Add support for styled underlines on tty frames
Resent-From: Mohsin Kaleem <mohkale@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Sat, 22 Apr 2023 09:33:02 +0000
Resent-Message-ID: <handler.62994.B62994.16821559485487 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 62994
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: 
To: Eli Zaretskii <eliz@HIDDEN>
Cc: 62994 <at> debbugs.gnu.org
Received: via spool by 62994-submit <at> debbugs.gnu.org id=B62994.16821559485487
          (code B ref 62994); Sat, 22 Apr 2023 09:33:02 +0000
Received: (at 62994) by debbugs.gnu.org; 22 Apr 2023 09:32:28 +0000
Received: from localhost ([127.0.0.1]:41802 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1pq9bY-0001QR-14
	for submit <at> debbugs.gnu.org; Sat, 22 Apr 2023 05:32:28 -0400
Received: from 119.ip-51-38-65.eu ([51.38.65.119]:46836 helo=mail.kisara.moe)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <mohkale@HIDDEN>) id 1pq9bV-0001QE-27
 for 62994 <at> debbugs.gnu.org; Sat, 22 Apr 2023 05:32:27 -0400
Received: from mk-deck (unknown [146.70.132.183])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange ECDHE (prime256v1) server-signature ECDSA (prime256v1)
 server-digest SHA256) (No client certificate requested)
 by mail.kisara.moe (Postfix) with ESMTPSA id 57C3CA0FB5;
 Sat, 22 Apr 2023 11:32:23 +0200 (CEST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kisara.moe;
 s=default; t=1682155943;
 bh=tRFSg3fp2Kt/BwMxOGE2v9XIMNocAUeB0hg7ePpGT9k=;
 h=From:To:Cc:Subject:In-Reply-To:References:Date:From;
 b=q9pe4oCA42KOO3C58jB2jwcTwCctJSG1Cdq2FPFm2Ajg4j6NF9h6J+yiCJmSCWbZt
 4/COaZTJqwurZspnwbYgYCYD1xs/z1WBH/J7emAM37N62/kVX7+PMQgnpiojvOVM4h
 n31JIhZ2JWtuO16eD5BRQjlmSogISZRgi8aqYdenHPKn4g72sHxo/58DLloJwQ6VCC
 idmRqfpy3lfhQANxumZsKCeVYgFnfutK7cZj+mQ4Q4l0/qh8cfLyyzvKZEZOcoTJyR
 ykD2xtXIQxIO/ukR788b9TAgw+I0VgSIQBRa9MGQtsW+HRHlfO3hsbM1hQt5YKD9JD
 iSKsttCQofm/A==
From: Mohsin Kaleem <mohkale@HIDDEN>
In-Reply-To: <83ildo2yg1.fsf@HIDDEN>
References: <handler.62994.B.168208734930664.ack <at> debbugs.gnu.org>
 <20230421143448.339022-1-mohkale@HIDDEN>
 <20230421143448.339022-3-mohkale@HIDDEN> <83y1ml2p8a.fsf@HIDDEN>
 <878rel5fqr.fsf@HIDDEN> <83sfct2kio.fsf@HIDDEN>
 <87354t5cyq.fsf@HIDDEN> <87zg713wlg.fsf@HIDDEN>
 <83ildo2yg1.fsf@HIDDEN>
Date: Sat, 22 Apr 2023 10:32:23 +0100
Message-ID: <87r0scb6u0.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: 0.4 (/)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.6 (/)

Eli Zaretskii <eliz@HIDDEN> writes:

> Why are you doing this manually?  Emacs does that for you, as soon as
> you set indent-tabs-mode to a non-nil value.  .dir-locals.el in the
> Emacs Git repository should do that automatically; it already does on
> the release branch and soon will be doing that on the master branch as
> well.  And to reformat existing code, make a region around it and
> invoke "M-x tabify".
>
> There should be no need to insert tabs and spaces manually.

Cool. If that works then I'll just reindent any affected hunks using M-x
tabify :-). As for why I didn't do it before, I suppose because I'm used
to Emacs never being able to indent as it should and then re-indenting on
top of my changes with formatters like clang-format. When I don't have
that the only approach I know of is manual.

-- 
Mohsin Kaleem




Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#62994: [PATCH 2/3] Add support for styled underlines on tty frames
Resent-From: Mohsin Kaleem <mohkale@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Sat, 22 Apr 2023 09:58:02 +0000
Resent-Message-ID: <handler.62994.B62994.16821574738754 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 62994
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: 
To: Eli Zaretskii <eliz@HIDDEN>
Cc: 62994 <at> debbugs.gnu.org
Received: via spool by 62994-submit <at> debbugs.gnu.org id=B62994.16821574738754
          (code B ref 62994); Sat, 22 Apr 2023 09:58:02 +0000
Received: (at 62994) by debbugs.gnu.org; 22 Apr 2023 09:57:53 +0000
Received: from localhost ([127.0.0.1]:41829 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1pqA08-0002H8-Tw
	for submit <at> debbugs.gnu.org; Sat, 22 Apr 2023 05:57:53 -0400
Received: from 119.ip-51-38-65.eu ([51.38.65.119]:50016 helo=mail.kisara.moe)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <mohkale@HIDDEN>) id 1pqA03-0002Gx-TC
 for 62994 <at> debbugs.gnu.org; Sat, 22 Apr 2023 05:57:51 -0400
Received: from mk-deck (unknown [146.70.133.87])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange ECDHE (prime256v1) server-signature ECDSA (prime256v1)
 server-digest SHA256) (No client certificate requested)
 by mail.kisara.moe (Postfix) with ESMTPSA id B02A0A0FB5;
 Sat, 22 Apr 2023 11:57:46 +0200 (CEST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kisara.moe;
 s=default; t=1682157466;
 bh=kUz4vqFInCd7w5Ib/lH4gwLKCHe4tyBNHpvUfSlbiQg=;
 h=From:To:Cc:Subject:In-Reply-To:References:Date:From;
 b=sJBpPpRlayQJMkARM3hk2V918fbKJkbcoxPM+j2lezxw6gJZTS1qrVQQ0pcylFlSo
 dur9uM8n1PQrwZjzaDk5jPDtuU6T1vnRnlbicJGU+AAy70JoV/4K7MaBD8PD2h3AXm
 cxYqLQJZpCsZHbRBJJSyQ21Cg61Ge377lzSAcS7TuVfegNfALhupoJQDSmCQdmP04v
 hYZdr9nFN9ypLXD5LEIv4crkvXrQ3UV5779M3fI0D4j/uRKtAwZ7RkanrzuIfosYMQ
 Wpw52Y98ZX1czUFNIgYv0OiaXacWLeylcFVbcz+SFNVvmUmxR4v4+nKC1vv/oVGapy
 GWTbQwPSvHnQg==
From: Mohsin Kaleem <mohkale@HIDDEN>
In-Reply-To: <83leik2z2n.fsf@HIDDEN>
References: <handler.62994.B.168208734930664.ack <at> debbugs.gnu.org>
 <20230421143448.339022-1-mohkale@HIDDEN>
 <20230421143448.339022-3-mohkale@HIDDEN> <83y1ml2p8a.fsf@HIDDEN>
 <878rel5fqr.fsf@HIDDEN> <83sfct2kio.fsf@HIDDEN>
 <87354t5cyq.fsf@HIDDEN> <83leik2z2n.fsf@HIDDEN>
Date: Sat, 22 Apr 2023 10:57:46 +0100
Message-ID: <87o7ngb5np.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: 0.4 (/)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.6 (/)

Eli Zaretskii <eliz@HIDDEN> writes:

> Are there any terminal emulators besides Kitty which support these
> attributes?  They should perhaps be mentioned in the NEWS entry.

I've tested the following. I'll add the relevant ones to the NEWS file:

- vte4 (through libvte). Supports both colored and styled underlines,
  but for some reason vte4 uses a TERM of xterm-256color for me so it
  hasn't got the termcaps to expose that it supports it. I guess it
  expects users to override it or is waiting for xterm to support it :/.
- xterm doesn't. I've never used xterm, it might be possible to
  configure it but I won't bother testing too thoroughly.
- St supports styled and colored underlines through the curly underlines
  patch.
- xterm.js apparently supports it [1] but installing hyper to check is
  taking forever so I can't confirm :/. Darn web terminals.

[1]: https://github.com/xtermjs/xterm.js/issues/1145

-- 
Mohsin Kaleem




Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#62994: [PATCH v3 1/1] Add support for colored and styled underlines on tty frames
Resent-From: mohkale@HIDDEN
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Sat, 22 Apr 2023 10:22:01 +0000
Resent-Message-ID: <handler.62994.B62994.168215891911444 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 62994
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: 
To: Eli Zaretskii <eliz@HIDDEN>, 62994 <at> debbugs.gnu.org
Cc: Mohsin Kaleem <mohkale@HIDDEN>
Received: via spool by 62994-submit <at> debbugs.gnu.org id=B62994.168215891911444
          (code B ref 62994); Sat, 22 Apr 2023 10:22:01 +0000
Received: (at 62994) by debbugs.gnu.org; 22 Apr 2023 10:21:59 +0000
Received: from localhost ([127.0.0.1]:41901 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1pqANS-0002yU-2q
	for submit <at> debbugs.gnu.org; Sat, 22 Apr 2023 06:21:59 -0400
Received: from 119.ip-51-38-65.eu ([51.38.65.119]:58994 helo=mail.kisara.moe)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <mohkale@HIDDEN>) id 1pqANN-0002yE-Lw
 for 62994 <at> debbugs.gnu.org; Sat, 22 Apr 2023 06:21:56 -0400
Received: from localhost.localdomain (unknown [146.70.133.87])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256)
 (No client certificate requested)
 by mail.kisara.moe (Postfix) with ESMTPSA id 3E342A0FFD;
 Sat, 22 Apr 2023 12:21:52 +0200 (CEST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kisara.moe;
 s=default; t=1682158912;
 bh=IwuBsaHFZkmWm0xIYK0Hqh7ZntEBOz6shNXlC/jvjgU=;
 h=From:To:Cc:Subject:Date:In-Reply-To:References:From;
 b=nq7RwZRnxVMyIpNKtlGI95avwKzLJWBvTRoFDUm0PUEQaL1U3YFi1xW8vV+I2gSlY
 gN8/YFntnAMGLfsE+dnetyTWheNyK9YhHICiQkJlkX0VFyOuciEEJY59AkVC+2Hc7C
 GxdW9gA8d5KRO8hvsvob8wvgswbWEssD4kB9zv+han+WYy34Iu8t+IBWrMrS/kwow5
 RsbZFlQkZ5lJzjEAHzPKQ3GxJgyrAdV3tSi91hh1zi71QsC7PEIhQDKVhyqgw6D/PV
 Vuk9fyF/De0WBaG/UiSs/QBISQFrn/WTRF8JKmcbcrZgW5jZAAq7CI7xVzm3ny1cW9
 S8n37Z3N7/erw==
From: mohkale@HIDDEN
Date: Sat, 22 Apr 2023 11:21:46 +0100
Message-Id: <20230422102146.93003-2-mohkale@HIDDEN>
X-Mailer: git-send-email 2.40.0
In-Reply-To: <20230422102146.93003-1-mohkale@HIDDEN>
References: <handler.62994.B.168208734930664.ack <at> debbugs.gnu.org>
 <20230422102146.93003-1-mohkale@HIDDEN>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
X-Spam-Score: 0.4 (/)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.6 (/)

From: Mohsin Kaleem <mohkale@HIDDEN>

* src/dispextern.h (face, face_underline_type, syms_of_xfacse,
internal-set-lisp-face-attribute, gui_supports_face_attributes_p):
Add definitions for new underline styles of Double, Dotted and Dashed.
Delete tty_underline_p from the face struct and use just underline going
forward.  Add a flag to check whether styled underlines are available.
* lisp/cus-face.el (custom-face-attributes): Add entries for Double,
Dotted and Dashed so they can be set through `customize'.
* src/termchar.c (tty_display_info): Add an entry for the escape
sequence to set the underline style and color on terminal frames.
* src/term.c (init_tty, tty_capable_p, turn_on_face): Read and save the
underline style escape sequence from the Smulx termcap (alternatively if
the Su flag is set use a default sequence).  Allow checking for support
of styled underlines in the current terminal frame.  Output the necessary
escape sequences to activate a styled underline on turn_on_face; this is
currently only used for the new special underline styles, a default
straight underline will still use the "us" termcap.  Output escape
sequence to set underline color when set in the face and supported by
the tty.  Save a default value for this sequence on init_tty when styled
underlines are supported.
* src/xfaces.c (tty_supports_face_attributes_p, realize_tty_face):
Assert whether styled underlines are supported by the current terminal
on display-supports-face-attributes-p checks.  Populate the correct
underline style and color in the face spec when realizing a face.
---
 etc/NEWS         |  13 +++++
 lisp/cus-face.el |   5 +-
 src/dispextern.h |  10 ++--
 src/term.c       |  54 +++++++++++++++++++--
 src/termchar.h   |   7 +++
 src/xfaces.c     | 121 ++++++++++++++++++++++++++++++++++++++++++-----
 6 files changed, 190 insertions(+), 20 deletions(-)

diff --git a/etc/NEWS b/etc/NEWS
index 62d2fdcd3a4..b552bb2d75e 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -1916,6 +1916,19 @@ This command switches to the "*scratch*" buffer.  If "*scratch*" doesn't
 exist, the command creates it first.  You can use this command if you
 inadvertently delete the "*scratch*" buffer.
 
+---
+** Support for 'styled' and 'colored' underline face attributes on TTY frames
+If your terminals termcap or terminfo database entry has the 'Su' or
+'Smulx' capability defined, Emacs will now emit the prescribed escape
+sequence necessary to render faces with styled underlines on TTY
+frames.
+
+Styled underlines are any underlines containing a non-default
+underline style or a color other than the foreground-color.
+The available underline styles for TTY frames are 'double', 'wave',
+'dotted', and 'dashed'.  These are currently supported by Kitty,
+libvte, and st (through the undercurl patch) among other terminals.
+
 ** Debugging
 
 ---
diff --git a/lisp/cus-face.el b/lisp/cus-face.el
index ec89b4f7ff6..2d6e6c7b73e 100644
--- a/lisp/cus-face.el
+++ b/lisp/cus-face.el
@@ -141,7 +141,10 @@ custom-face-attributes
 		   (const :format "" :value :style)
 		   (choice :tag "Style"
 			   (const :tag "Line" line)
-			   (const :tag "Wave" wave))
+			   (const :tag "Double" double)
+			   (const :tag "Wave" wave)
+			   (const :tag "Dotted" dotted)
+			   (const :tag "Dashed" dashed))
                    (const :format "" :value :position)
                    (choice :tag "Position"
                            (const :tag "At Default Position" nil)
diff --git a/src/dispextern.h b/src/dispextern.h
index 4dcab113ea2..753bee446f1 100644
--- a/src/dispextern.h
+++ b/src/dispextern.h
@@ -1653,9 +1653,13 @@ #define FONT_TOO_HIGH(ft)						\
 
 enum face_underline_type
 {
+	/* Note: Order matches the order of the Smulx terminfo extension. */
   FACE_NO_UNDERLINE = 0,
   FACE_UNDER_LINE,
-  FACE_UNDER_WAVE
+  FACE_DOUBLE_UNDER_LINE,
+  FACE_UNDER_WAVE,
+  FACE_DOTTED_UNDER_LINE,
+  FACE_DASHED_UNDER_LINE,
 };
 
 /* Structure describing a realized face.
@@ -1737,7 +1741,7 @@ #define FONT_TOO_HIGH(ft)						\
   ENUM_BF (face_box_type) box : 2;
 
   /* Style of underlining. */
-  ENUM_BF (face_underline_type) underline : 2;
+  ENUM_BF (face_underline_type) underline : 3;
 
   /* If `box' above specifies a 3D type, true means use box_color for
      drawing shadows.  */
@@ -1769,7 +1773,6 @@ #define FONT_TOO_HIGH(ft)						\
      string meaning the default color of the TTY.  */
   bool_bf tty_bold_p : 1;
   bool_bf tty_italic_p : 1;
-  bool_bf tty_underline_p : 1;
   bool_bf tty_reverse_p : 1;
   bool_bf tty_strike_through_p : 1;
 
@@ -3361,6 +3364,7 @@ #define TTY_CAP_BOLD		0x04
 #define TTY_CAP_DIM		0x08
 #define TTY_CAP_ITALIC  	0x10
 #define TTY_CAP_STRIKE_THROUGH	0x20
+#define TTY_CAP_UNDERLINE_STYLED	0x32 & TTY_CAP_UNDERLINE
 
 
 /***********************************************************************
diff --git a/src/term.c b/src/term.c
index 53ba2a231e4..b4fb607ee1f 100644
--- a/src/term.c
+++ b/src/term.c
@@ -1948,8 +1948,19 @@ turn_on_face (struct frame *f, int face_id)
 	OUTPUT1 (tty, tty->TS_enter_dim_mode);
     }
 
-  if (face->tty_underline_p && MAY_USE_WITH_COLORS_P (tty, NC_UNDERLINE))
-    OUTPUT1_IF (tty, tty->TS_enter_underline_mode);
+  if (face->underline && MAY_USE_WITH_COLORS_P (tty, NC_UNDERLINE))
+	{
+	if (face->underline == FACE_UNDER_LINE
+		|| !tty->TF_set_underline_style)
+		OUTPUT1_IF (tty, tty->TS_enter_underline_mode);
+	else if (tty->TF_set_underline_style)
+	  {
+		char *p;
+		p = tparam(tty->TF_set_underline_style, NULL, 0, face->underline, 0, 0, 0);
+		OUTPUT (tty, p);
+		xfree (p);
+	  }
+	}
 
   if (face->tty_strike_through_p
       && MAY_USE_WITH_COLORS_P (tty, NC_STRIKE_THROUGH))
@@ -1975,6 +1986,14 @@ turn_on_face (struct frame *f, int face_id)
 	  OUTPUT (tty, p);
 	  xfree (p);
 	}
+
+	  ts = tty->TF_set_underline_color;
+	  if (ts && face->underline_color)
+	{
+	  p = tparam (ts, NULL, 0, face->underline_color, 0, 0, 0);
+	  OUTPUT (tty, p);
+	  xfree (p);
+	}
     }
 }
 
@@ -1995,7 +2014,7 @@ turn_off_face (struct frame *f, int face_id)
       if (face->tty_bold_p
 	  || face->tty_italic_p
 	  || face->tty_reverse_p
-	  || face->tty_underline_p
+	  || face->underline
 	  || face->tty_strike_through_p)
 	{
 	  OUTPUT1_IF (tty, tty->TS_exit_attribute_mode);
@@ -2007,7 +2026,7 @@ turn_off_face (struct frame *f, int face_id)
     {
       /* If we don't have "me" we can only have those appearances
 	 that have exit sequences defined.  */
-      if (face->tty_underline_p)
+      if (face->underline)
 	OUTPUT_IF (tty, tty->TS_exit_underline_mode);
     }
 
@@ -2036,6 +2055,9 @@ #define TTY_CAPABLE_P_TRY(tty, cap, TS, NC_bit)				\
   TTY_CAPABLE_P_TRY (tty,
 		     TTY_CAP_UNDERLINE,	  tty->TS_enter_underline_mode,
 		     NC_UNDERLINE);
+  TTY_CAPABLE_P_TRY (tty,
+			 TTY_CAP_UNDERLINE_STYLED,	  tty->TF_set_underline_style,
+			 NC_UNDERLINE);
   TTY_CAPABLE_P_TRY (tty,
 		     TTY_CAP_BOLD,	  tty->TS_enter_bold_mode, NC_BOLD);
   TTY_CAPABLE_P_TRY (tty,
@@ -4250,6 +4272,30 @@ init_tty (const char *name, const char *terminal_type, bool must_succeed)
   tty->TF_underscore = tgetflag ("ul");
   tty->TF_teleray = tgetflag ("xt");
 
+  /* Styled underlines.	 Support for this is provided either by the
+	 escape sequence in Smulx or the Su flag.  The latter results in a
+	 common default escape sequence and is not recommended.	 */
+#ifdef TERMINFO
+	tty->TF_set_underline_style = tigetstr("Smulx");
+	if (tty->TF_set_underline_style == (char *) (intptr_t) -1)
+		tty->TF_set_underline_style = NULL;
+#else
+	tty->TF_set_underline_style = tgetstr("Smulx", address);
+#endif
+	if (!tty->TF_set_underline_style && tgetflag("Su"))
+		/* Default to the kitty escape sequence.  See
+		   https://sw.kovidgoyal.net/kitty/underlines/ */
+		tty->TF_set_underline_style = "\x1b[4:%p1%dm";
+
+	if (tty->TF_set_underline_style)
+		/* This escape sequence for setting the underline color is
+		   consistent with the one described in kitty (see above) and
+		   adapted from the one used by neovim.	 This sequence has
+		   been altered from the neovim sequence at
+		   https://github.com/neovim/neovim/blob/42f492ac99058bd1cd56c3c7871e7e464b2a5e24/src/nvim/tui/tui.c#L1932
+		   to require only a single parameter, the color index.	 */
+		tty->TF_set_underline_color = "\x1b[58:2::%p1%{65536}%/%d:%p1%{256}%/%{255}%&%d:%p1%{255}%&%dm";
+
 #else /* DOS_NT */
 #ifdef WINDOWSNT
   {
diff --git a/src/termchar.h b/src/termchar.h
index 5c47679a994..a9c28fff5cf 100644
--- a/src/termchar.h
+++ b/src/termchar.h
@@ -171,6 +171,13 @@ #define EMACS_TERMCHAR_H
                                    non-blank position.  Must clear before writing _.  */
   int TF_teleray;               /* termcap xt flag: many weird consequences.
                                    For t1061. */
+  const char *TF_set_underline_style; /* termcap Smulx entry: Switches the underline
+										 style based on the parameter.	Param should
+										 be one of: 0 (none), 1 (straight), 2 (double),
+										 3 (wave), 4 (dotted), or 5 (dashed).  */
+  const char *TF_set_underline_color; /* Enabled when TF_set_underline_style is set:
+										 Sets the color of the underline.  Accepts a
+										 single parameter, the color index.	 */
 
   int RPov;                     /* # chars to start a TS_repeat */
 
diff --git a/src/xfaces.c b/src/xfaces.c
index 37b703984be..f07bb6c8eca 100644
--- a/src/xfaces.c
+++ b/src/xfaces.c
@@ -3255,7 +3255,11 @@ DEFUN ("internal-set-lisp-face-attribute", Finternal_set_lisp_face_attribute,
                 }
 
               else if (EQ (key, QCstyle)
-                       && !(EQ (val, Qline) || EQ (val, Qwave)))
+					   && !(EQ (val, Qline)
+							|| EQ (val, Qdouble)
+							|| EQ (val, Qwave)
+							|| EQ (val, Qdotted)
+							|| EQ (val, Qdashed)))
                 {
                   valid_p = false;
                   break;
@@ -5204,6 +5208,7 @@ gui_supports_face_attributes_p (struct frame *f,
                                 Lisp_Object attrs[LFACE_VECTOR_SIZE],
                                 struct face *def_face)
 {
+  Lisp_Object val;
   Lisp_Object *def_attrs = def_face->lface;
   Lisp_Object lattrs[LFACE_VECTOR_SIZE];
 
@@ -5298,6 +5303,20 @@ gui_supports_face_attributes_p (struct frame *f,
       return false;
     }
 
+  /* Check supported underline styles. */
+  val = attrs[LFACE_UNDERLINE_INDEX];
+  if (!UNSPECIFIEDP (val))
+	{
+	if (EQ (CAR_SAFE (val), QCstyle))
+	  {
+		if (!(EQ (CAR_SAFE (CDR_SAFE (val)), Qline)
+			  || EQ (CAR_SAFE (CDR_SAFE (val)), Qwave)))
+		  {
+			return false; /* Unsupported underline style */
+		  }
+	  }
+	}
+
   /* Everything checks out, this face is supported.  */
   return true;
 }
@@ -5390,15 +5409,26 @@ tty_supports_face_attributes_p (struct frame *f,
   val = attrs[LFACE_UNDERLINE_INDEX];
   if (!UNSPECIFIEDP (val))
     {
-      if (STRINGP (val))
-	return false;		/* ttys can't use colored underlines */
-      else if (EQ (CAR_SAFE (val), QCstyle) && EQ (CAR_SAFE (CDR_SAFE (val)), Qwave))
-	return false;		/* ttys can't use wave underlines */
-      else if (face_attr_equal_p (val, def_attrs[LFACE_UNDERLINE_INDEX]))
-	return false;		/* same as default */
-      else
-	test_caps |= TTY_CAP_UNDERLINE;
-    }
+	if (STRINGP (val))
+		test_caps |= TTY_CAP_UNDERLINE_STYLED;
+	else if (EQ (CAR_SAFE (val), QCstyle))
+	  {
+	if (!(EQ (CAR_SAFE (CDR_SAFE (val)), Qline)
+		  || EQ (CAR_SAFE (CDR_SAFE (val)), Qdouble)
+		  || EQ (CAR_SAFE (CDR_SAFE (val)), Qwave)
+		  || EQ (CAR_SAFE (CDR_SAFE (val)), Qdotted)
+		  || EQ (CAR_SAFE (CDR_SAFE (val)), Qdashed)))
+	  {
+		return false; /* Face uses an unsupported underline style.	*/
+	  }
+
+	test_caps |= TTY_CAP_UNDERLINE_STYLED;
+	  }
+	else if (face_attr_equal_p (val, def_attrs[LFACE_UNDERLINE_INDEX]))
+		return false;  /* same as default */
+	else
+		test_caps |= TTY_CAP_UNDERLINE;
+  }
 
   /* inverse video */
   val = attrs[LFACE_INVERSE_INDEX];
@@ -6319,6 +6349,8 @@ realize_gui_face (struct face_cache *cache, Lisp_Object attrs[LFACE_VECTOR_SIZE]
                 face->underline = FACE_UNDER_LINE;
               else if (EQ (value, Qwave))
                 face->underline = FACE_UNDER_WAVE;
+	      else
+		face->underline = FACE_UNDER_LINE;
             }
 	  else if (EQ (keyword, QCposition))
 	    {
@@ -6453,6 +6485,7 @@ realize_tty_face (struct face_cache *cache,
 {
   struct face *face;
   int weight, slant;
+  Lisp_Object underline;
   bool face_colors_defaulted = false;
   struct frame *f = cache->f;
 
@@ -6472,13 +6505,74 @@ realize_tty_face (struct face_cache *cache,
     face->tty_bold_p = true;
   if (slant != 100)
     face->tty_italic_p = true;
-  if (!NILP (attrs[LFACE_UNDERLINE_INDEX]))
-    face->tty_underline_p = true;
   if (!NILP (attrs[LFACE_INVERSE_INDEX]))
     face->tty_reverse_p = true;
   if (!NILP (attrs[LFACE_STRIKE_THROUGH_INDEX]))
     face->tty_strike_through_p = true;
 
+  /* Text underline.  */
+  underline = attrs[LFACE_UNDERLINE_INDEX];
+  if (NILP (underline))
+    {
+	face->underline = FACE_NO_UNDERLINE;
+	face->underline_color = 0;
+    }
+  else if (EQ (underline, Qt))
+    {
+	face->underline = FACE_UNDER_LINE;
+	face->underline_color = 0;
+    }
+  else if (STRINGP (underline))
+    {
+	face->underline = FACE_UNDER_LINE;
+	face->underline_color = load_color (f, face, underline, LFACE_UNDERLINE_INDEX);
+    }
+  else if (CONSP (underline))
+    {
+	/* `(:color COLOR :style STYLE)'.
+	   STYLE being one of `line', `double', `wave', `dotted' or `dashed'.  */
+	face->underline = FACE_UNDER_LINE;
+	face->underline_color = 0;
+
+	while (CONSP (underline))
+	  {
+		Lisp_Object keyword, value;
+
+		keyword = XCAR (underline);
+		underline = XCDR (underline);
+
+		if (!CONSP (underline))
+			break;
+		value = XCAR (underline);
+		underline = XCDR (underline);
+
+		if (EQ (keyword, QCcolor))
+		  {
+			if (EQ (value, Qforeground_color))
+				face->underline_color = 0;
+			else if (STRINGP (value))
+				face->underline_color
+				    = load_color (f, face, value,
+						  LFACE_UNDERLINE_INDEX);
+		  }
+		else if (EQ (keyword, QCstyle))
+		  {
+			if (EQ (value, Qline))
+				face->underline = FACE_UNDER_LINE;
+			else if (EQ (value, Qdouble))
+				face->underline = FACE_DOUBLE_UNDER_LINE;
+			else if (EQ (value, Qwave))
+				face->underline = FACE_UNDER_WAVE;
+			else if (EQ (value, Qdotted))
+				face->underline = FACE_DOTTED_UNDER_LINE;
+			else if (EQ (value, Qdashed))
+				face->underline = FACE_DASHED_UNDER_LINE;
+			else
+				face->underline = FACE_UNDER_LINE;
+		  }
+	  }
+    }
+
   /* Map color names to color indices.  */
   map_tty_color (f, face, LFACE_FOREGROUND_INDEX, &face_colors_defaulted);
   map_tty_color (f, face, LFACE_BACKGROUND_INDEX, &face_colors_defaulted);
@@ -7165,6 +7259,9 @@ syms_of_xfaces (void)
   DEFSYM (QCposition, ":position");
   DEFSYM (Qline, "line");
   DEFSYM (Qwave, "wave");
+  DEFSYM (Qdouble, "double");
+  DEFSYM (Qdotted, "dotted");
+  DEFSYM (Qdashed, "dashed");
   DEFSYM (Qreleased_button, "released-button");
   DEFSYM (Qpressed_button, "pressed-button");
   DEFSYM (Qflat_button, "flat-button");
-- 
2.40.0





Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#62994: [PATCH v3 0/1] Support styled underlines on tty Emacs frames
Resent-From: mohkale@HIDDEN
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Sat, 22 Apr 2023 10:22:02 +0000
Resent-Message-ID: <handler.62994.B62994.168215891911450 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 62994
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: 
To: Eli Zaretskii <eliz@HIDDEN>, 62994 <at> debbugs.gnu.org
Cc: Mohsin Kaleem <mohkale@HIDDEN>
Received: via spool by 62994-submit <at> debbugs.gnu.org id=B62994.168215891911450
          (code B ref 62994); Sat, 22 Apr 2023 10:22:02 +0000
Received: (at 62994) by debbugs.gnu.org; 22 Apr 2023 10:21:59 +0000
Received: from localhost ([127.0.0.1]:41903 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1pqANT-0002yX-2a
	for submit <at> debbugs.gnu.org; Sat, 22 Apr 2023 06:21:59 -0400
Received: from 119.ip-51-38-65.eu ([51.38.65.119]:58988 helo=mail.kisara.moe)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <mohkale@HIDDEN>) id 1pqANN-0002yD-Lz
 for 62994 <at> debbugs.gnu.org; Sat, 22 Apr 2023 06:21:57 -0400
Received: from localhost.localdomain (unknown [146.70.133.87])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256)
 (No client certificate requested)
 by mail.kisara.moe (Postfix) with ESMTPSA id 07D2DA0FB5;
 Sat, 22 Apr 2023 12:21:51 +0200 (CEST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kisara.moe;
 s=default; t=1682158912;
 bh=6g0KC4G4H/YUwO7HIoEj+HjhIuo6Y2jWHVVql078lDU=;
 h=From:To:Cc:Subject:Date:In-Reply-To:References:From;
 b=zXeim4WlCdI4O9EWPFGWSYPShk3extrqqldjFOSN9zt8yjWR9JtTQkczR8mW4X1IA
 bs4Ldl73kow6teI77+0Q/1HRh8cI45MFMTYjWPi4YioaueppB3KIZBzye5DHw32X7G
 GkBlnvcwYcsxn0N7s06qlqfEFDk31LjJSge/O6W3vBjJqXcPi7QPYm80uylNLu/XsS
 L6Zdjp8bZYMkq2TufQ/op6Q/4yW8MCZU3ZLhDOc7+uCLnQktXJJUfjp3GeXLlYzyuV
 s/CHB57Dv0pJxhB+UMm1esvao/NEfSHVPhcH1W69eKvQwHFcuDd5DNOiFcZ/ZQQc0l
 ZIwEKYti5TpqA==
From: mohkale@HIDDEN
Date: Sat, 22 Apr 2023 11:21:45 +0100
Message-Id: <20230422102146.93003-1-mohkale@HIDDEN>
X-Mailer: git-send-email 2.40.0
In-Reply-To: <handler.62994.B.168208734930664.ack <at> debbugs.gnu.org>
References: <handler.62994.B.168208734930664.ack <at> debbugs.gnu.org>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
X-Spam-Score: 0.4 (/)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.6 (/)

From: Mohsin Kaleem <mohkale@HIDDEN>

Modern terminals (such as kitty) support setting the style of an
underline with the escape sequence exposed in the Smulx termcap.
This allows for (among others) wavy underlines on terminals.
These terminals also support setting the color of these underlines
using a separate escape sequence that to the best of my knowledge
is not exposed as a termcap but has been adopted by other terminal
supporting editors like neovim.

Version 3: All changed hunks reformatted with M-x tabify.
I think the only comment that hasn't been actioned on is whether to
retain the original order of underline styles in face_underline_type.

Mohsin Kaleem (1):
  Add support for colored and styled underlines on tty frames

 etc/NEWS         |  13 +++++
 lisp/cus-face.el |   5 +-
 src/dispextern.h |  10 ++--
 src/term.c       |  54 +++++++++++++++++++--
 src/termchar.h   |   7 +++
 src/xfaces.c     | 121 ++++++++++++++++++++++++++++++++++++++++++-----
 6 files changed, 190 insertions(+), 20 deletions(-)

-- 
2.40.0





Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#62994: [PATCH v2 1/1] Add support for colored and styled underlines on tty frames
Resent-From: Robert Pluim <rpluim@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Mon, 24 Apr 2023 09:22:01 +0000
Resent-Message-ID: <handler.62994.B62994.168232811432251 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 62994
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: 
To: mohkale@HIDDEN
Cc: Eli Zaretskii <eliz@HIDDEN>, 62994 <at> debbugs.gnu.org
Received: via spool by 62994-submit <at> debbugs.gnu.org id=B62994.168232811432251
          (code B ref 62994); Mon, 24 Apr 2023 09:22:01 +0000
Received: (at 62994) by debbugs.gnu.org; 24 Apr 2023 09:21:54 +0000
Received: from localhost ([127.0.0.1]:47531 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1pqsOQ-0008O7-2R
	for submit <at> debbugs.gnu.org; Mon, 24 Apr 2023 05:21:54 -0400
Received: from mail-wm1-f43.google.com ([209.85.128.43]:61787)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <rpluim@HIDDEN>) id 1pqsON-0008Nt-Ii
 for 62994 <at> debbugs.gnu.org; Mon, 24 Apr 2023 05:21:52 -0400
Received: by mail-wm1-f43.google.com with SMTP id
 5b1f17b1804b1-3f1950f5676so29961555e9.3
 for <62994 <at> debbugs.gnu.org>; Mon, 24 Apr 2023 02:21:51 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20221208; t=1682328105; x=1684920105;
 h=content-transfer-encoding:mime-version:message-id:date:references
 :in-reply-to:subject:cc:to:from:from:to:cc:subject:date:message-id
 :reply-to; bh=IwUvFTrTku2uHuRl8/j6BwBvKqn/gvsB97A0hY1Qido=;
 b=kW5mThTjS3+YwadZsiarnem2Y8FnlSE7k+x/CgqXFCkVAgxJJadoniekxY1CmLeYE2
 VXhh1QfxX957/IPIh3bCK4mY+l7o3nBhnpiDk1sGcDW+/f+O4njPnIKojWOr1pdAR3q1
 eBIvL2rPUMS6zqu+ufXyTnZJSDDbeXVPA7yUnKVlbopuGlQ8Sd1Lwb02eozhJTvSdydF
 yYonIlpDH9aPVsWcmXjP1UV9Q0eDbcXOJtA50R6AEsskmOdOsnI/UpShCeEsWoWHHWm6
 sJrIQ3uImziVCcWbKLfEXCHvs99EjHaNO3FtqkQ+PisYSno2+hKbq9XP01ouYOsJsZKM
 DCNw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20221208; t=1682328105; x=1684920105;
 h=content-transfer-encoding:mime-version:message-id:date:references
 :in-reply-to:subject:cc:to:from:x-gm-message-state:from:to:cc
 :subject:date:message-id:reply-to;
 bh=IwUvFTrTku2uHuRl8/j6BwBvKqn/gvsB97A0hY1Qido=;
 b=D4pU+xu04rVu4F7HwjG/X3/hSEPO+L3llK4/0sjk3t89pJMiZCh41tHsva22SFJcCz
 Y7WodITyg4PYWzWmEevS+IfCRwfIfORi8XvdrSLvckw4j1ZYYCcyKKGean5hEFbZFUYF
 72Zjs0+8Kd6vfVDe0e4zyyehr0oMFcsvRyq+vehUtaLZl9wCrNgm4nFpPPQmWPQEtjIO
 CdUxRWdTs2NJGUbO+Tp/Rmawy9m0tb/lUjWX3PXifnbL0UKfdWWqGCa2tLjMvLqJj+/q
 e8tUvNvjANnhhXiaXBC0qxQlffXVa5UVzIKnz7UfHU92787bBdTf5U+/mGM2qw3pc1TO
 oVjQ==
X-Gm-Message-State: AAQBX9fKQjAK9lLy5dgtrGr+SX2I694GlUwOIedW4CRIQBQr82VroP9n
 hl02reHdG/GfVNXn+L783xPPYXfFpi0=
X-Google-Smtp-Source: AKy350ZtWEczGaVZKVD2wICovl4Ij0hGVBs+NRsYrzPvajR5PKu/QJDIFKBUnso523r9yDhFa/8XDg==
X-Received: by 2002:a1c:4b1a:0:b0:3ef:561d:255d with SMTP id
 y26-20020a1c4b1a000000b003ef561d255dmr6372939wma.41.1682328105177; 
 Mon, 24 Apr 2023 02:21:45 -0700 (PDT)
Received: from rltb ([82.66.8.55]) by smtp.gmail.com with ESMTPSA id
 w9-20020a05600c474900b003f17e37ce60sm15077683wmo.47.2023.04.24.02.21.44
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Mon, 24 Apr 2023 02:21:44 -0700 (PDT)
From: Robert Pluim <rpluim@HIDDEN>
In-Reply-To: <20230421192433.579140-2-mohkale@HIDDEN>
 (mohkale@HIDDEN's message of "Fri, 21 Apr 2023 20:24:33 +0100")
References: <handler.62994.B.168208734930664.ack <at> debbugs.gnu.org>
 <20230421192433.579140-1-mohkale@HIDDEN>
 <20230421192433.579140-2-mohkale@HIDDEN>
Date: Mon, 24 Apr 2023 11:21:43 +0200
Message-ID: <87sfcpbpp4.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-Spam-Score: 0.0 (/)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

>>>>> On Fri, 21 Apr 2023 20:24:33 +0100, mohkale@HIDDEN said:

    Mohsin> From: Mohsin Kaleem <mohkale@HIDDEN>
    Mohsin> * src/dispextern.h (face, face_underline_type,
    Mohsin> syms_of_xfacse,

This typo tell me you=CA=BCre not using 'C-x 4 a' to generate your
ChangeLog entries.
=20
    Mohsin> +---
    Mohsin> +** Support for 'styled' and 'colored' underline face
    Mohsin> attributes on TTY frames

Full stop at the end of the sentence please.

    Mohsin> +  if (face->underline && MAY_USE_WITH_COLORS_P (tty, NC_UNDERL=
INE))
    Mohsin> +    {
    Mohsin> +	if (face->underline =3D=3D FACE_UNDER_LINE
    Mohsin> +	    || !tty->TF_set_underline_style)
    Mohsin> +		OUTPUT1_IF (tty, tty->TS_enter_underline_mode);
    Mohsin> +	else if (tty->TF_set_underline_style)
    Mohsin> +	  {
    Mohsin> +		char *p;
    Mohsin> +		p =3D tparam(tty->TF_set_underline_style, NULL, 0, face->und=
erline, 0, 0, 0);
    Mohsin> +		OUTPUT (tty, p);
    Mohsin> +		xfree (p);
    Mohsin> +	  }
    Mohsin> +    }

space before '(' please.


    Mohsin>                else if (EQ (key, QCstyle)
    Mohsin> -                       && !(EQ (val, Qline) || EQ (val, Qwave)=
))
    Mohsin> +                       && !(EQ (val, Qline)
    Mohsin> +                            || EQ (val, Qdouble)
    Mohsin> +                            || EQ (val, Qwave)
    Mohsin> +                            || EQ (val, Qdotted)
    Mohsin> +                            || EQ (val, Qdashed)))

If this was in lisp I=CA=BCd expect to see `memq', but we work with what we
have :-)

    Mohsin> +  /* Check supported underline styles. */
    Mohsin> +  val =3D attrs[LFACE_UNDERLINE_INDEX];
    Mohsin> +  if (!UNSPECIFIEDP (val))
    Mohsin> +    {
    Mohsin> +	if (EQ (CAR_SAFE (val), QCstyle))
    Mohsin> +	  {
    Mohsin> +		if (!(EQ (CAR_SAFE (CDR_SAFE (val)), Qline)
    Mohsin> +		      || EQ (CAR_SAFE (CDR_SAFE (val)), Qwave)))
    Mohsin> +		  {
    Mohsin> +			return false; /* Unsupported underline style */
    Mohsin> +		  }
    Mohsin> +	  }
    Mohsin> +    }
    Mohsin> +
    Mohsin>    /* Everything checks out, this face is supported.  */
    Mohsin>    return true;
    Mohsin>  }

Your TAB usage here still looks wrong

    Mohsin> @@ -5390,15 +5409,26 @@ tty_supports_face_attributes_p (struct =
frame *f,
    Mohsin>    val =3D attrs[LFACE_UNDERLINE_INDEX];
    Mohsin>    if (!UNSPECIFIEDP (val))
    Mohsin>      {
    Mohsin> -      if (STRINGP (val))
    Mohsin> -	return false;		/* ttys can't use colored underlines */
    Mohsin> -      else if (EQ (CAR_SAFE (val), QCstyle) && EQ (CAR_SAFE (C=
DR_SAFE (val)), Qwave))
    Mohsin> -	return false;		/* ttys can't use wave underlines */
    Mohsin> -      else if (face_attr_equal_p (val, def_attrs[LFACE_UNDERLI=
NE_INDEX]))
    Mohsin> -	return false;		/* same as default */
    Mohsin> -      else
    Mohsin> -	test_caps |=3D TTY_CAP_UNDERLINE;
    Mohsin> -    }
    Mohsin> +	if (STRINGP (val))
    Mohsin> +		test_caps |=3D TTY_CAP_UNDERLINE_STYLED;
    Mohsin> +	else if (EQ (CAR_SAFE (val), QCstyle))
    Mohsin> +	  {
    Mohsin> +	if (!(EQ (CAR_SAFE (CDR_SAFE (val)), Qline)
    Mohsin> +	      || EQ (CAR_SAFE (CDR_SAFE (val)), Qdouble)
    Mohsin> +	      || EQ (CAR_SAFE (CDR_SAFE (val)), Qwave)
    Mohsin> +	      || EQ (CAR_SAFE (CDR_SAFE (val)), Qdotted)
    Mohsin> +	      || EQ (CAR_SAFE (CDR_SAFE (val)), Qdashed)))
    Mohsin> +	  {
    Mohsin> +		return false; /* Face uses an unsupported underline style.  =
*/
    Mohsin> +	  }
    Mohsin> +
    Mohsin> +	test_caps |=3D TTY_CAP_UNDERLINE_STYLED;
    Mohsin> +	  }
    Mohsin> +	else if (face_attr_equal_p (val, def_attrs[LFACE_UNDERLINE_IN=
DEX]))
    Mohsin> +		return false;  /* same as default */
    Mohsin> +	else
    Mohsin> +		test_caps |=3D TTY_CAP_UNDERLINE;
    Mohsin> +  }

And here.

Robert
--=20




Message received at control <at> debbugs.gnu.org:


Received: (at control) by debbugs.gnu.org; 6 Sep 2023 11:07:03 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Sep 06 07:07:02 2023
Received: from localhost ([127.0.0.1]:33094 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1qdqNC-0003ij-Na
	for submit <at> debbugs.gnu.org; Wed, 06 Sep 2023 07:07:02 -0400
Received: from mail-lf1-x12a.google.com ([2a00:1450:4864:20::12a]:54619)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <stefankangas@HIDDEN>) id 1qdqNA-0003i7-Ur
 for control <at> debbugs.gnu.org; Wed, 06 Sep 2023 07:07:01 -0400
Received: by mail-lf1-x12a.google.com with SMTP id
 2adb3069b0e04-50078e52537so5923153e87.1
 for <control <at> debbugs.gnu.org>; Wed, 06 Sep 2023 04:06:59 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20221208; t=1693998414; x=1694603214; darn=debbugs.gnu.org;
 h=to:subject:message-id:date:mime-version:from:from:to:cc:subject
 :date:message-id:reply-to;
 bh=DddI3oEudR9FOCnYH8KXQ3ksPjhgzB4Y4qbOaavheWI=;
 b=JoHu9RfUIwABXIbHu3DQKkMWTEzJNGt1RlkIKNnuMAMrqpm1+3t9U3sGhgV4PUj3HO
 qgbVJF59MC2hQlakU/NlPKcwcrwEgvDJayILrGSEDr4eGPNxXroIF6fT7VVZDOVGQpFW
 QeuXB7DcHMwCPeV2G2eEp8VjEU8zXOwfpHIxWohLhVCQJzxNkC2YkQuRAEotxkYdwysa
 GNfJ3scujb8DIB0deuVcU62nfE41pwPXfJDVZl6/TxSemEEt/TN+YDnQvbhVfz9GBdSW
 ExEADXD1YGHwsqKPxO0ana0SnnNkYSHkwcFsneX8zG1LraWzTAQDLPdQweyohlMozzWS
 JPpg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20221208; t=1693998414; x=1694603214;
 h=to:subject:message-id:date:mime-version:from:x-gm-message-state
 :from:to:cc:subject:date:message-id:reply-to;
 bh=DddI3oEudR9FOCnYH8KXQ3ksPjhgzB4Y4qbOaavheWI=;
 b=OsQhSUKPAItMjuNeCv+BlwFx+ODg3TiiLkyi7X9Vrgnbwq+xh86dWS0nt3YzHgu/yp
 AUb2qEmWAgjhroAsa0uycuyR0Q1PNu7MLOxg8edca64NoNYkrrqy55gqnmbWcw8RCHKx
 SQc1cYEQvJzj4yECiRPCgDRVWgpUY1XfYI+5ZXxwmq0QE6ShDxuE2wLSH99gVffmf86b
 rU6HWmxm2k9BKUPPCrRZnzl+OGA+G33pqeSGzDegxT9ebn5RYTbEImkVARfcwTEIAaBE
 ank7iL1+ZE2pOxH9Ft7rdEbpYUMuolB9xPLg//aYqQ/zjbqNQvk1FwBV52sODyxyeq25
 2Dlw==
X-Gm-Message-State: AOJu0YwJ57zCZgHeikOg5DKq2ybtsLwYLO/ba5tP87Zxx7gmnJFBv0Bx
 HdhcfocHCqk//xB71hnCctBMI6FtXypPOq0G2VYjY4u+bZA=
X-Google-Smtp-Source: AGHT+IGXZxOcmS06Df3N8YdQAMhAi/Mg2U4niGpZLZ+sgkC+tvqtmQfrdpFXkAmTqWLbJI3RlMtOKLtYckXXrhMGQQQ=
X-Received: by 2002:a19:2d15:0:b0:4fb:94c6:fd63 with SMTP id
 k21-20020a192d15000000b004fb94c6fd63mr1826861lfj.17.1693998413696; Wed, 06
 Sep 2023 04:06:53 -0700 (PDT)
Received: from 753933720722 named unknown by gmailapi.google.com with
 HTTPREST; Wed, 6 Sep 2023 04:06:53 -0700
From: Stefan Kangas <stefankangas@HIDDEN>
MIME-Version: 1.0
Date: Wed, 6 Sep 2023 04:06:53 -0700
Message-ID: <CADwFkmmJNAnJZz825pUKAKr3_Qk_u1z09HoLd+V2_FraOvDtzA@HIDDEN>
Subject: control message for bug #62994
To: control <at> debbugs.gnu.org
Content-Type: text/plain; charset="UTF-8"
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: control
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

severity 62994 wishlist
quit




Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#62994: [PATCH v3 0/1] Support styled underlines on tty Emacs frames
Resent-From: Mohsin Kaleem <mohkale@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Sun, 28 Jan 2024 11:31:02 +0000
Resent-Message-ID: <handler.62994.B62994.170644145227487 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 62994
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: 
To: Eli Zaretskii <eliz@HIDDEN>, 62994 <at> debbugs.gnu.org
Received: via spool by 62994-submit <at> debbugs.gnu.org id=B62994.170644145227487
          (code B ref 62994); Sun, 28 Jan 2024 11:31:02 +0000
Received: (at 62994) by debbugs.gnu.org; 28 Jan 2024 11:30:52 +0000
Received: from localhost ([127.0.0.1]:56768 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1rU3ND-00079G-Ns
	for submit <at> debbugs.gnu.org; Sun, 28 Jan 2024 06:30:51 -0500
Received: from 119.ip-51-38-65.eu ([51.38.65.119]:41966 helo=mail.kisara.moe)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <mohkale@HIDDEN>) id 1rU3N8-000793-Cd
 for 62994 <at> debbugs.gnu.org; Sun, 28 Jan 2024 06:30:50 -0500
Received: from kisara.moe (vps788627.ovh.net [51.38.65.119])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange ECDHE (prime256v1) server-signature ECDSA (prime256v1)
 server-digest SHA256) (No client certificate requested)
 by mail.kisara.moe (Postfix) with ESMTPSA id 5DE69A2795;
 Sun, 28 Jan 2024 12:30:37 +0100 (CET)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kisara.moe;
 s=default; t=1706441437;
 bh=ciCL4xeMRD9S61xlMOEt4uWiLmrLgKlhN7+hvHAFU9s=;
 h=From:To:Subject:In-Reply-To:References:Date:From;
 b=eg7D7HAUIxVwTgfAZ5MahlwbuD6B3ncQpq7PbmVr9C64TioA2KwE2W3ANEnoBw3LB
 YyQHEwhD+F2yRtfZEK67iHw9A5o6GXfPoRKeji5+VlCm/8zB1Tj2dxAVfh9+M5ssJ5
 vG7sWjvUPqPQNkvd4ZlsyLV7B8QwfwRiCjE0Uj4V8j5o5IVlIfHYS9aSOIJ8p5DWiW
 XMuMk8csMuZjk1FXf7bfl1EzwewcDYZkfz8WrtNgZVUB3Nf1ofQGoqAyRaNb3hc8n6
 vFDIxY0hRBnAj8ROu3AxWCtDJtlNC3OD+1l9r0mAm/7GMADl91BIKy5nxWRC2kxHCD
 zgrqapl5QkdqA==
From: Mohsin Kaleem <mohkale@HIDDEN>
In-Reply-To: <20230422102146.93003-1-mohkale@HIDDEN>
References: <handler.62994.B.168208734930664.ack <at> debbugs.gnu.org>
 <20230422102146.93003-1-mohkale@HIDDEN>
Date: Sun, 28 Jan 2024 12:30:25 +0100
Message-ID: <86le89itke.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: 0.4 (/)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.6 (/)

mohkale@HIDDEN writes:

Hi there,

My copyright situation should be solved now. I was waiting on something
else from my work but would rather not put this off any longer. I've
figured out how to do the correct resolution for color. Only thing
that's confusing me a little is that in src/xfaces:6466 for
map_tty_color it looks like we change the color in the face spec itself
only on MSDOS frames. What are the ramifications of this? Is this logic
we want to keep going forward? For reference I don't this should be done
for the underline spec because unlike foreground and background it can
be a string or a plist containing the color value and we would not want
to update it in place.

-- 
Mohsin Kaleem




Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#62994: [PATCH v3 0/1] Support styled underlines on tty Emacs frames
Resent-From: Eli Zaretskii <eliz@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Sun, 28 Jan 2024 12:06:02 +0000
Resent-Message-ID: <handler.62994.B62994.170644355531911 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 62994
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: 
To: Mohsin Kaleem <mohkale@HIDDEN>
Cc: 62994 <at> debbugs.gnu.org
Received: via spool by 62994-submit <at> debbugs.gnu.org id=B62994.170644355531911
          (code B ref 62994); Sun, 28 Jan 2024 12:06:02 +0000
Received: (at 62994) by debbugs.gnu.org; 28 Jan 2024 12:05:55 +0000
Received: from localhost ([127.0.0.1]:56778 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1rU3v8-0008Id-TE
	for submit <at> debbugs.gnu.org; Sun, 28 Jan 2024 07:05:55 -0500
Received: from eggs.gnu.org ([2001:470:142:3::10]:49628)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1rU3v5-0008IK-9w
 for 62994 <at> debbugs.gnu.org; Sun, 28 Jan 2024 07:05:53 -0500
Received: from fencepost.gnu.org ([2001:470:142:3::e])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1rU3us-0002zm-2Y; Sun, 28 Jan 2024 07:05:38 -0500
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date:
 mime-version; bh=3PwMjgVb65T3npL1jp4FvcPpqs5yZMTMhB+0sZa5Xlc=; b=qPWF6ST0/0Qm
 UCyfWLzHTb48STM2ek4S5BcRCeaxqGjgEjur1tanNdr2RSWa1Qiw4S3o6Vb05PfvOcPWpnoAPpuyP
 HJlvMUk3JmkerVg96JoDOwR/gl5XFES0vRhs1aZ0UW63xfK3uyotaDRBSErZFo/HEAvb6EjjWyoqv
 u/Lz5U5t3AnhSt2ixWHlyYgkV8t5eDMdi2afKsorNJb3xMBUVEN4D3n27GMP/NUNbMYx4gsAOVXZ6
 8un5bIfcT/2u9vfg8v9xbOzwRRxkDMAJOn0p7dxykzfc+ipvfBsHfZOxk9BrteYS7n6oZz2Zzx0P0
 dxdotO+CPy5UiqfNiZTk+A==;
Date: Sun, 28 Jan 2024 14:05:32 +0200
Message-Id: <86a5op64tv.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
In-Reply-To: <86le89itke.fsf@HIDDEN> (message from Mohsin Kaleem on Sun,
 28 Jan 2024 12:30:25 +0100)
References: <handler.62994.B.168208734930664.ack <at> debbugs.gnu.org>
 <20230422102146.93003-1-mohkale@HIDDEN> <86le89itke.fsf@HIDDEN>
X-Spam-Score: -2.3 (--)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> From: Mohsin Kaleem <mohkale@HIDDEN>
> Date: Sun, 28 Jan 2024 12:30:25 +0100
> 
> mohkale@HIDDEN writes:
> 
> My copyright situation should be solved now. I was waiting on something
> else from my work but would rather not put this off any longer.

That's good to know, thanks.

> I've
> figured out how to do the correct resolution for color. Only thing
> that's confusing me a little is that in src/xfaces:6466 for
> map_tty_color it looks like we change the color in the face spec itself
> only on MSDOS frames. What are the ramifications of this? Is this logic
> we want to keep going forward?

The MSDOS frames are different from other TTY frames in that we can
know the default colors used by the MSDOS terminals.  That's why MSDOS
needs a special code there.  And yes, we want to keep this logic, for
MSDOS only.

> For reference I don't this should be done for the underline spec
> because unlike foreground and background it can be a string or a
> plist containing the color value and we would not want to update it
> in place.

The MSDOS terminal doesn't support underline, so no worries here.




Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#62994: [PATCH v3 0/1] Support styled underlines on tty Emacs frames
Resent-From: Eli Zaretskii <eliz@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Mon, 29 Jan 2024 12:38:02 +0000
Resent-Message-ID: <handler.62994.B62994.170653184229782 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 62994
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: 
To: Mohsin Kaleem <mohkale@HIDDEN>
Cc: 62994 <at> debbugs.gnu.org
Received: via spool by 62994-submit <at> debbugs.gnu.org id=B62994.170653184229782
          (code B ref 62994); Mon, 29 Jan 2024 12:38:02 +0000
Received: (at 62994) by debbugs.gnu.org; 29 Jan 2024 12:37:22 +0000
Received: from localhost ([127.0.0.1]:59232 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1rUQt7-0007kH-TZ
	for submit <at> debbugs.gnu.org; Mon, 29 Jan 2024 07:37:22 -0500
Received: from eggs.gnu.org ([2001:470:142:3::10]:39004)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1rUQt5-0007k4-AY
 for 62994 <at> debbugs.gnu.org; Mon, 29 Jan 2024 07:37:19 -0500
Received: from fencepost.gnu.org ([2001:470:142:3::e])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1rUQsr-0001K7-MK; Mon, 29 Jan 2024 07:37:05 -0500
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date:
 mime-version; bh=MIaNbvVpEYAxacRgHckWL1prBwCeB7PlfcTFoY91MCQ=; b=UyZZz/j6GQ3Z
 /h3We3sPIqnaKu5nBwjn73hiQ1mo7Ygx4Rrvsj51Qs+wERKj8rP/L0Ks5rJbTl00eMbBg25xBmK2e
 ONc4LnhhzWnVRW7kvoTTN6rv0KK3WbHcoC4xMmYBmc+CLTP+pIRrj5zuU94n+nnrR832Wzk7rAlUn
 lCDZRGGhmP6+I12SZ1L9kAu25hLgKxVmrqiHQw4EosnYzdCmdabLmkn7k6wBuhh0o8no3qz68grrj
 ywFrH3q1FKuJ/btzPge3qV4gZnKPyvyVhxBHcIcIcMUc0vLZRSxGYGytkfU3hZke/mbra16zSYgbj
 wlL6vcuusp4B7RboJep9uA==;
Date: Mon, 29 Jan 2024 14:37:03 +0200
Message-Id: <86h6iw48pc.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
In-Reply-To: <86fryg62kh.fsf@HIDDEN> (message from Mohsin Kaleem on Mon,
 29 Jan 2024 08:06:38 +0100)
References: <handler.62994.B.168208734930664.ack <at> debbugs.gnu.org>
 <20230422102146.93003-1-mohkale@HIDDEN> <86le89itke.fsf@HIDDEN>
 <86a5op64tv.fsf@HIDDEN> <86fryg62kh.fsf@HIDDEN>
X-Spam-Score: -2.3 (--)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

[Please use Reply All to reply, to keep the bug tracker CC'ed.]

> From: Mohsin Kaleem <mohkale@HIDDEN>
> Date: Mon, 29 Jan 2024 08:06:38 +0100
> 
> Eli Zaretskii <eliz@HIDDEN> writes:
> 
> > The MSDOS frames are different from other TTY frames in that we can
> > know the default colors used by the MSDOS terminals.  That's why MSDOS
> > needs a special code there.  And yes, we want to keep this logic, for
> > MSDOS only.
> 
> Interesting. Didn't know MSDOS terminals expose that. Neat. Although why
> do we update the face spec (face->lface) itself in this case instead of
> only the foreground/background values which we do later anyways.

AFAIR, it's because those default colors are then used to define the
'default' face and the frame's fore/back-ground pixel values, so we
need the actual colors.

> face->lface seems to be the actual spec set in the theme/customisation
> display (unless I'm misunderstanding). If we change it wouldn't that
> alter what's shown in customize for example.

How can that alter what is shown, when the colors we stick in the face
are the exact colors that the screen uses?  It's like you take a
"blue" color that is specified by the special name "default" and
replace it with an actual "blue" -- how can the result be different.





Last modified: Mon, 29 Jan 2024 12:45:02 UTC

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