GNU bug report logs - #5615
23.1.92; [PATCH] term.el: Calculation of window height is bad

Previous Next

Package: emacs;

Reported by: irieshinsuke <at> yahoo.co.jp

Date: Sun, 21 Feb 2010 06:10:02 UTC

Severity: normal

Tags: fixed, patch

Fixed in version 26.1

Done: npostavs <at> users.sourceforge.net

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 5615 in the body.
You can then email your comments to 5615 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#5615; Package emacs. (Sun, 21 Feb 2010 06:10:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to irieshinsuke <at> yahoo.co.jp:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Sun, 21 Feb 2010 06:10:03 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: IRIE Shinsuke <irieshinsuke <at> yahoo.co.jp>
To: bug-gnu-emacs <at> gnu.org
Subject: 23.1.92; [PATCH] term.el: Calculation of window height is bad
Date: Sun, 21 Feb 2010 14:57:46 +0900
[Message part 1 (text/plain, inline)]
When I use term-mode (ansi-term), the bottom row of the terminal
often disappears from the window. For example, if I execute Emacs in
ansi-term with -nw option, the minibuffer is unusable because it becomes
completely hidden. I investigated this problem and found the solution.

In term.el, the number of rows of the terminal window is calculated as:

(1- (window-height))

This expression, however, doesn't always return exact value from lack
of consideration to the header line height and the spacing of each row.
So I tested the better expression instead:

(if (display-graphic-p)
    (let ((e (window-inside-pixel-edges))
          (s (or line-spacing 0)))
      (/ (+ (- (nth 3 e) (cadr e)) s)
         (+ (frame-char-height) s)))
  (window-text-height))

and it seems to work fine. We can test this expression by evaluating
the following code before starting ansi-term:

(add-hook 'term-mode-hook
          (lambda ()
            (fset 'term-window-height
                  #'(lambda ()
                      (if (display-graphic-p)
                          (let ((e (window-inside-pixel-edges))
                                (s (or line-spacing 0)))
                            (/ (+ (- (nth 3 e) (cadr e)) s)
                               (+ (frame-char-height) s)))
                        (window-text-height))))
            (fset 'term-check-size
                  #'(lambda (process)
                      (when (or (/= term-height (term-window-height))
                                (/= term-width (term-window-width)))
                        (term-reset-size (term-window-height) (term-window-width))
                        (set-process-window-size process term-height term-width))))
            (setq term-height (term-window-height))))

or applying the patch I attached.
[term-window-height.patch (text/x-diff, attachment)]

Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#5615; Package emacs. (Fri, 19 Mar 2010 10:23:02 GMT) Full text and rfc822 format available.

Message #8 received at 5615 <at> debbugs.gnu.org (full text, mbox):

From: IRIE Shinsuke <irieshinsuke <at> yahoo.co.jp>
To: 5615 <at> debbugs.gnu.org
Subject: bug#5615: 23.1.92; [PATCH] term.el: Calculation of window height
	is bad (new patch)
Date: Fri, 19 Mar 2010 19:23:09 +0900
Sorry, the patch I sent with previous mail is bad, because the previous
patch was made without considering `line-spacing' specified by a
floating point number or frame-parameter.

So I wrote the new patch. Please check it.


IRIE Shinsuke





Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#5615; Package emacs. (Fri, 19 Mar 2010 10:25:02 GMT) Full text and rfc822 format available.

Message #11 received at 5615 <at> debbugs.gnu.org (full text, mbox):

From: IRIE Shinsuke <irieshinsuke <at> yahoo.co.jp>
To: 5615 <at> debbugs.gnu.org
Subject: bug#5615: 23.1.92; [PATCH] term.el: Calculation of window height
	is bad (new patch)
Date: Fri, 19 Mar 2010 19:25:06 +0900
[Message part 1 (text/plain, inline)]
Sorry, the patch I sent with previous mail is bad, because the previous
patch was made without considering `line-spacing' specified by a
floating point number or frame-parameter.

So I wrote the new patch. Please check it.


IRIE Shinsuke

[term-window-height-newpatch.patch (text/x-diff, attachment)]

Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#5615; Package emacs. (Fri, 19 Mar 2010 10:38:02 GMT) Full text and rfc822 format available.

Message #14 received at 5615 <at> debbugs.gnu.org (full text, mbox):

From: IRIE Shinsuke <irieshinsuke <at> yahoo.co.jp>
To: 5615 <at> debbugs.gnu.org
Subject: bug#5615: 23.1.92; [PATCH] term.el: Calculation of window height
	is bad (new patch)
Date: Fri, 19 Mar 2010 19:38:01 +0900
Oops, I missed attaching the patch to the mail... Sorry.


