GNU bug report logs - #75024
Fix check for underlining capability on ttys

Previous Next

Package: emacs;

Reported by: Gerd Möllmann <gerd.moellmann <at> gmail.com>

Date: Sun, 22 Dec 2024 13:15:02 UTC

Severity: normal

Fixed in version 31.1

Done: Gerd Möllmann <gerd.moellmann <at> gmail.com>

Bug is archived. No further changes may be made.

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

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

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


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#75024; Package emacs. (Sun, 22 Dec 2024 13:15:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Gerd Möllmann <gerd.moellmann <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Sun, 22 Dec 2024 13:15:02 GMT) Full text and rfc822 format available.

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

From: Gerd Möllmann <gerd.moellmann <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: [PATCH] Fix check for underlining capability on ttys
Date: Sun, 22 Dec 2024 14:13:54 +0100
[Message part 1 (text/plain, inline)]
Tags: patch

With current master

emacs -nw -Q on Terminal.app, $TERM=xterm-256color

1. (display-supports-face-attributes-p '(underline t))
     => nil

2. C-h f context-menu-map RET
   => The separator line in *Help* in underlined, which
   means that term.c thinks that underlines can be used.

display-supports-face-attribute-p uses tty_capable_p in term.c.
This code in tty_capable_p looks wrong:

  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);

It returns false as soon as it finds TS_enter_underline_mode is cannot
be used, and doesn't check TS_set_underline_style. The output code uses
one or the other

  if (face->underline && MAY_USE_WITH_COLORS_P (tty, NC_UNDERLINE))
    {
      if (face->underline == FACE_UNDERLINE_SINGLE
	  || !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);
	}
    }

In GNU Emacs 31.0.50 (build 6, aarch64-apple-darwin24.2.0) of 2024-12-22
 built on pro2
Repository revision: d481da70010eab163d12f770ed11f8fef171406a
Repository branch: cl-packages
System Description:  macOS 15.2

Configured using:
 'configure --without-ns --cache-file
 /var/folders/1d/k_6t25f94sl83szqbf8gpkrh0000gn/T//config.cache.cl-packages
 --with-native-compilation --with-mps=yes CC=clang
 'CFLAGS=-Wgnu-imaginary-constant -Wunused-result -g
 -fno-omit-frame-pointer -F
 /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks
 -Wno-ignored-attributes -Wno-flag-enum -Wno-missing-method-return-type
 -Wno-variadic-macros -Wno-strict-prototypes -Wno-availability
 -Wno-nullability-completeness' --prefix=/Users/gerd/.local'

