* bug#53485: 29.0.50; [PATCH] Implement alternative sub-buffer support in term.el
@ 2022-01-23 21:00 miha--- via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-01-24 10:26 ` Lars Ingebrigtsen
0 siblings, 1 reply; 4+ messages in thread
From: miha--- via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2022-01-23 21:00 UTC (permalink / raw)
To: 53485
[-- Attachment #1.1: Type: text/plain, Size: 536 bytes --]
In M-x term, try:
$ seq 100
$ htop
Press 'q' to exit htop.
(Instead of 'htop', you could also try with 'emacs -q', 'vi' or any
other full-screen TUI program.)
Current behaviour: htop overwrites a portion of output from the 'seq'
command and htop's contents remain visible on the screen after pressing
'q'.
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.
Best regards.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: 0001-Implement-alternative-sub-buffer-support-in-term.el.patch --]
[-- Type: text/x-patch, Size: 8604 bytes --]
From 41d2f635612c2ef7e046b8f38bd81d0393a7a730 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Miha=20Rihtar=C5=A1i=C4=8D?= <miha@kamnitnik.top>
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-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.
---
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 | 80 ++++++++++++++++++++++++-------------------
4 files changed, 48 insertions(+), 37 deletions(-)
diff --git a/etc/e/eterm-color b/etc/e/eterm-color
index bf44fa0f36de0f6681fa3172db13a83c414aa42a..fadac25ffcb55b3b3f6812e9c80f848e94f3dcc3 100644
GIT binary patch
delta 283
zcmbQhwTz2fiqV}xl7XKglkwC<?r=^97?_wC?h?-M|9>n)5<@zW&S5BIC<D^}|5r2A
z1L;<VE`|wUK1d7(rU6A}K}F{P>4glF4H;!5mNKjYa@GU!W`-RMd!Y&rGEAPxsAO}L
z;T*$th6g~wmkgg6egkP1MwodJnit9!0Mf#YVvG_{zBJ?Hi;PxGvLNc@WC2EYCM8Co
zk$PO}j7DH3=8Qn=rNkVd>XA)#1!?kP_Gavw9LOBSY+{}<c?Gi?lX=eOQ_OCR0H64e
At^fc4
delta 270
zcmZ3+HGzv;iqV~c9|$uU_f6yupO_Qo{2vIy8Dba`8UFuIW5{MG0Mh^emx9SkhB}58
zFbgCG16@FoKB(vfAU$<rq3GlQMh@|r4D*28#X!8AVGYAZsFJN9=?#p0Hai&(F`Q<&
z0u;W>@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
--- 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=^G,
blink=\E[5m,
@@ -77,8 +78,8 @@ eterm-color|Emacs term.el terminal emulator term-protocol-version 0.96,
smso=\E[7m,
u6=\E[%i%d;%dR,
u7=\E[6n,
-# smcup=\E[?47h,
-# rmcup=\E[?47l,
+ smcup=\E[47h,
+ rmcup=\E[47l,
# rs2 may need to be added
eterm-direct|Emacs term.el with direct-color indexing term-protocol-version 0.96,
diff --git a/etc/e/eterm-direct b/etc/e/eterm-direct
index c113c3713693b948ae9d52e75df5d89957fd0c77..f4c16621eb185d7d0de14b56fb2e2b73a57adab8 100644
GIT binary patch
delta 259
zcmcc5^_7cTjwz5ql7XKglkww3?nF)o7?_w{>JrZI|9>n)5<@zW&S5BIC<D^}|5r2A
z1L;<VE`|wUK1d7(rU6A}K}F{P>4gjv8)YPxGOPl!*8}lph8+xhq4EbACLd%}vOdai
zj^R4P1EAnbhEEK?fiw#v%s2?m3*`#{X<<e&MhPfidh$m`Yerchd67{GNa}N{Ga7;A
q%z-><Mh74%%;*Xvy_vlk=S{9;j$$@3&zO9HS&hj&XY(iKTt)x@PJ&SY
delta 260
zcmey$b)Sn{jwz6V9|$uUpHAdXoLE-k{2vIy8Dba`8UFuIW5{MG0Mh^emx9SkhB}58
zFbgCG16@FoKB(vfAU$<rqpbK$hIv5dVjy15u!dnHRC?>gMrG@r42Kv_Gh6`*-DP;j
z@E%D2fJ(zmWMqV}Sb#J;BNrnNl+Qm|ky&{11x5`<K`={zX%F-N|6)*48BS?NHLyx;
kkjTUZ9E>I)2BRfZu?4d|<D|*W%u$mcGb?ZAVaa3!0GjoLTL1t6
diff --git a/lisp/term.el b/lisp/term.el
index 895dfbed6c..e1ace628b2 100644
--- a/lisp/term.el
+++ b/lisp/term.el
@@ -1270,7 +1270,8 @@ term-reset-size
(when (/= width term-width)
(save-excursion
(term--remove-fake-newlines)))
- (let ((point (point)))
+ (let ((point (point))
+ (home-marker (marker-position term-home-marker)))
(setq term-height height)
(setq term-width width)
(setq term-start-line-column nil)
@@ -1279,11 +1280,20 @@ term-reset-size
(term--reset-scroll-region)
;; `term-set-scroll-region' causes these to be set, we have to
;; clear them again since we're changing point (Bug#30544).
+ (term--unwrap-visible-long-lines width)
(setq term-start-line-column nil)
(setq term-current-row nil)
(setq term-current-column nil)
- (goto-char point))
- (term--unwrap-visible-long-lines width)))
+ (goto-char point)
+
+ (when (term-using-alternate-sub-buffer)
+ (term-handle-deferred-scroll)
+ ;; When using an alternative sub-buffer, the home marker should
+ ;; not move forward. Bring it back by deleting text in front of
+ ;; it.
+ (when (> term-home-marker home-marker)
+ (let ((inhibit-read-only t))
+ (delete-region home-marker term-home-marker)))))))
;; Recursive routine used to check if any string in term-kill-echo-list
;; matches part of the buffer before point.
@@ -1611,6 +1621,7 @@ term-termcap-format
"%s%s:li#%d:co#%d:cl=\\E[H\\E[J:cd=\\E[J:bs:am:xn:cm=\\E[%%i%%d;%%dH\
:nd=\\E[C:up=\\E[A:ce=\\E[K:ho=\\E[H:pt\
:al=\\E[L:dl=\\E[M:DL=\\E[%%dM:AL=\\E[%%dL:cs=\\E[%%i%%d;%%dr:sf=^J\
+:NR:te=\\E[47l:ti=\\E[47h\
:dc=\\E[P:DC=\\E[%%dP:IC=\\E[%%d@:im=\\E[4h:ei=\\E[4l:mi:\
:mb=\\E[5m:mh=\\E[2m:ZR=\\E[23m:ZH=\\E[3m\
:so=\\E[7m:se=\\E[m:us=\\E[4m:ue=\\E[m:md=\\E[1m:mr=\\E[7m:me=\\E[m\
@@ -3539,16 +3550,14 @@ term-handle-ansi-escape
((eq char ?h)
(cond ((eq (car params) 4) ;; (terminfo: smir)
(setq term-insert-mode t))
- ;; ((eq (car params) 47) ;; (terminfo: smcup)
- ;; (term-switch-to-alternate-sub-buffer t))
- ))
+ ((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))
- ;; ((eq (car params) 47) ;; (terminfo: rmcup)
- ;; (term-switch-to-alternate-sub-buffer nil))
- ))
+ ((eq (car params) 47) ;; (terminfo: rmcup)
+ (term-switch-to-alternate-sub-buffer nil))))
;; Modified to allow ansi coloring -mm
;; \E[m - Set/reset modes, set bg/fg
@@ -3595,32 +3604,33 @@ term-set-scroll-region
(term-move-columns (- (term-current-column)))
(term-goto 0 0))
-;; (defun term-switch-to-alternate-sub-buffer (set)
-;; ;; If asked to switch to (from) the alternate sub-buffer, and already (not)
-;; ;; using it, do nothing. This test is needed for some programs (including
-;; ;; Emacs) that emit the ti termcap string twice, for unknown reason.
-;; (term-handle-deferred-scroll)
-;; (if (eq set (not (term-using-alternate-sub-buffer)))
-;; (let ((row (term-current-row))
-;; (col (term-horizontal-column)))
-;; (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 (= term-scroll-start 0)
-;; (= term-scroll-end term-height))))
-;; (set-marker term-home-marker term-saved-home-marker)
-;; (set-marker term-saved-home-marker nil)
-;; (setq term-saved-home-marker nil)
-;; (goto-char term-home-marker)))
-;; (setq term-current-column nil)
-;; (setq term-current-row 0)
-;; (term-goto row col))))
+(defun term-switch-to-alternate-sub-buffer (set)
+ ;; If asked to switch to (from) the alternate sub-buffer, and already (not)
+ ;; using it, do nothing. This test is needed for some programs (including
+ ;; Emacs) that emit the ti termcap string twice, for unknown reason.
+ (term-handle-deferred-scroll)
+ (when (eq set (not (term-using-alternate-sub-buffer)))
+ (let ((row (term-current-row))
+ (col (term-horizontal-column)))
+ (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 (= term-scroll-start 0)
+ (= term-scroll-end (term--last-line)))))
+ (delete-region term-home-marker (point-max))
+ (set-marker term-home-marker term-saved-home-marker)
+ (set-marker term-saved-home-marker nil)
+ (setq term-saved-home-marker nil)
+ (goto-char (point-max))))
+ (setq term-current-column nil)
+ (setq term-current-row nil)
+ (term-goto row col))))
;; Default value for the symbol term-command-function.
--
2.34.1
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 861 bytes --]
^ permalink raw reply related [flat|nested] 4+ messages in thread
* bug#53485: 29.0.50; [PATCH] Implement alternative sub-buffer support in term.el
2022-01-23 21:00 bug#53485: 29.0.50; [PATCH] Implement alternative sub-buffer support in term.el miha--- via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2022-01-24 10:26 ` Lars Ingebrigtsen
2022-01-24 18:21 ` miha--- via Bug reports for GNU Emacs, the Swiss army knife of text editors
0 siblings, 1 reply; 4+ messages in thread
From: Lars Ingebrigtsen @ 2022-01-24 10:26 UTC (permalink / raw)
To: miha; +Cc: 53485
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.)
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
^ permalink raw reply [flat|nested] 4+ messages in thread
* bug#53485: 29.0.50; [PATCH] Implement alternative sub-buffer support in term.el
2022-01-24 10:26 ` Lars Ingebrigtsen
@ 2022-01-24 18:21 ` miha--- via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-01-24 19:03 ` Lars Ingebrigtsen
0 siblings, 1 reply; 4+ messages in thread
From: miha--- via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2022-01-24 18:21 UTC (permalink / raw)
To: Lars Ingebrigtsen; +Cc: 53485
[-- Attachment #1.1: Type: text/plain, Size: 546 bytes --]
Lars Ingebrigtsen <larsi@gnus.org> 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.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: 0001-Implement-alternative-sub-buffer-support-in-term.el.patch --]
[-- Type: text/x-patch, Size: 9330 bytes --]
From 884c26d84c8cc615916f7f9270b16ac615868b83 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Miha=20Rihtar=C5=A1i=C4=8D?= <miha@kamnitnik.top>
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.
---
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..fadac25ffcb55b3b3f6812e9c80f848e94f3dcc3 100644
GIT binary patch
delta 283
zcmbQhwTz2fiqV}xl7XKglkwC<?r=^97?_wC?h?-M|9>n)5<@zW&S5BIC<D^}|5r2A
z1L;<VE`|wUK1d7(rU6A}K}F{P>4glF4H;!5mNKjYa@GU!W`-RMd!Y&rGEAPxsAO}L
z;T*$th6g~wmkgg6egkP1MwodJnit9!0Mf#YVvG_{zBJ?Hi;PxGvLNc@WC2EYCM8Co
zk$PO}j7DH3=8Qn=rNkVd>XA)#1!?kP_Gavw9LOBSY+{}<c?Gi?lX=eOQ_OCR0H64e
At^fc4
delta 270
zcmZ3+HGzv;iqV~c9|$uU_f6yupO_Qo{2vIy8Dba`8UFuIW5{MG0Mh^emx9SkhB}58
zFbgCG16@FoKB(vfAU$<rq3GlQMh@|r4D*28#X!8AVGYAZsFJN9=?#p0Hai&(F`Q<&
z0u;W>@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
--- 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=^G,
blink=\E[5m,
@@ -77,8 +78,8 @@ eterm-color|Emacs term.el terminal emulator term-protocol-version 0.96,
smso=\E[7m,
u6=\E[%i%d;%dR,
u7=\E[6n,
-# smcup=\E[?47h,
-# rmcup=\E[?47l,
+ smcup=\E[47h,
+ rmcup=\E[47l,
# rs2 may need to be added
eterm-direct|Emacs term.el with direct-color indexing term-protocol-version 0.96,
diff --git a/etc/e/eterm-direct b/etc/e/eterm-direct
index c113c3713693b948ae9d52e75df5d89957fd0c77..f4c16621eb185d7d0de14b56fb2e2b73a57adab8 100644
GIT binary patch
delta 259
zcmcc5^_7cTjwz5ql7XKglkww3?nF)o7?_w{>JrZI|9>n)5<@zW&S5BIC<D^}|5r2A
z1L;<VE`|wUK1d7(rU6A}K}F{P>4gjv8)YPxGOPl!*8}lph8+xhq4EbACLd%}vOdai
zj^R4P1EAnbhEEK?fiw#v%s2?m3*`#{X<<e&MhPfidh$m`Yerchd67{GNa}N{Ga7;A
q%z-><Mh74%%;*Xvy_vlk=S{9;j$$@3&zO9HS&hj&XY(iKTt)x@PJ&SY
delta 260
zcmey$b)Sn{jwz6V9|$uUpHAdXoLE-k{2vIy8Dba`8UFuIW5{MG0Mh^emx9SkhB}58
zFbgCG16@FoKB(vfAU$<rqpbK$hIv5dVjy15u!dnHRC?>gMrG@r42Kv_Gh6`*-DP;j
z@E%D2fJ(zmWMqV}Sb#J;BNrnNl+Qm|ky&{11x5`<K`={zX%F-N|6)*48BS?NHLyx;
kkjTUZ9E>I)2BRfZu?4d|<D|*W%u$mcGb?ZAVaa3!0GjoLTL1t6
diff --git a/lisp/term.el b/lisp/term.el
index 895dfbed6c..0c8763b462 100644
--- a/lisp/term.el
+++ b/lisp/term.el
@@ -523,6 +523,16 @@ term-suppress-hard-newline
(make-obsolete-variable 'term-suppress-hard-newline nil
"27.1")
+(defcustom term-clear-full-screen-programs t
+ "Whether to clear contents of full-screen TUI programs after exit.
+If non-nil, output of full-screen TUI programs is cleared after
+exiting them. Note however that a minority of such programs
+don't send an appropriate escape sequence to the terminal before
+exiting so their output isn't cleared regardless of this option."
+ :version "29.1"
+ :type 'boolean
+ :group 'term)
+
;; Where gud-display-frame should put the debugging arrow. This is
;; set by the marker-filter, which scans the debugger's output for
;; indications of the current pc.
@@ -1270,7 +1280,8 @@ term-reset-size
(when (/= width term-width)
(save-excursion
(term--remove-fake-newlines)))
- (let ((point (point)))
+ (let ((point (point))
+ (home-marker (marker-position term-home-marker)))
(setq term-height height)
(setq term-width width)
(setq term-start-line-column nil)
@@ -1279,11 +1290,20 @@ term-reset-size
(term--reset-scroll-region)
;; `term-set-scroll-region' causes these to be set, we have to
;; clear them again since we're changing point (Bug#30544).
+ (term--unwrap-visible-long-lines width)
(setq term-start-line-column nil)
(setq term-current-row nil)
(setq term-current-column nil)
- (goto-char point))
- (term--unwrap-visible-long-lines width)))
+ (goto-char point)
+
+ (when (term-using-alternate-sub-buffer)
+ (term-handle-deferred-scroll)
+ ;; When using an alternative sub-buffer, the home marker should
+ ;; not move forward. Bring it back by deleting text in front of
+ ;; it.
+ (when (> term-home-marker home-marker)
+ (let ((inhibit-read-only t))
+ (delete-region home-marker term-home-marker)))))))
;; 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=\\E[H\\E[J:cd=\\E[J:bs:am:xn:cm=\\E[%%i%%d;%%dH\
:nd=\\E[C:up=\\E[A:ce=\\E[K:ho=\\E[H:pt\
:al=\\E[L:dl=\\E[M:DL=\\E[%%dM:AL=\\E[%%dL:cs=\\E[%%i%%d;%%dr:sf=^J\
+:NR:te=\\E[47l:ti=\\E[47h\
:dc=\\E[P:DC=\\E[%%dP:IC=\\E[%%d@:im=\\E[4h:ei=\\E[4l:mi:\
:mb=\\E[5m:mh=\\E[2m:ZR=\\E[23m:ZH=\\E[3m\
:so=\\E[7m:se=\\E[m:us=\\E[4m:ue=\\E[m:md=\\E[1m:mr=\\E[7m:me=\\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))
- ;; ((eq (car params) 47) ;; (terminfo: smcup)
- ;; (term-switch-to-alternate-sub-buffer t))
- ))
+ ((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))
- ;; ((eq (car params) 47) ;; (terminfo: rmcup)
- ;; (term-switch-to-alternate-sub-buffer nil))
- ))
+ ((eq (car params) 47) ;; (terminfo: rmcup)
+ (term-switch-to-alternate-sub-buffer nil))))
;; 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))
-;; (defun term-switch-to-alternate-sub-buffer (set)
-;; ;; If asked to switch to (from) the alternate sub-buffer, and already (not)
-;; ;; using it, do nothing. This test is needed for some programs (including
-;; ;; Emacs) that emit the ti termcap string twice, for unknown reason.
-;; (term-handle-deferred-scroll)
-;; (if (eq set (not (term-using-alternate-sub-buffer)))
-;; (let ((row (term-current-row))
-;; (col (term-horizontal-column)))
-;; (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 (= term-scroll-start 0)
-;; (= term-scroll-end term-height))))
-;; (set-marker term-home-marker term-saved-home-marker)
-;; (set-marker term-saved-home-marker nil)
-;; (setq term-saved-home-marker nil)
-;; (goto-char term-home-marker)))
-;; (setq term-current-column nil)
-;; (setq term-current-row 0)
-;; (term-goto row col))))
+(defun term-switch-to-alternate-sub-buffer (set)
+ ;; If asked to switch to (from) the alternate sub-buffer, and already (not)
+ ;; using it, do nothing. This test is needed for some programs (including
+ ;; 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 (= term-scroll-start 0)
+ (= 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)))
;; Default value for the symbol term-command-function.
--
2.34.1
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 861 bytes --]
^ permalink raw reply related [flat|nested] 4+ messages in thread
* bug#53485: 29.0.50; [PATCH] Implement alternative sub-buffer support in term.el
2022-01-24 18:21 ` miha--- via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2022-01-24 19:03 ` Lars Ingebrigtsen
0 siblings, 0 replies; 4+ messages in thread
From: Lars Ingebrigtsen @ 2022-01-24 19:03 UTC (permalink / raw)
To: miha; +Cc: 53485
<miha@kamnitnik.top> writes:
> Thanks, good idea, sending revised patch.
Great; seems to work perfect. 😀 Pushed to Emacs 29.
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-01-24 19:03 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-01-23 21:00 bug#53485: 29.0.50; [PATCH] Implement alternative sub-buffer support in term.el miha--- via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-01-24 10:26 ` Lars Ingebrigtsen
2022-01-24 18:21 ` miha--- via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-01-24 19:03 ` Lars Ingebrigtsen
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).