From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: =?utf-8?Q?Benjam=C3=ADn_Buccianti?= Newsgroups: gmane.emacs.devel Subject: Eshell output filter Date: Sun, 20 Sep 2020 16:26:00 -0300 Message-ID: <87mu1k5jxz.fsf@buccianti.dev> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="22458"; mail-complaints-to="usenet@ciao.gmane.io" To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sun Sep 20 21:52:40 2020 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kK5O4-0005kz-FF for ged-emacs-devel@m.gmane-mx.org; Sun, 20 Sep 2020 21:52:40 +0200 Original-Received: from localhost ([::1]:57026 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kK5O3-0002wk-Ed for ged-emacs-devel@m.gmane-mx.org; Sun, 20 Sep 2020 15:52:39 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:37210) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kK4yO-0002UV-Tn for emacs-devel@gnu.org; Sun, 20 Sep 2020 15:26:08 -0400 Original-Received: from mail.buccianti.dev ([69.164.203.126]:50908) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kK4yM-0004jh-Sd for emacs-devel@gnu.org; Sun, 20 Sep 2020 15:26:08 -0400 Original-Received: from ryzen.buccianti.dev (unknown [186.137.219.172]) by mail.buccianti.dev (Postfix) with ESMTPSA id EDED82F9F for ; Sun, 20 Sep 2020 19:26:25 +0000 (UTC) Received-SPF: pass client-ip=69.164.203.126; envelope-from=benjamin@buccianti.dev; helo=mail.buccianti.dev X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/20 15:26:05 X-ACL-Warn: Detected OS = Linux 3.11 and newer [fuzzy] X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Sun, 20 Sep 2020 15:51:18 -0400 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:256267 Archived-At: --=-=-= Content-Type: text/plain 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. --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=eshell-apk-control-codes.patch Content-Transfer-Encoding: 8bit Content-Description: Eshell handle apk (alpine linux) control codes 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))))))) --=-=-= Content-Type: text/plain Thanks! --=-=-=--