[0001-Fix-check-for-underlining-capability-on-ttys.patch (text/patch, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#75024; Package emacs. (Mon, 23 Dec 2024 05:54:01 GMT) Full text and rfc822 format available.

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

From: Gerd Möllmann <gerd.moellmann <at> gmail.com>
To: 75024 <at> debbugs.gnu.org
Subject: Re: bug#75024: [PATCH] Fix check for underlining capability on ttys
Date: Mon, 23 Dec 2024 06:52:45 +0100
Gerd Möllmann <gerd.moellmann <at> gmail.com> writes:

> Tags: patch

Please disregard the patch. I'll send another one later.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#75024; Package emacs. (Mon, 23 Dec 2024 07:56:02 GMT) Full text and rfc822 format available.

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

From: Gerd Möllmann <gerd.moellmann <at> gmail.com>
To: 75024 <at> debbugs.gnu.org
Cc: Mohsin Kaleem <mohkale <at> kisara.moe>
Subject: Re: bug#75024: [PATCH] Fix check for underlining capability on ttys
Date: Mon, 23 Dec 2024 08:54:29 +0100
Gerd Möllmann <gerd.moellmann <at> gmail.com> writes:

> Gerd Möllmann <gerd.moellmann <at> gmail.com> writes:
>
>> Tags: patch
>
> Please disregard the patch. I'll send another one later.

I meanwhile found this, to my great surprise:

#define TTY_CAP_UNDERLINE_STYLED	(0x32 & TTY_CAP_UNDERLINE)

That makes TTY_CAP_UNDERLINE_STYLED == TTY_CAP_UNDERLINE. And this test
in tty_capable_p

  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,

fails because it tests TTY_CAP_UNDERLINE twice, and requires both
TS_enter_underline_mode and TF_set_underline_style to be usable for
underline support. In Terminal.app, only TS_enter_underline_mode is
available.

Maybe this should have been 

#define TTY_CAP_UNDERLINE_STYLED	0x40

?

BTW, the 0x32 also also makes no sense to me because of 

#define TTY_CAP_ITALIC  	0x10
#define TTY_CAP_STRIKE_THROUGH	0x20

CC to the original author to check.





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#75024; Package emacs. (Sun, 05 Jan 2025 04:09:01 GMT) Full text and rfc822 format available.

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

From: Gerd Möllmann <gerd.moellmann <at> gmail.com>
To: 75024 <at> debbugs.gnu.org
Cc: Mohsin Kaleem <mohkale <at> kisara.moe>
Subject: Re: bug#75024: [PATCH] Fix check for underlining capability on ttys
Date: Sun, 05 Jan 2025 05:08:07 +0100
Hi Mohsin, friendly ping. Could you find the time to look at this?

Gerd Möllmann <gerd.moellmann <at> gmail.com> writes:

> Gerd Möllmann <gerd.moellmann <at> gmail.com> writes:
>
>> Gerd Möllmann <gerd.moellmann <at> gmail.com> writes:
>>
>>> Tags: patch
>>
>> Please disregard the patch. I'll send another one later.
>
> I meanwhile found this, to my great surprise:
>
> #define TTY_CAP_UNDERLINE_STYLED	(0x32 & TTY_CAP_UNDERLINE)
>
> That makes TTY_CAP_UNDERLINE_STYLED == TTY_CAP_UNDERLINE. And this test
> in tty_capable_p
>
>   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,
>
> fails because it tests TTY_CAP_UNDERLINE twice, and requires both
> TS_enter_underline_mode and TF_set_underline_style to be usable for
> underline support. In Terminal.app, only TS_enter_underline_mode is
> available.
>
> Maybe this should have been 
>
> #define TTY_CAP_UNDERLINE_STYLED	0x40
>
> ?
>
> BTW, the 0x32 also also makes no sense to me because of 
>
> #define TTY_CAP_ITALIC  	0x10
> #define TTY_CAP_STRIKE_THROUGH	0x20
>
> CC to the original author to check.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#75024; Package emacs. (Sun, 05 Jan 2025 11:37:02 GMT) Full text and rfc822 format available.

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

From: Mohsin Kaleem <mohkale <at> kisara.moe>
To: Gerd Möllmann <gerd.moellmann <at> gmail.com>,
 75024 <at> debbugs.gnu.org
Subject: Re: bug#75024: [PATCH] Fix check for underlining capability on ttys
Date: Sun, 05 Jan 2025 11:36:50 +0000
Gerd Möllmann <gerd.moellmann <at> gmail.com> writes:

Hi there,

Sorry for the late response.

>> I meanwhile found this, to my great surprise:
>>
>> #define TTY_CAP_UNDERLINE_STYLED	(0x32 & TTY_CAP_UNDERLINE)
>>
>> That makes TTY_CAP_UNDERLINE_STYLED == TTY_CAP_UNDERLINE. And this test
>> in tty_capable_p
>>
>>   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,
>>
>> fails because it tests TTY_CAP_UNDERLINE twice, and requires both
>> TS_enter_underline_mode and TF_set_underline_style to be usable for
>> underline support. In Terminal.app, only TS_enter_underline_mode is
>> available.
>>
>> Maybe this should have been 
>>
>> #define TTY_CAP_UNDERLINE_STYLED	0x40
>>
>> ?

Ah, yep. The original intention was or a new bit flag with the existing
underline bit flag so that styled underlines were only available in
environments with at least regular underlines. In retrospect that was
probably excessive and simply checking for styled underline support by
itself (with a value of 0x40) is sufficient. I'd find it strange to have
a terminal that supported styled underlines but not regular ones but
there's no need to enforce this on the Emacs side.

>>
>> BTW, the 0x32 also also makes no sense to me because of 
>>
>> #define TTY_CAP_ITALIC  	0x10
>> #define TTY_CAP_STRIKE_THROUGH	0x20
>>
>> CC to the original author to check.

Correct here as well, I should've confirmed the binary representation
:-(.

0b00000000000000000000000000010000 0o00000000020 0d0000000016 0x00000010
0b00000000000000000000000000100000 0o00000000040 0d0000000032 0x00000020
0b00000000000000000000000000110010 0o00000000062 0d0000000050 0x00000032
0b00000000000000000000000001000000 0o00000000100 0d0000000064 0x00000040

0x40 is what the next entry in the flag should have been.

-- 
Mohsin Kaleem




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#75024; Package emacs. (Sun, 05 Jan 2025 11:50:02 GMT) Full text and rfc822 format available.

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

From: Gerd Möllmann <gerd.moellmann <at> gmail.com>
To: Mohsin Kaleem <mohkale <at> kisara.moe>
Cc: 75024 <at> debbugs.gnu.org
Subject: Re: bug#75024: [PATCH] Fix check for underlining capability on ttys
Date: Sun, 05 Jan 2025 12:48:54 +0100
Mohsin Kaleem <mohkale <at> kisara.moe> writes:

> Gerd Möllmann <gerd.moellmann <at> gmail.com> writes:
>
> Hi there,
>
> Sorry for the late response.
>
>>> I meanwhile found this, to my great surprise:
>>>
>>> #define TTY_CAP_UNDERLINE_STYLED	(0x32 & TTY_CAP_UNDERLINE)
>>>
>>> That makes TTY_CAP_UNDERLINE_STYLED == TTY_CAP_UNDERLINE. And this test
>>> in tty_capable_p
>>>
>>>   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,
>>>
>>> fails because it tests TTY_CAP_UNDERLINE twice, and requires both
>>> TS_enter_underline_mode and TF_set_underline_style to be usable for
>>> underline support. In Terminal.app, only TS_enter_underline_mode is
>>> available.
>>>
>>> Maybe this should have been 
>>>
>>> #define TTY_CAP_UNDERLINE_STYLED	0x40
>>>
>>> ?
>
> Ah, yep. The original intention was or a new bit flag with the existing
> underline bit flag so that styled underlines were only available in
> environments with at least regular underlines. In retrospect that was
> probably excessive and simply checking for styled underline support by
> itself (with a value of 0x40) is sufficient. I'd find it strange to have
> a terminal that supported styled underlines but not regular ones but
> there's no need to enforce this on the Emacs side.
>
>>>
>>> BTW, the 0x32 also also makes no sense to me because of 
>>>
>>> #define TTY_CAP_ITALIC  	0x10
>>> #define TTY_CAP_STRIKE_THROUGH	0x20
>>>
>>> CC to the original author to check.
>
> Correct here as well, I should've confirmed the binary representation
> :-(.
>
> 0b00000000000000000000000000010000 0o00000000020 0d0000000016 0x00000010
> 0b00000000000000000000000000100000 0o00000000040 0d0000000032 0x00000020
> 0b00000000000000000000000000110010 0o00000000062 0d0000000050 0x00000032
> 0b00000000000000000000000001000000 0o00000000100 0d0000000064 0x00000040
>
> 0x40 is what the next entry in the flag should have been.

Thanks for checking, Mohsin!

Would you perhaps have the time to prepare a patch that fixes this?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#75024; Package emacs. (Sun, 05 Jan 2025 11:54:01 GMT) Full text and rfc822 format available.

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

From: Mohsin Kaleem <mohkale <at> kisara.moe>
To: Gerd Möllmann <gerd.moellmann <at> gmail.com>
Cc: 75024 <at> debbugs.gnu.org
Subject: Re: bug#75024: [PATCH] Fix check for underlining capability on ttys
Date: Sun, 05 Jan 2025 11:53:08 +0000
Gerd Möllmann <gerd.moellmann <at> gmail.com> writes:

> Would you perhaps have the time to prepare a patch that fixes this?

I'm a bit swamped atm but could try prepping something in the next few
weeks. Hopefully shouldn't be too big of a change :-).

-- 
Mohsin Kaleem




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#75024; Package emacs. (Sun, 05 Jan 2025 11:56:01 GMT) Full text and rfc822 format available.

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

From: Gerd Möllmann <gerd.moellmann <at> gmail.com>
To: Mohsin Kaleem <mohkale <at> kisara.moe>
Cc: 75024 <at> debbugs.gnu.org
Subject: Re: bug#75024: [PATCH] Fix check for underlining capability on ttys
Date: Sun, 05 Jan 2025 12:54:56 +0100
Mohsin Kaleem <mohkale <at> kisara.moe> writes:

> Gerd Möllmann <gerd.moellmann <at> gmail.com> writes:
>
>> Would you perhaps have the time to prepare a patch that fixes this?
>
> I'm a bit swamped atm but could try prepping something in the next few
> weeks. Hopefully shouldn't be too big of a change :-).

Thanks!




Removed tag(s) patch. Request was from Stefan Kangas <stefankangas <at> gmail.com> to control <at> debbugs.gnu.org. (Thu, 13 Feb 2025 09:59:01 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#75024; Package emacs. (Sun, 23 Feb 2025 00:24:01 GMT) Full text and rfc822 format available.

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

From: Stefan Kangas <stefankangas <at> gmail.com>
To: Mohsin Kaleem <mohkale <at> kisara.moe>
Cc: Gerd Möllmann <gerd.moellmann <at> gmail.com>,
 75024 <at> debbugs.gnu.org
Subject: Re: bug#75024: [PATCH] Fix check for underlining capability on ttys
Date: Sun, 23 Feb 2025 00:22:55 +0000
Mohsin Kaleem <mohkale <at> kisara.moe> writes:

> Gerd Möllmann <gerd.moellmann <at> gmail.com> writes:
>
>> Would you perhaps have the time to prepare a patch that fixes this?
>
> I'm a bit swamped atm but could try prepping something in the next few
> weeks. Hopefully shouldn't be too big of a change :-).

Did you make any progress here?




Changed bug title to 'Fix check for underlining capability on ttys' from '[PATCH] Fix check for underlining capability on ttys' Request was from Stefan Kangas <stefankangas <at> gmail.com> to control <at> debbugs.gnu.org. (Tue, 04 Mar 2025 01:48:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#75024; Package emacs. (Fri, 07 Mar 2025 08:45:01 GMT) Full text and rfc822 format available.

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

From: Gerd Möllmann <gerd.moellmann <at> gmail.com>
To: Stefan Kangas <stefankangas <at> gmail.com>
Cc: Mohsin Kaleem <mohkale <at> kisara.moe>, 75024 <at> debbugs.gnu.org
Subject: Re: bug#75024: Fix check for underlining capability on ttys
Date: Fri, 07 Mar 2025 09:44:00 +0100
[Message part 1 (text/plain, inline)]
Stefan Kangas <stefankangas <at> gmail.com> writes:

> Mohsin Kaleem <mohkale <at> kisara.moe> writes:
>
>> Gerd Möllmann <gerd.moellmann <at> gmail.com> writes:
>>
>>> Would you perhaps have the time to prepare a patch that fixes this?
>>
>> I'm a bit swamped atm but could try prepping something in the next few
>> weeks. Hopefully shouldn't be too big of a change :-).
>
> Did you make any progress here?

AFAICT, the attached patch fixes this.

[0001-Fix-tty-underline-capability-check-bug-75024.patch (text/x-patch, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#75024; Package emacs. (Fri, 07 Mar 2025 19:19:02 GMT) Full text and rfc822 format available.

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

From: Stefan Kangas <stefankangas <at> gmail.com>
To: Gerd Möllmann <gerd.moellmann <at> gmail.com>
Cc: Mohsin Kaleem <mohkale <at> kisara.moe>, 75024 <at> debbugs.gnu.org
Subject: Re: bug#75024: Fix check for underlining capability on ttys
Date: Fri, 7 Mar 2025 11:18:11 -0800
Gerd Möllmann <gerd.moellmann <at> gmail.com> writes:

> Stefan Kangas <stefankangas <at> gmail.com> writes:
>
>> Mohsin Kaleem <mohkale <at> kisara.moe> writes:
>>
>>> Gerd Möllmann <gerd.moellmann <at> gmail.com> writes:
>>>
>>>> Would you perhaps have the time to prepare a patch that fixes this?
>>>
>>> I'm a bit swamped atm but could try prepping something in the next few
>>> weeks. Hopefully shouldn't be too big of a change :-).
>>
>> Did you make any progress here?
>
> AFAICT, the attached patch fixes this.

Thanks, I don't know this code so just a small question below.

> From cfc43e88a98be7a1923d5fd182059f70314027f5 Mon Sep 17 00:00:00 2001
> From: =?UTF-8?q?Gerd=20M=C3=B6llmann?= <gerd.moellmann <at> gmail.com>
> Date: Fri, 7 Mar 2025 09:35:20 +0100
> Subject: [PATCH] Fix tty underline capability check (bug#75024)
>
> * src/dispextern.h (TTY_CAP_UNDERLINE_STYLED): Fix. Also make this an
> enum.
> ---
>  src/dispextern.h | 17 ++++++++++-------
>  1 file changed, 10 insertions(+), 7 deletions(-)
>
> diff --git a/src/dispextern.h b/src/dispextern.h
> index 833106d2570..816ab9def93 100644
> --- a/src/dispextern.h
> +++ b/src/dispextern.h
> @@ -3495,13 +3495,16 @@ #define DEFAULT_TOOL_BAR_IMAGE_HEIGHT 24
>     capabilities being queried for when calling `tty_capable_p' (which
>     returns true if the terminal supports all of them).  */
>
> -#define TTY_CAP_INVERSE		0x01
> -#define TTY_CAP_UNDERLINE	0x02
> -#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)
> +enum
> +{
> +  TTY_CAP_INVERSE = 1 << 1,
> +  TTY_CAP_UNDERLINE = 1 << 2,
> +  TTY_CAP_BOLD = 1 << 3,
> +  TTY_CAP_DIM = 1 << 4,
> +  TTY_CAP_ITALIC = 1 << 5,
> +  TTY_CAP_STRIKE_THROUGH = 1 << 6,
> +  TTY_CAP_UNDERLINE_STYLED = 1 << 7
> +};

So the values where just wrong before?  IOW, TTY_CAP_INVERSE should be 2
instead of 1, and so on?  Perhaps this should be mentioned in the commit
message.

I guess I'm a little bit surprised since most of these values have been
there, AFAICT, since 2002.

>
>  
>  /***********************************************************************
> --
> 2.48.1




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#75024; Package emacs. (Fri, 07 Mar 2025 19:28:01 GMT) Full text and rfc822 format available.

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

From: Gerd Möllmann <gerd.moellmann <at> gmail.com>
To: Stefan Kangas <stefankangas <at> gmail.com>
Cc: Mohsin Kaleem <mohkale <at> kisara.moe>, 75024 <at> debbugs.gnu.org
Subject: Re: bug#75024: Fix check for underlining capability on ttys
Date: Fri, 07 Mar 2025 20:27:29 +0100
Stefan Kangas <stefankangas <at> gmail.com> writes:

>> -#define TTY_CAP_UNDERLINE_STYLED	(0x32 & TTY_CAP_UNDERLINE)
>> +enum
>> +{
>> +  TTY_CAP_INVERSE = 1 << 1,
>> +  TTY_CAP_UNDERLINE = 1 << 2,
>> +  TTY_CAP_BOLD = 1 << 3,
>> +  TTY_CAP_DIM = 1 << 4,
>> +  TTY_CAP_ITALIC = 1 << 5,
>> +  TTY_CAP_STRIKE_THROUGH = 1 << 6,
>> +  TTY_CAP_UNDERLINE_STYLED = 1 << 7
>> +};
>
> So the values where just wrong before?  IOW, TTY_CAP_INVERSE should be 2
> instead of 1, and so on?  Perhaps this should be mentioned in the commit
> message.
>
> I guess I'm a little bit surprised since most of these values have been
> there, AFAICT, since 2002.

The error was in the definition of TTY_CAP_UNDERLINE_STYLED, the rest are
just bit positions in a bit mask and their values don't matter as long
as they are different.

By defining TTY_CAP_UNDERLINE_STYLED the way it was, it was == to
TM_CAP_UNDERLINE and things went wrong. Took me some time to find back
then because I couldn't imagine an error there.

Making it an enum is for the sake of LLDB which can't handle macros.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#75024; Package emacs. (Fri, 07 Mar 2025 19:31:02 GMT) Full text and rfc822 format available.

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

From: Stefan Kangas <stefankangas <at> gmail.com>
To: Gerd Möllmann <gerd.moellmann <at> gmail.com>
Cc: Mohsin Kaleem <mohkale <at> kisara.moe>, 75024 <at> debbugs.gnu.org
Subject: Re: bug#75024: Fix check for underlining capability on ttys
Date: Fri, 7 Mar 2025 11:30:49 -0800
Gerd Möllmann <gerd.moellmann <at> gmail.com> writes:

> Stefan Kangas <stefankangas <at> gmail.com> writes:
>
>>> -#define TTY_CAP_UNDERLINE_STYLED	(0x32 & TTY_CAP_UNDERLINE)
>>> +enum
>>> +{
>>> +  TTY_CAP_INVERSE = 1 << 1,
>>> +  TTY_CAP_UNDERLINE = 1 << 2,
>>> +  TTY_CAP_BOLD = 1 << 3,
>>> +  TTY_CAP_DIM = 1 << 4,
>>> +  TTY_CAP_ITALIC = 1 << 5,
>>> +  TTY_CAP_STRIKE_THROUGH = 1 << 6,
>>> +  TTY_CAP_UNDERLINE_STYLED = 1 << 7
>>> +};
>>
>> So the values where just wrong before?  IOW, TTY_CAP_INVERSE should be 2
>> instead of 1, and so on?  Perhaps this should be mentioned in the commit
>> message.
>>
>> I guess I'm a little bit surprised since most of these values have been
>> there, AFAICT, since 2002.
>
> The error was in the definition of TTY_CAP_UNDERLINE_STYLED, the rest are
> just bit positions in a bit mask and their values don't matter as long
> as they are different.
>
> By defining TTY_CAP_UNDERLINE_STYLED the way it was, it was == to
> TM_CAP_UNDERLINE and things went wrong. Took me some time to find back
> then because I couldn't imagine an error there.

Ah, so these are values that we define ourselves.  That explains it.

Then I have nothing relevant to add.  If you think it's good then please
install.

> Making it an enum is for the sake of LLDB which can't handle macros.

They make things nicer with GDB too, IME.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#75024; Package emacs. (Fri, 07 Mar 2025 20:34:02 GMT) Full text and rfc822 format available.

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

From: Gerd Möllmann <gerd.moellmann <at> gmail.com>
To: Stefan Kangas <stefankangas <at> gmail.com>
Cc: Mohsin Kaleem <mohkale <at> kisara.moe>, 75024 <at> debbugs.gnu.org
Subject: Re: bug#75024: Fix check for underlining capability on ttys
Date: Fri, 07 Mar 2025 21:33:03 +0100
Stefan Kangas <stefankangas <at> gmail.com> writes:

> Gerd Möllmann <gerd.moellmann <at> gmail.com> writes:
>
>> Stefan Kangas <stefankangas <at> gmail.com> writes:
>>
>>>> -#define TTY_CAP_UNDERLINE_STYLED	(0x32 & TTY_CAP_UNDERLINE)
>>>> +enum
>>>> +{
>>>> +  TTY_CAP_INVERSE = 1 << 1,
>>>> +  TTY_CAP_UNDERLINE = 1 << 2,
>>>> +  TTY_CAP_BOLD = 1 << 3,
>>>> +  TTY_CAP_DIM = 1 << 4,
>>>> +  TTY_CAP_ITALIC = 1 << 5,
>>>> +  TTY_CAP_STRIKE_THROUGH = 1 << 6,
>>>> +  TTY_CAP_UNDERLINE_STYLED = 1 << 7
>>>> +};
>>>
>>> So the values where just wrong before?  IOW, TTY_CAP_INVERSE should be 2
>>> instead of 1, and so on?  Perhaps this should be mentioned in the commit
>>> message.
>>>
>>> I guess I'm a little bit surprised since most of these values have been
>>> there, AFAICT, since 2002.
>>
>> The error was in the definition of TTY_CAP_UNDERLINE_STYLED, the rest are
>> just bit positions in a bit mask and their values don't matter as long
>> as they are different.
>>
>> By defining TTY_CAP_UNDERLINE_STYLED the way it was, it was == to
>> TM_CAP_UNDERLINE and things went wrong. Took me some time to find back
>> then because I couldn't imagine an error there.
>
> Ah, so these are values that we define ourselves.  That explains it.
>
> Then I have nothing relevant to add.  If you think it's good then please
> install.

Thanks, pushed to master, and closing




bug marked as fixed in version 31.1, send any further explanations to 75024 <at> debbugs.gnu.org and Gerd Möllmann <gerd.moellmann <at> gmail.com> Request was from Gerd Möllmann <gerd.moellmann <at> gmail.com> to control <at> debbugs.gnu.org. (Fri, 07 Mar 2025 20:34:03 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#75024; Package emacs. (Sat, 08 Mar 2025 08:22:01 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Stefan Kangas <stefankangas <at> gmail.com>
Cc: gerd.moellmann <at> gmail.com, mohkale <at> kisara.moe, 75024 <at> debbugs.gnu.org
Subject: Re: bug#75024: Fix check for underlining capability on ttys
Date: Sat, 08 Mar 2025 10:21:44 +0200
> Cc: Mohsin Kaleem <mohkale <at> kisara.moe>, 75024 <at> debbugs.gnu.org
> From: Stefan Kangas <stefankangas <at> gmail.com>
> Date: Fri, 7 Mar 2025 11:30:49 -0800
> 
> > Making it an enum is for the sake of LLDB which can't handle macros.
> 
> They make things nicer with GDB too, IME.

I've made a habit of compiling with "-gdwarf-4 -g3", which makes GDB
aware of all the macros.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sat, 05 Apr 2025 11:24:09 GMT) Full text and rfc822 format available.

This bug report was last modified 96 days ago.

Previous Next


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