From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: miha--- via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#53485: 29.0.50; [PATCH] Implement alternative sub-buffer support in term.el Date: Mon, 24 Jan 2022 19:21:02 +0100 Message-ID: <8735ld2dwx.fsf@miha-pc> References: <87pmoicgmg.fsf@miha-pc> <874k5t2zva.fsf@gnus.org> Reply-To: Mime-Version: 1.0 Content-Type: multipart/signed; boundary="==-=-="; micalg=pgp-sha256; protocol="application/pgp-signature" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="38587"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 53485@debbugs.gnu.org To: Lars Ingebrigtsen Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Jan 24 20:18:26 2022 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1nC4rB-0009mq-0l for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 24 Jan 2022 20:18:25 +0100 Original-Received: from localhost ([::1]:39034 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nC4r7-0004la-UO for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 24 Jan 2022 14:18:21 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:40570) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nC3rr-0007d3-75 for bug-gnu-emacs@gnu.org; Mon, 24 Jan 2022 13:15:03 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:52858) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nC3rq-0008Hh-SF for bug-gnu-emacs@gnu.org; Mon, 24 Jan 2022 13:15:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1nC3rq-0001Pm-Iw for bug-gnu-emacs@gnu.org; Mon, 24 Jan 2022 13:15:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 24 Jan 2022 18:15:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 53485 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 53485-submit@debbugs.gnu.org id=B53485.16430480795374 (code B ref 53485); Mon, 24 Jan 2022 18:15:02 +0000 Original-Received: (at 53485) by debbugs.gnu.org; 24 Jan 2022 18:14:39 +0000 Original-Received: from localhost ([127.0.0.1]:45761 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nC3rT-0001Oc-3a for submit@debbugs.gnu.org; Mon, 24 Jan 2022 13:14:39 -0500 Original-Received: from kamnitnik.top ([209.250.245.214]:42676) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nC3rR-0001OT-1u for 53485@debbugs.gnu.org; Mon, 24 Jan 2022 13:14:37 -0500 Original-Received: from localhost (BSN-77-156-43.static.siol.net [193.77.156.43]) by kamnitnik.top (Postfix) with ESMTPSA id D30A69C711; Mon, 24 Jan 2022 18:14:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kamnitnik.top; s=mail; t=1643048076; bh=P71SUZRAkSn89cxk+S490ULqQDyH0ASAzZFG6KCulAM=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=ubOGRkZpkzprP1+OjTHoZLMaxoZH6oXHqnbpaDfStd6Wsilr29chOjgBTQMPNQ7F2 Rmmz/T79/8ihswFueiZCoCatrklVDReS3rSydqWhZ5bxc0kgiINhvHZKrnzFb1N1YT RxgtDwYOmuNxbj+WMFElmado3R/ELj7PnjXSywzT5mcqlgekyyY6ISNLnpLOw+fgUz BziGOIgXlH9xIhPSnwtj1u2GZx6PBUtfpJ547AbqP1XURNU3NRfnrlWOIT929u/gYl BALBtIMzu9RfjrckpsYEl11+cdJgbyGUl78VtlNpuZP82AszhUxp8ES8VTpak74ik8 rEw5/lnSm27WQ== In-Reply-To: <874k5t2zva.fsf@gnus.org> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:225102 Archived-At: --==-=-= Content-Type: multipart/mixed; boundary="=-=-=" --=-=-= Content-Type: text/plain Lars Ingebrigtsen writes: > miha@kamnitnik.top writes: > >> Proposed behaviour (patch attached): avoid overwriting output from the >> 'seq' command and erase htop's contents after exiting. This is the >> default behaviour of xterm, st and most other terminal emulators. > > I think that makes sense, but I think it would be good to add a user > option to get the old behaviour back. (Some people prefer to be able to > see the last htop (etc) display after quitting the application.) Thanks, good idea, sending revised patch. --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-Implement-alternative-sub-buffer-support-in-term.el.patch Content-Transfer-Encoding: quoted-printable From=20884c26d84c8cc615916f7f9270b16ac615868b83 Mon Sep 17 00:00:00 2001 From: =3D?UTF-8?q?Miha=3D20Rihtar=3DC5=3DA1i=3DC4=3D8D?=3D Date: Sun, 23 Jan 2022 21:13:24 +0100 Subject: [PATCH] Implement alternative sub-buffer support in term.el * etc/e/eterm-color.ti: Added termcaps for entering and leaving an alternative sub-buffer. * lisp/term.el (term-reset-size): Resize correctly in an alternative sub-buffer is in use. (term-clear-full-screen-programs): New user option. (term-handle-ansi-escape): (term-termcap-format): Handle termcaps for entering and leaving an alternative sub-buffer. (term-switch-to-alternate-sub-buffer): New (used to be commented out) function to enter or leave an alternative sub-buffer. =2D-- etc/e/eterm-color | Bin 1296 -> 1318 bytes etc/e/eterm-color.ti | 5 ++- etc/e/eterm-direct | Bin 1375 -> 1397 bytes lisp/term.el | 92 +++++++++++++++++++++++++++---------------- 4 files changed, 60 insertions(+), 37 deletions(-) diff --git a/etc/e/eterm-color b/etc/e/eterm-color index bf44fa0f36de0f6681fa3172db13a83c414aa42a..fadac25ffcb55b3b3f6812e9c80= f848e94f3dcc3 100644 GIT binary patch delta 283 zcmbQhwTz2fiqV}xl7XKglkwCn)5<@zW&S5BIC4glF4H;!5mNKjYa@GU!W`-RMd!Y&rGEAPxsAO}L z;T*$th6g~wmkgg6egkP1MwodJnit9!0Mf#YVvG_{zBJ?Hi;PxGvLNc@WC2EYCM8Co zk$PO}j7DH3=3D8Qn=3DrNkVd>XA)#1!?kP_Gavw9LOBSY+{}@QmR-kp2Nx0yCMB5yD~t((H^}j66_2KjY+wj8;s7AnGvCEM6ut#>opA^|+)N r)xb)$87Dh3N{N|3)x*pK(Uu@hUd;B4b(5o+qbBcWR^I%C*@+PVcS)1K diff --git a/etc/e/eterm-color.ti b/etc/e/eterm-color.ti index eeb9b0b6e6..84b27aef5d 100644 =2D-- a/etc/e/eterm-color.ti +++ b/etc/e/eterm-color.ti @@ -16,6 +16,7 @@ eterm-color|Emacs term.el terminal emulator term-protocol= -version 0.96, am, mir, msgr, + nrrmc, xenl, bel=3D^G, blink=3D\E[5m, @@ -77,8 +78,8 @@ eterm-color|Emacs term.el terminal emulator term-protocol= -version 0.96, smso=3D\E[7m, u6=3D\E[%i%d;%dR, u7=3D\E[6n, =2D# smcup=3D\E[?47h, =2D# rmcup=3D\E[?47l, + smcup=3D\E[47h, + rmcup=3D\E[47l, # rs2 may need to be added =20 eterm-direct|Emacs term.el with direct-color indexing term-protocol-versio= n 0.96, diff --git a/etc/e/eterm-direct b/etc/e/eterm-direct index c113c3713693b948ae9d52e75df5d89957fd0c77..f4c16621eb185d7d0de14b56fb2= e2b73a57adab8 100644 GIT binary patch delta 259 zcmcc5^_7cTjwz5ql7XKglkww3?nF)o7?_w{>JrZI|9>n)5<@zW&S5BIC4gjv8)YPxGOPl!*8}lph8+xhq4EbACLd%}vOdai zj^R4P1EAnbhEEK?fiw#v%s2?m3*`#{X<gMrG@r42Kv_Gh6`*-DP;j z@E%D2fJ(zmWMqV}Sb#J;BNrnNl+Qm|ky&{11x5`I)2BRfZu?4d| term-home-marker home-marker) + (let ((inhibit-read-only t)) + (delete-region home-marker term-home-marker))))))) =20 ;; Recursive routine used to check if any string in term-kill-echo-list ;; matches part of the buffer before point. @@ -1611,6 +1631,7 @@ term-termcap-format "%s%s:li#%d:co#%d:cl=3D\\E[H\\E[J:cd=3D\\E[J:bs:am:xn:cm=3D\\E[%%i%%d;%%= dH\ :nd=3D\\E[C:up=3D\\E[A:ce=3D\\E[K:ho=3D\\E[H:pt\ :al=3D\\E[L:dl=3D\\E[M:DL=3D\\E[%%dM:AL=3D\\E[%%dL:cs=3D\\E[%%i%%d;%%dr:sf= =3D^J\ +:NR:te=3D\\E[47l:ti=3D\\E[47h\ :dc=3D\\E[P:DC=3D\\E[%%dP:IC=3D\\E[%%d@:im=3D\\E[4h:ei=3D\\E[4l:mi:\ :mb=3D\\E[5m:mh=3D\\E[2m:ZR=3D\\E[23m:ZH=3D\\E[3m\ :so=3D\\E[7m:se=3D\\E[m:us=3D\\E[4m:ue=3D\\E[m:md=3D\\E[1m:mr=3D\\E[7m:me= =3D\\E[m\ @@ -3539,16 +3560,14 @@ term-handle-ansi-escape ((eq char ?h) (cond ((eq (car params) 4) ;; (terminfo: smir) (setq term-insert-mode t)) =2D ;; ((eq (car params) 47) ;; (terminfo: smcup) =2D ;; (term-switch-to-alternate-sub-buffer t)) =2D )) + ((eq (car params) 47) ;; (terminfo: smcup) + (term-switch-to-alternate-sub-buffer t)))) ;; \E[?l - DEC Private Mode Reset ((eq char ?l) (cond ((eq (car params) 4) ;; (terminfo: rmir) (setq term-insert-mode nil)) =2D ;; ((eq (car params) 47) ;; (terminfo: rmcup) =2D ;; (term-switch-to-alternate-sub-buffer nil)) =2D )) + ((eq (car params) 47) ;; (terminfo: rmcup) + (term-switch-to-alternate-sub-buffer nil)))) =20 ;; Modified to allow ansi coloring -mm ;; \E[m - Set/reset modes, set bg/fg @@ -3595,32 +3614,35 @@ term-set-scroll-region (term-move-columns (- (term-current-column))) (term-goto 0 0)) =20 =2D;; (defun term-switch-to-alternate-sub-buffer (set) =2D;; ;; If asked to switch to (from) the alternate sub-buffer, and alrea= dy (not) =2D;; ;; using it, do nothing. This test is needed for some programs (in= cluding =2D;; ;; Emacs) that emit the ti termcap string twice, for unknown reason. =2D;; (term-handle-deferred-scroll) =2D;; (if (eq set (not (term-using-alternate-sub-buffer))) =2D;; (let ((row (term-current-row)) =2D;; (col (term-horizontal-column))) =2D;; (cond (set =2D;; (goto-char (point-max)) =2D;; (if (not (eq (preceding-char) ?\n)) =2D;; (term-insert-char ?\n 1)) =2D;; (setq term-scroll-with-delete t) =2D;; (setq term-saved-home-marker (copy-marker term-home-marker)) =2D;; (set-marker term-home-marker (point))) =2D;; (t =2D;; (setq term-scroll-with-delete =2D;; (not (and (=3D term-scroll-start 0) =2D;; (=3D term-scroll-end term-height)))) =2D;; (set-marker term-home-marker term-saved-home-marker) =2D;; (set-marker term-saved-home-marker nil) =2D;; (setq term-saved-home-marker nil) =2D;; (goto-char term-home-marker))) =2D;; (setq term-current-column nil) =2D;; (setq term-current-row 0) =2D;; (term-goto row col)))) +(defun term-switch-to-alternate-sub-buffer (set) + ;; If asked to switch to (from) the alternate sub-buffer, and already (n= ot) + ;; using it, do nothing. This test is needed for some programs (includi= ng + ;; Emacs) that emit the ti termcap string twice, for unknown reason. + (term-handle-deferred-scroll) + (when (eq set (not (term-using-alternate-sub-buffer))) + (cond + (set + (goto-char (point-max)) + (if (not (eq (preceding-char) ?\n)) + (term-insert-char ?\n 1)) + (setq term-scroll-with-delete t) + (setq term-saved-home-marker (copy-marker term-home-marker)) + (set-marker term-home-marker (point))) + (t + (setq term-scroll-with-delete + (not (and (=3D term-scroll-start 0) + (=3D term-scroll-end (term--last-line))))) + (goto-char (point-max)) + (when term-clear-full-screen-programs + (delete-region term-home-marker (point)) + (set-marker term-home-marker term-saved-home-marker)) + (set-marker term-saved-home-marker nil) + (setq term-saved-home-marker nil))) + + (setq term-start-line-column nil) + (setq term-current-column nil) + (setq term-current-row nil) + (term-handle-deferred-scroll))) =20 ;; Default value for the symbol term-command-function. =20 =2D-=20 2.34.1 --=-=-=-- --==-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQJHBAEBCAAxFiEEmxVnesoT5rQXvVXnswkaGpIVmT8FAmHu7g4THG1paGFAa2Ft bml0bmlrLnRvcAAKCRCzCRoakhWZPz59D/9A1yldaFpEehfH90sJxAnZ/OorZOfy hkH6zBZpYinec8JESwh6XP7IPP9Qb04yCOXkbrMenc4IsveTYjVtC7hRtDI9QK5W sGIvfy7cMcHPFXhA5SGR3KZVoi3AwdBGz+Rtcvvh/WwnH/IAllxy6xwg8mB2NY4v iJfscumdDa5ECzRKOQMDDRDz9H9d8Toq8FifEGcq2GwTUbvd7o1iStI3q7/At99J 0R/t9ED3n9SafxOTkS1TKNCaYkBa4UgUV0jhu7mEarxcdWAedn5dMkwjNpnfFAS3 NO3r41ljzysn2cBuPEm6D91H/GWldaxjA6lldgJl6yUvPMic5+vkxC22YxAmNDpM LSJ24ApayAAGALHqMmoli5ySAWB3oiSEZDye25xdE/Ie0L9c5oBOWj0wvOvTrQ0X +MzfK5c9JmYy9fMCcq6k3Os5WJvGJWXbXPmA+8dVX07SKEn0e3XGrdYGkxcocehx dyTcS+SlGDiUwU/g6qcaLkpVURJN4Aeo6aAOnaJpAVt2BlL6vg5V5S4HyZVWivJ4 3Rzqm6Sa2DaANtNuh7di7WYJQOODdmzV82XRj4lFa2jY6f1L60anq5Ythfd9BFLN y2kVIa5DJJxJuQWFC147/yV43QPeZBP0duvOeIGYgSchErl6qQDUMQY7+D1vjGil Fdt8PisHPcWymQ== =ojXD -----END PGP SIGNATURE----- --==-=-=--