commit: 1fd9f819fbb2493c47c2166cd234246c1f8f85a7
Author: Kerin Millar <kfm <AT> plushkava <DOT> net>
AuthorDate: Mon May 13 22:14:05 2024 +0000
Commit: Sam James <sam <AT> gentoo <DOT> 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 <kfm <AT> 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/.