IRIE Shinsuke





Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#5615; Package emacs. (Sun, 30 May 2010 05:24:01 GMT) Full text and rfc822 format available.

Message #17 received at 5615 <at> debbugs.gnu.org (full text, mbox):

From: Ken Hori <fplemma <at> gmail.com>
To: IRIE Shinsuke <irieshinsuke <at> yahoo.co.jp>
Cc: 5615 <at> debbugs.gnu.org
Subject: Re: bug#5615: 23.1.92; [PATCH] term.el: Calculation of window height 
	is bad (new patch)
Date: Sat, 29 May 2010 22:23:47 -0700
Haven't tried yet, but thanks for the patch.

I'm sure this "off-by-2-lines" problem has been an annoyance to most
forks who use term.el off the bzr head.

2010/3/19 IRIE Shinsuke <irieshinsuke <at> yahoo.co.jp>:
> Oops, I missed attaching the patch to the mail... Sorry.
>
>
> IRIE Shinsuke
>
>
>
>
>
>




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#5615; Package emacs. (Sun, 28 Feb 2016 06:08:01 GMT) Full text and rfc822 format available.

Message #20 received at 5615 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: IRIE Shinsuke <irieshinsuke <at> yahoo.co.jp>
Cc: 5615 <at> debbugs.gnu.org
Subject: Re: bug#5615: 23.1.92;
 [PATCH] term.el: Calculation of window height is bad (new patch)
Date: Sun, 28 Feb 2016 17:06:57 +1100
IRIE Shinsuke <irieshinsuke <at> yahoo.co.jp> writes:

> Sorry, the patch I sent with previous mail is bad, because the previous
> patch was made without considering `line-spacing' specified by a
> floating point number or frame-parameter.
>
> So I wrote the new patch. Please check it.

[...]

Is this still a problem in the current Emacs?

> + (defun term-window-height ()
> +   (if (display-graphic-p)
> +       (let ((e (window-inside-pixel-edges))
> + 	    (s (or (with-current-buffer (window-buffer) line-spacing)
> + 		   (frame-parameter nil 'line-spacing)
> + 		   0)))
> + 	(if (floatp s)
> + 	    (setq s (truncate (* (frame-char-height) s))))
> + 	(/ (+ (- (nth 3 e) (cadr e)) s)
> + 	   (+ (frame-char-height) s)))
> +     (window-text-height)))
>   
>   (put 'term-mode 'mode-class 'special)

[...]

>   (defun term-check-size (process)
> !   (when (or (/= term-height (1- (window-height)))
>   	    (/= term-width (term-window-width)))
> !     (term-reset-size (1- (window-height)) (term-window-width))
>       (set-process-window-size process term-height term-width)))
>   
>   (defun term-send-raw-string (chars)
> --- 1193,1201 ----
>       found))
>   
>   (defun term-check-size (process)
> !   (when (or (/= term-height (term-window-height))
>   	    (/= term-width (term-window-width)))
> !     (term-reset-size (term-window-height) (term-window-width))
>       (set-process-window-size process term-height term-width)))
>   
>   (defun term-send-raw-string (chars)

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#5615; Package emacs. (Fri, 11 Aug 2017 00:44:02 GMT) Full text and rfc822 format available.

Message #23 received at 5615 <at> debbugs.gnu.org (full text, mbox):

From: npostavs <at> users.sourceforge.net
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: IRIE Shinsuke <irieshinsuke <at> yahoo.co.jp>, 5615 <at> debbugs.gnu.org
Subject: Re: bug#5615: 23.1.92;
 [PATCH] term.el: Calculation of window height is bad (new patch)
Date: Thu, 10 Aug 2017 20:45:16 -0400
[Message part 1 (text/plain, inline)]
tags 5615 + patch
quit

Lars Ingebrigtsen <larsi <at> gnus.org> writes:

> IRIE Shinsuke <irieshinsuke <at> yahoo.co.jp> writes:
>
>> Sorry, the patch I sent with previous mail is bad, because the previous
>> patch was made without considering `line-spacing' specified by a
>> floating point number or frame-parameter.
>>
>> So I wrote the new patch. Please check it.
>
> [...]
>
> Is this still a problem in the current Emacs?

Current Emacs still uses the same (1- (window-height)) expression, but I
can't understand from the description when exactly this gives the wrong
result.  Furthermore, I don't see any justification which would explain
why the new proposed significantly more complicated computation is more
correct.  I think we should just use window-text-height.

