From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id B7DB81581D3 for ; Tue, 14 May 2024 00:05:24 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 0DA88E2A2D; Tue, 14 May 2024 00:05:23 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id E885AE2A2D for ; Tue, 14 May 2024 00:05:22 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 20CA3335DE9 for ; Tue, 14 May 2024 00:05:22 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 5B8471AAC for ; Tue, 14 May 2024 00:05:20 +0000 (UTC) From: "Sam James" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Sam James" Message-ID: <1715638756.1fd9f819fbb2493c47c2166cd234246c1f8f85a7.sam@gentoo> Subject: [gentoo-commits] proj/gentoo-functions:master commit in: / X-VCS-Repository: proj/gentoo-functions X-VCS-Files: functions.sh.in X-VCS-Directories: / X-VCS-Committer: sam X-VCS-Committer-Name: Sam James X-VCS-Revision: 1fd9f819fbb2493c47c2166cd234246c1f8f85a7 X-VCS-Branch: master Date: Tue, 14 May 2024 00:05:20 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: 05bba51e-2d75-4339-bba8-17f44ce5b1f1 X-Archives-Hash: 61ce6e3beb0c206ad6360b53923f0e67 commit: 1fd9f819fbb2493c47c2166cd234246c1f8f85a7 Author: Kerin Millar plushkava net> AuthorDate: Mon May 13 22:14:05 2024 +0000 Commit: Sam James gentoo org> CommitDate: Mon May 13 22:19:16 2024 +0000 URL: https://gitweb.gentoo.org/proj/gentoo-functions.git/commit/?id=1fd9f819 Don't check for Emacs every time _eend() is called For it is an edge case and it is not clear that it is worth it. Instead, check at the time of sourcing. The underlying bug really ought to be addressed upstream. Signed-off-by: Kerin Millar plushkava.net> functions.sh.in | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/functions.sh.in b/functions.sh.in index 555d1d1..c97219b 100644 --- a/functions.sh.in +++ b/functions.sh.in @@ -336,24 +336,15 @@ _eend() # Calculate the column at which the indicator may be printed. indent=$(( genfun_cols - genfun_x - 6 )) - # In Emacs, M-x term opens an "eterm-color" terminal, whose - # implementation of the CHA (ECMA-48 CSI) sequence suffers from - # an off-by-one error. - if [ "${INSIDE_EMACS}" ] && [ "${TERM}" = "eterm-color" ]; then - offset=-1 - else - offset=0 - fi - # Determine whether the cursor needs to be repositioned. if [ "${indent}" -gt 0 ]; then # Use CHA (ECMA-48 CSI) to move the cursor to the right. - printf '\033[%dG' "$(( genfun_x + indent + offset ))" + printf '\033[%dG' "$(( genfun_x + indent + genfun_offset ))" elif [ "${indent}" -lt 0 ]; then # The indent is negative, meaning that there is not # enough room. Arrange for the indicator to be printed # on the next line instead. - printf '\n\033[%dG' "$(( genfun_cols - 6 + offset ))" + printf '\n\033[%dG' "$(( genfun_cols - 6 + genfun_offset ))" fi # Finally, print the indicator. @@ -697,6 +688,14 @@ genfun_newline=' # Whether the last printed message is pending a concluding LF character. genfun_is_pending_lf=0 +# In Emacs, M-x term opens an "eterm-color" terminal, whose implementation of +# the CHA (ECMA-48 CSI) sequence suffers from an off-by-one error. +if [ "${INSIDE_EMACS}" ] && [ "${TERM}" = "eterm-color" ]; then + genfun_offset=-1 +else + genfun_offset=0 +fi + # Should we use color? if [ -n "${NO_COLOR}" ]; then # See https://no-color.org/.