unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Eshell output filter
@ 2020-09-20 19:26 Benjamín Buccianti
  2020-09-20 19:59 ` Benjamín Buccianti
  0 siblings, 1 reply; 2+ messages in thread
From: Benjamín Buccianti @ 2020-09-20 19:26 UTC (permalink / raw)
  To: emacs-devel

[-- 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!


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: Eshell output filter
  2020-09-20 19:26 Eshell output filter Benjamín Buccianti
@ 2020-09-20 19:59 ` Benjamín Buccianti
  0 siblings, 0 replies; 2+ messages in thread
From: Benjamín Buccianti @ 2020-09-20 19:59 UTC (permalink / raw)
  To: emacs-devel

Benjamín Buccianti <benjamin@buccianti.dev> writes:

> ```
> ~ $ 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
> ```

Those %1b are ?\^[ chars!

I've selected the wrong option before sending the message (url-encode).



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-09-20 19:59 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-20 19:26 Eshell output filter Benjamín Buccianti
2020-09-20 19:59 ` Benjamín Buccianti

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).