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 4962515810F for ; Sun, 11 Jun 2023 16:47:19 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 73848E0898; Sun, 11 Jun 2023 16:47:18 +0000 (UTC) Received: from smtp.gentoo.org (woodpecker.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 3F38AE0898 for ; Sun, 11 Jun 2023 16:47:18 +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)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 6534A3413DD for ; Sun, 11 Jun 2023 16:47:17 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id CF224A94 for ; Sun, 11 Jun 2023 16:47:14 +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: <1686483373.075761b394201951e2948be8730f8cb8e7fc8122.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: 075761b394201951e2948be8730f8cb8e7fc8122 X-VCS-Branch: master Date: Sun, 11 Jun 2023 16:47:14 +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: 8eae2def-a983-4f0a-a8a0-5cfb316f6b81 X-Archives-Hash: ebbcedd9308aff7e2d39fbb450bc761d commit: 075761b394201951e2948be8730f8cb8e7fc8122 Author: Kerin Millar plushkava net> AuthorDate: Sun Jun 11 11:26:16 2023 +0000 Commit: Sam James gentoo org> CommitDate: Sun Jun 11 11:36:13 2023 +0000 URL: https://gitweb.gentoo.org/proj/gentoo-functions.git/commit/?id=075761b3 Account for the buggy CHA implementation in Emacs 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. Work around it. Note that Eterm does not have this same bug. Signed-off-by: Kerin Millar plushkava.net> functions.sh.in | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/functions.sh.in b/functions.sh.in index 6f1ee75..d2baf5d 100644 --- a/functions.sh.in +++ b/functions.sh.in @@ -335,15 +335,24 @@ _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 ))" + printf '\033[%dG' "$(( genfun_x + indent + 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 ))" + printf '\n\033[%dG' "$(( genfun_cols - 6 + offset ))" fi # Finally, print the indicator.