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

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

bug#5718: scroll-margin in buffer with small line count.


From: npostavs
Subject: bug#5718: scroll-margin in buffer with small line count.
Date: Tue, 13 Sep 2016 22:23:07 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (gnu/linux)

martin rudalics <address@hidden> writes:

>        int window_total_lines
> -        = window->total_lines * WINDOW_FRAME_LINE_HEIGHT (window)
> +        = (window->total_lines * WINDOW_FRAME_LINE_HEIGHT (window)
> +           - WINDOW_MODE_LINE_HEIGHT (window))
>
> Please use another name instead of "window_total_lines" here.  And
> please explain why you can't use Fwindow_text_height here (i.e., why
> header lines, horizontal scrollbars and window dividers apparently don't
> count).

Oh, I just didn't think of those, I don't think there is a reason not to
use it.  How about this (I use window_box_height instead of
Fwindow_text_height just to save the bother of struct window* to
Lisp_Object conversion):

@@ -4799,10 +4799,7 @@ window_scroll_margin (struct window *window, enum 
margin_unit unit)
   if (scroll_margin > 0)
     {
       int frame_line_height = default_line_pixel_height (window);
-      int window_total_lines
-        = (window->total_lines * WINDOW_FRAME_LINE_HEIGHT (window)
-           - WINDOW_MODE_LINE_HEIGHT (window))
-        / frame_line_height;
+      int window_lines = window_box_height (window) / frame_line_height;

       int margin, max_margin;
       double ratio = 0.25;
@@ -4812,7 +4809,7 @@ window_scroll_margin (struct window *window, enum 
margin_unit unit)
           ratio = max (0.0, ratio);
           ratio = min (ratio, 0.5);
         }
-      max_margin = (int) (window_total_lines * ratio);
+      max_margin = (int) (window_lines * ratio);
       margin = max (0, scroll_margin);
       margin = min (scroll_margin, max_margin);


>
> +(defmacro window-with-test-buffer-window (&rest body)
>
> Please call it ‘window-test-with-test-buffer-window’ to consistentlyy
> keep the ‘window-test-’ prefix on everything defined in this file.

Oops, right.





reply via email to

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