From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Gerd =?UTF-8?Q?M=C3=B6llmann?= Newsgroups: gmane.emacs.bugs Subject: bug#75024: [PATCH] Fix check for underlining capability on ttys Date: Sun, 22 Dec 2024 14:13:54 +0100 Message-ID: Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="8430"; mail-complaints-to="usenet@ciao.gmane.io" To: 75024@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Dec 22 14:15:24 2024 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1tPLno-00022s-4j for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 22 Dec 2024 14:15:24 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tPLnY-0001ym-CE; Sun, 22 Dec 2024 08:15:08 -0500 Original-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 ) id 1tPLnT-0001ux-OE for bug-gnu-emacs@gnu.org; Sun, 22 Dec 2024 08:15:04 -0500 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tPLnT-0004HC-Au for bug-gnu-emacs@gnu.org; Sun, 22 Dec 2024 08:15:03 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:Date:From:To:Subject; bh=jHp9XNXeGIdNQE40oPCgQfzeKy4KbwiTw8WEBcXfAs4=; b=FfaGAo+Vjm0pZyU1BVzo8xgfOssRWvmcAG4EDj9GZbmBR60erQteWt1b2LpaEY7YFu/Ss8zQg+VawXg89mYBfuZXRysTmN48OR571CPopYYFDn3vY3baBr0hppB8lO+Xwlaj+4fC1Cp7AcIOGIaScRgXdOKy9aXYyS/4goLnRkhD28LKHgknaeSiCNLT7uVMlKl14RiscMiK0rbLOiasAaLtN56IXWbVpoENnHzo2rsLWufpQsCcl6S/o2z6jD04ESb5wVxgbezBzsTjJ1Xl/V1vG51UaBf121Z/yChJmOQGVwCnSPyBHDccDZ4zoTd3rgRUAZST92b8x774RWbNmA==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tPLnS-0003Te-Ii for bug-gnu-emacs@gnu.org; Sun, 22 Dec 2024 08:15:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Gerd =?UTF-8?Q?M=C3=B6llmann?= Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 22 Dec 2024 13:15:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 75024 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.173487324513268 (code B ref -1); Sun, 22 Dec 2024 13:15:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 22 Dec 2024 13:14:05 +0000 Original-Received: from localhost ([127.0.0.1]:49379 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tPLmW-0003Ru-Tu for submit@debbugs.gnu.org; Sun, 22 Dec 2024 08:14:05 -0500 Original-Received: from lists.gnu.org ([209.51.188.17]:49692) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tPLmU-0003Ra-0m for submit@debbugs.gnu.org; Sun, 22 Dec 2024 08:14:02 -0500 Original-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 ) id 1tPLmT-0001UJ-47 for bug-gnu-emacs@gnu.org; Sun, 22 Dec 2024 08:14:01 -0500 Original-Received: from mail-ed1-x52b.google.com ([2a00:1450:4864:20::52b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tPLmR-0003ud-8M for bug-gnu-emacs@gnu.org; Sun, 22 Dec 2024 08:14:00 -0500 Original-Received: by mail-ed1-x52b.google.com with SMTP id 4fb4d7f45d1cf-5d0f6fa6f8bso5410312a12.0 for ; Sun, 22 Dec 2024 05:13:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1734873237; x=1735478037; darn=gnu.org; h=mime-version:message-id:date:subject:to:from:from:to:cc:subject :date:message-id:reply-to; bh=jHp9XNXeGIdNQE40oPCgQfzeKy4KbwiTw8WEBcXfAs4=; b=lBKIZ8iWFOAmkwolxjX/BR/bgBpBxyV1jjIDuIy9BxLPU2qcUUsI0d4LPy4bfFV4iL XbR9we/GN/5muikZotKMQrbeot5/DuVASyZjxNu+kJqVXyEIMf8H9j2RgbI/qCF0B7WQ mUupDNjFJYxB5orhgM/UkBfdbZ79rYlBkp4UMje31zmLrVcuYucCaebtOsnSphhgaSOU IDgUrzjTQiQ1qFWkdOJDWPxu6hbI2aM6MEjYP5eB60GPmpzRCMrd3OA8EQL+/aHZ+JUx OAusxh3pfQ3Yd4tj6o6OR0KQVZ41VlWwHJFS8S30gflAFlRnx3JlqRL7ge1OyXcSkloo Vchg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734873237; x=1735478037; h=mime-version:message-id:date:subject:to:from:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=jHp9XNXeGIdNQE40oPCgQfzeKy4KbwiTw8WEBcXfAs4=; b=ZpCHnkTRQMWyIuLaxU2p/pNDHbit/YtVStNn+/9+zImjKvdBI1PoarNsVKCkWADcp+ xs7PHqs0jBjZ9iwrKupTAFWY0ekay03WCHYmsuIeFPxNmiUrtjuBQa/h5hYD+ZZRs6X+ vv7wbGODXKcNVWpjPrgjtiuk0iL7YQtHPPYQftypZmmyP7pSXGMGD2qu5kJHhZxNZmRA 19TniLU7GY8X3+NIE9Wi3nPimxG3ceijx1/FQ5DA4ArLvPoJXDzgQx7o1hJxyX4c4nyh s7aftgU4u0eryihcbakrKl9zboCh+Si1+vPNJ/IuIRquNQNTFm9UI1L0dKryv09mCKu6 xHIw== X-Gm-Message-State: AOJu0Yw8DFbSa3MebnuNsylNlRTEOQZLdwVo8xRWreumFKe+52739J5H ATIJ1cUa9hVQH0J7u75NeioQEulUaIvdAy5BRbm08hi8gh8cGEX7S2oecQ== X-Gm-Gg: ASbGncuQi9khaVXsqznvcECelbjfI2Eicnf0R6+w1YqZWhIh3yiolPMGqQEmrktOiOV xBOoCxP6fnIOm1xolR6lDgfTJ5qQq5tyQvdavKEB6360QnikC4c54Hh07fdCFhu83evCQmGbZnp WoXulgHHfvffBQBMWHRg5WbQHlG4C44n0gMBeiemr7JskDIcXFrxRY8A//wsS9Ro7uNJEWNtUrs z4oxwMkyq7HivOQMR9ZbvWOfUz1OUvUqJEcdtjL6vSbenII1JTCrQCvpQlcEX69zDmnU5EUrHEV IniD9CRVRg97rWnLzumkyMo7v+UwycPiEXy4EpQko3/PQU49OXkCUopWkHHdOVa9rA== X-Google-Smtp-Source: AGHT+IGbHHTDFL2E9B2zE3Uu6H2n2pM9bvQkn7oiwsCOkvUV7A/Sco853LGpZ9TWL993MtNM6cR02w== X-Received: by 2002:a05:6402:13c8:b0:5d4:3761:d184 with SMTP id 4fb4d7f45d1cf-5d81dd7f3b0mr8968500a12.10.1734873236892; Sun, 22 Dec 2024 05:13:56 -0800 (PST) Original-Received: from pro2 (p200300e0b71f6700b0196211433a3436.dip0.t-ipconnect.de. [2003:e0:b71f:6700:b019:6211:433a:3436]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5d80701ac68sm3664387a12.78.2024.12.22.05.13.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 22 Dec 2024 05:13:55 -0800 (PST) Received-SPF: pass client-ip=2a00:1450:4864:20::52b; envelope-from=gerd.moellmann@gmail.com; helo=mail-ed1-x52b.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:297600 Archived-At: --=-=-= Content-Type: text/plain 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' --=-=-= Content-Type: text/patch Content-Disposition: attachment; filename=0001-Fix-check-for-underlining-capability-on-ttys.patch >From 419a5fa0fd98f673660b123f5b37c99cd0b8c61b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gerd=20M=C3=B6llmann?= 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 --=-=-=--