all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Gerd Möllmann" <gerd.moellmann@gmail.com>
To: 75024@debbugs.gnu.org
Subject: bug#75024: [PATCH] Fix check for underlining capability on ttys
Date: Sun, 22 Dec 2024 14:13:54 +0100	[thread overview]
Message-ID: <m234ifoo6l.fsf@gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 1973 bytes --]

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'


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Fix-check-for-underlining-capability-on-ttys.patch --]
[-- Type: text/patch, Size: 1991 bytes --]

From 419a5fa0fd98f673660b123f5b37c99cd0b8c61b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gerd=20M=C3=B6llmann?= <gerd@gnu.org>
Date: Sun, 22 Dec 2024 14:11:33 +0100
Subject: [PATCH] Fix check for underlining capability on ttys

* src/term.c (tty_capable_p): Check both possible terminal capabilities
for underlining.
---
 src/term.c | 23 ++++++++++++-----------
 1 file changed, 12 insertions(+), 11 deletions(-)

diff --git a/src/term.c b/src/term.c
index f2d1846e488..875d4d2deff 100644
--- a/src/term.c
+++ b/src/term.c
@@ -2113,18 +2113,20 @@ turn_off_face (struct frame *f, struct face *face)
 tty_capable_p (struct tty_display_info *tty, unsigned int caps)
 {
 #ifndef HAVE_ANDROID
-#define TTY_CAPABLE_P_TRY(tty, cap, TS, NC_bit)				\
-  if ((caps & (cap)) && (!(TS) || !MAY_USE_WITH_COLORS_P (tty, NC_bit)))	\
-    return 0;
+# define TTY_CAPABLE_P(tty, cap, TS, NC_bit) \
+   ((caps & (cap)) && (TS) && MAY_USE_WITH_COLORS_P (tty, NC_bit))
+# define TTY_CAPABLE_P_TRY(tty, cap, TS, NC_bit) \
+  if (!TTY_CAPABLE_P (tty, cap, TS, NC_bit)) \
+    return false;
+
+  if (!TTY_CAPABLE_P (tty, TTY_CAP_UNDERLINE, tty->TS_enter_underline_mode,
+		      NC_UNDERLINE)
+      && !TTY_CAPABLE_P (tty, TTY_CAP_UNDERLINE_STYLED,
+			 tty->TF_set_underline_style, NC_UNDERLINE))
+    return false;
 
   TTY_CAPABLE_P_TRY (tty,
 		     TTY_CAP_INVERSE,	  tty->TS_standout_mode, NC_REVERSE);
-  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,
@@ -2135,8 +2137,7 @@ #define TTY_CAPABLE_P_TRY(tty, cap, TS, NC_bit)				\
 		     TTY_CAP_STRIKE_THROUGH, tty->TS_enter_strike_through_mode,
 		     NC_STRIKE_THROUGH);
 
-  /* We can do it!  */
-  return 1;
+  return true;
 #else
   return false;
 #endif
-- 
2.47.1


             reply	other threads:[~2024-12-22 13:13 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-22 13:13 Gerd Möllmann [this message]
2024-12-23  5:52 ` bug#75024: [PATCH] Fix check for underlining capability on ttys Gerd Möllmann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m234ifoo6l.fsf@gmail.com \
    --to=gerd.moellmann@gmail.com \
    --cc=75024@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.