bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


From: IRIE Shinsuke
Subject: bug#5615: 23.1.92; [PATCH] term.el: Calculation of window height is bad
Date: Sun, 21 Feb 2010 14:57:46 +0900
User-agent: Mozilla/5.0 (X11; U; Linux i686; ja; rv:1.9.1.7) Gecko/20100111 Thunderbird/3.0.1

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.

Attachment: term-window-height.patch
Description: Text Data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]