[v2-0001-lisp-term.el-term-mode-Use-window-text-height-Bug.patch (text/x-diff, inline)]
From b22407f5fedea77f34ca1efb5469e368164f9084 Mon Sep 17 00:00:00 2001
From: Noam Postavsky <npostavs <at> gmail.com>
Date: Thu, 10 Aug 2017 20:43:13 -0400
Subject: [PATCH v2] * lisp/term.el (term-mode): Use `window-text-height'
 (Bug#5615).

---
 lisp/term.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lisp/term.el b/lisp/term.el
index 5eb7b3e8ed..12a37cafbe 100644
--- a/lisp/term.el
+++ b/lisp/term.el
@@ -1007,7 +1007,7 @@ term-mode
   (setq indent-tabs-mode nil)
   (setq buffer-display-table term-display-table)
   (set (make-local-variable 'term-home-marker) (copy-marker 0))
-  (set (make-local-variable 'term-height) (1- (window-height)))
+  (set (make-local-variable 'term-height) (window-text-height))
   (set (make-local-variable 'term-width) (window-max-chars-per-line))
   (set (make-local-variable 'term-last-input-start) (make-marker))
   (set (make-local-variable 'term-last-input-end) (make-marker))
-- 
2.11.1


Added tag(s) patch. Request was from npostavs <at> users.sourceforge.net to control <at> debbugs.gnu.org. (Fri, 11 Aug 2017 00:44:03 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#5615; Package emacs. (Fri, 11 Aug 2017 06:34:01 GMT) Full text and rfc822 format available.

Message #28 received at 5615 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: npostavs <at> users.sourceforge.net
Cc: larsi <at> gnus.org, irieshinsuke <at> yahoo.co.jp, 5615 <at> debbugs.gnu.org
Subject: Re: bug#5615: 23.1.92;
 [PATCH] term.el: Calculation of window height is bad (new patch)
Date: Fri, 11 Aug 2017 09:32:43 +0300
> From: npostavs <at> users.sourceforge.net
> Date: Thu, 10 Aug 2017 20:45:16 -0400
> Cc: IRIE Shinsuke <irieshinsuke <at> yahoo.co.jp>, 5615 <at> debbugs.gnu.org
> 
> Current Emacs still uses the same (1- (window-height)) expression, but I
> can't understand from the description when exactly this gives the wrong
> result.  Furthermore, I don't see any justification which would explain
> why the new proposed significantly more complicated computation is more
> correct.  I think we should just use window-text-height.

I think you are right.  If no one objects in a few days, please push
your change.

Thanks.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#5615; Package emacs. (Sun, 20 Aug 2017 03:33:01 GMT) Full text and rfc822 format available.

Message #31 received at 5615 <at> debbugs.gnu.org (full text, mbox):

From: npostavs <at> users.sourceforge.net
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: larsi <at> gnus.org, irieshinsuke <at> yahoo.co.jp, 5615 <at> debbugs.gnu.org
Subject: Re: bug#5615: 23.1.92;
 [PATCH] term.el: Calculation of window height is bad (new patch)
Date: Sat, 19 Aug 2017 23:34:24 -0400
tags 5615 fixed
close 5615 26.1
quit

Eli Zaretskii <eliz <at> gnu.org> writes:

>> From: npostavs <at> users.sourceforge.net
>> Date: Thu, 10 Aug 2017 20:45:16 -0400
>> Cc: IRIE Shinsuke <irieshinsuke <at> yahoo.co.jp>, 5615 <at> debbugs.gnu.org
>> 
>> Current Emacs still uses the same (1- (window-height)) expression, but I
>> can't understand from the description when exactly this gives the wrong
>> result.  Furthermore, I don't see any justification which would explain
>> why the new proposed significantly more complicated computation is more
>> correct.  I think we should just use window-text-height.
>
> I think you are right.  If no one objects in a few days, please push
> your change.

Pushed to master.

[1: dbd3a17cb0]: 2017-08-19 23:29:28 -0400
  * lisp/term.el (term-mode): Use `window-text-height' (Bug#5615).
  http://git.savannah.gnu.org/cgit/emacs.git/commit/?id=dbd3a17cb068148bd49e288eb0b44ca7eb4a4e3c




Added tag(s) fixed. Request was from npostavs <at> users.sourceforge.net to control <at> debbugs.gnu.org. (Sun, 20 Aug 2017 03:33:02 GMT) Full text and rfc822 format available.

bug marked as fixed in version 26.1, send any further explanations to 5615 <at> debbugs.gnu.org and irieshinsuke <at> yahoo.co.jp Request was from npostavs <at> users.sourceforge.net to control <at> debbugs.gnu.org. (Sun, 20 Aug 2017 03:33:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sun, 17 Sep 2017 11:24:03 GMT) Full text and rfc822 format available.

This bug report was last modified 7 years and 358 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.