From: "Benjamín Buccianti" <benjamin@buccianti.dev>
To: emacs-devel@gnu.org
Subject: Eshell output filter
Date: Sun, 20 Sep 2020 16:26:00 -0300 [thread overview]
Message-ID: <87mu1k5jxz.fsf@buccianti.dev> (raw)
[-- Attachment #1: Type: text/plain, Size: 2106 bytes --]
Hello there!
I've encountered a problem with eshell and apk (package manager of Alpine Linux).
When running an update, I see some chars that I think are used to delete the line (behaviour that you can see on any terminal emulator).
For example:
```
~ $ doas apk -U upgrade
fetch http://dl-cdn.alpinelinux.org/alpine/edge/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/edge/community/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/edge/testing/x86_64/APKINDEX.tar.gz
%1b7 0% %1b8OK: 3694 MiB in 819 packages
```
The expected outcome it's to see only this:
```
~ $ doas apk -U upgrade
fetch http://dl-cdn.alpinelinux.org/alpine/edge/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/edge/community/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/edge/testing/x86_64/APKINDEX.tar.gz
OK: 3694 MiB in 819 packages
```
I think we don't see the 0% because it occurs really fast. But in some cases, you can see the progress of the bar changing from 0% to 100%. I think ^[8 it's used to erase the line because in other cases you can see output like this:
```
~ $ doas apk add emacs
(1/2) Installing emacs-nox (27.1-r1)
%1b7 0% %1b8%1b7 97% ########################################### %1b8%1b7 98% ########################################### %1b8%1b7 99% ########################################### %1b8(2/2) Installing emacs (27.1-r1)
%1b7 99% ########################################### %1b8%1b7100% ############################################%1b8Executing busybox-1.32.0-r3.trigger
Executing gtk-update-icon-cache-2.24.32-r2.trigger
OK: 3802 MiB in 821 packages
```
(output reduced for the sake of understanding, but you can see the whole sequence)
So, I figured out that eshell uses a eshell-handle-control-codes to detect control codes.
This is a proposed alternative but I'm not really that well versed on emacs and on terminal control codes so, I post here with the intention of see what you guys think and with the desire of improve with your help.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Eshell handle apk (alpine linux) control codes --]
[-- Type: text/x-patch, Size: 583 bytes --]
diff --git a/lisp/eshell/esh-mode.el b/lisp/eshell/esh-mode.el
index db5fddb2aa..ed5c864eda 100644
--- a/lisp/eshell/esh-mode.el
+++ b/lisp/eshell/esh-mode.el
@@ -999,6 +999,14 @@ eshell-handle-control-codes
(beep))
((eq char ?\C-h)
(delete-region (1- (point)) (1+ (point))))
+ ((and (eq char ?\^[)
+ (memq (char-after (1+ (point)))
+ '(?\8)))
+ (let ((end (1+ (point))))
+ (beginning-of-line)
+ (delete-region (point) end)
+ (delete-char 1))
+ (forward-char))
(t
(forward-char)))))))
[-- Attachment #3: Type: text/plain, Size: 10 bytes --]
Thanks!
next reply other threads:[~2020-09-20 19:26 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-20 19:26 Benjamín Buccianti [this message]
2020-09-20 19:59 ` Eshell output filter Benjamín Buccianti
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
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87mu1k5jxz.fsf@buccianti.dev \
--to=benjamin@buccianti.dev \
--cc=emacs-devel@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 public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).