diff options
| author | Noam Postavsky | 2016-09-11 11:09:57 -0400 |
|---|---|---|
| committer | Noam Postavsky | 2017-02-02 21:20:29 -0500 |
| commit | e27a91cddc1a66c25e09d3929c5625637ec34a49 (patch) | |
| tree | 00096f2a38822f4c63ba228e769fb02c1c966b54 /src | |
| parent | c92fc7a2156a5939439b7236452d4dfcfc13cc89 (diff) | |
| download | emacs-e27a91cddc1a66c25e09d3929c5625637ec34a49.tar.gz emacs-e27a91cddc1a66c25e09d3929c5625637ec34a49.zip | |
Make limit on scroll-margin variable
* src/xdisp.c (maximum-scroll-margin): New variable.
* lisp/cus-start.el: Make it customizable.
* etc/NEWS: Mention it.
* doc/emacs/display.texi (Auto Scrolling):
* doc/lispref/windows.texi (Textual Scrolling): Document it.
* src/window.c (window_scroll_pixel_based): Use it instead of hardcoding
division by 4 (Bug #5718).
Diffstat (limited to 'src')
| -rw-r--r-- | src/window.c | 19 | ||||
| -rw-r--r-- | src/xdisp.c | 8 |
2 files changed, 22 insertions, 5 deletions
diff --git a/src/window.c b/src/window.c index 235c3c1ade8..ba03780f3df 100644 --- a/src/window.c +++ b/src/window.c | |||
| @@ -4801,11 +4801,20 @@ window_scroll_margin (struct window *window, enum margin_unit unit) | |||
| 4801 | { | 4801 | { |
| 4802 | int frame_line_height = default_line_pixel_height (window); | 4802 | int frame_line_height = default_line_pixel_height (window); |
| 4803 | int window_lines = window_box_height (window) / frame_line_height; | 4803 | int window_lines = window_box_height (window) / frame_line_height; |
| 4804 | int margin = min (scroll_margin, window_lines / 4); | 4804 | |
| 4805 | if (unit == MARGIN_IN_PIXELS) | 4805 | double ratio = 0.25; |
| 4806 | return margin * frame_line_height; | 4806 | if (FLOATP (Vmaximum_scroll_margin)) |
| 4807 | else | 4807 | { |
| 4808 | return margin; | 4808 | ratio = XFLOAT_DATA (Vmaximum_scroll_margin); |
| 4809 | ratio = max (0.0, ratio); | ||
| 4810 | ratio = min (ratio, 0.5); | ||
| 4811 | } | ||
| 4812 | int max_margin = min ((window_lines - 1)/2, | ||
| 4813 | (int) (window_lines * ratio)); | ||
| 4814 | int margin = clip_to_bounds (0, scroll_margin, max_margin); | ||
| 4815 | return (unit == MARGIN_IN_PIXELS) | ||
| 4816 | ? margin * frame_line_height | ||
| 4817 | : margin; | ||
| 4809 | } | 4818 | } |
| 4810 | else | 4819 | else |
| 4811 | return 0; | 4820 | return 0; |
diff --git a/src/xdisp.c b/src/xdisp.c index 8a450b7a8a4..134ef6c6196 100644 --- a/src/xdisp.c +++ b/src/xdisp.c | |||
| @@ -31520,6 +31520,14 @@ Recenter the window whenever point gets within this many lines | |||
| 31520 | of the top or bottom of the window. */); | 31520 | of the top or bottom of the window. */); |
| 31521 | scroll_margin = 0; | 31521 | scroll_margin = 0; |
| 31522 | 31522 | ||
| 31523 | DEFVAR_LISP ("maximum-scroll-margin", Vmaximum_scroll_margin, | ||
| 31524 | doc: /* Maximum effective value of `scroll-margin'. | ||
| 31525 | Given as a fraction of the current window's lines. The value should | ||
| 31526 | be a floating point number between 0.0 and 0.5. The effective maximum | ||
| 31527 | is limited to (/ (1- window-lines) 2). Non-float values for this | ||
| 31528 | variable are ignored and the default 0.25 is used instead. */); | ||
| 31529 | Vmaximum_scroll_margin = make_float (0.25); | ||
| 31530 | |||
| 31523 | DEFVAR_LISP ("display-pixels-per-inch", Vdisplay_pixels_per_inch, | 31531 | DEFVAR_LISP ("display-pixels-per-inch", Vdisplay_pixels_per_inch, |
| 31524 | doc: /* Pixels per inch value for non-window system displays. | 31532 | doc: /* Pixels per inch value for non-window system displays. |
| 31525 | Value is a number or a cons (WIDTH-DPI . HEIGHT-DPI). */); | 31533 | Value is a number or a cons (WIDTH-DPI . HEIGHT-DPI). */); |