diff options
| author | Eli Zaretskii | 2017-05-31 19:01:31 +0300 |
|---|---|---|
| committer | Eli Zaretskii | 2017-05-31 19:01:31 +0300 |
| commit | 140ddc321be96c03ef234a12c56cef97a078fc07 (patch) | |
| tree | 96ea84c5cdcc8cfb9be7036bd30e702c62a736fb | |
| parent | a415c8bccb917c247792c4ce8e77b2512b3414d6 (diff) | |
| download | emacs-140ddc321be96c03ef234a12c56cef97a078fc07.tar.gz emacs-140ddc321be96c03ef234a12c56cef97a078fc07.zip | |
Support lower bound on hscrolling when only current line scrolls
* doc/emacs/display.texi (Horizontal Scrolling): Document the new
mode of auto-hscrolling only the current line.
* src/xdisp.c (init_iterator): When hscrolling only the
current line, apply the window's min_hscroll here, so that
non-current lines will be hscrolled by that minimum.
Suggested by Stephen Berman <stephen.berman@gmx.net>.
(hscroll_window_tree): Account for window's min_hscroll when
deciding whether to recompute the hscroll.
(display_line): Subtract window's min_hscroll from x_incr, as that
was already accounted for in init_iterator. (Bug#27008)
| -rw-r--r-- | doc/emacs/display.texi | 11 | ||||
| -rw-r--r-- | etc/NEWS | 1 | ||||
| -rw-r--r-- | src/xdisp.c | 24 |
3 files changed, 30 insertions, 6 deletions
diff --git a/doc/emacs/display.texi b/doc/emacs/display.texi index d07913cefbe..a0d0792eacc 100644 --- a/doc/emacs/display.texi +++ b/doc/emacs/display.texi | |||
| @@ -308,7 +308,11 @@ displayed. When the text in a window is scrolled horizontally, text | |||
| 308 | lines are truncated rather than continued (@pxref{Line Truncation}). | 308 | lines are truncated rather than continued (@pxref{Line Truncation}). |
| 309 | If a window shows truncated lines, Emacs performs automatic horizontal | 309 | If a window shows truncated lines, Emacs performs automatic horizontal |
| 310 | scrolling whenever point moves off the left or right edge of the | 310 | scrolling whenever point moves off the left or right edge of the |
| 311 | screen. To disable automatic horizontal scrolling, set the variable | 311 | screen. By default, all the lines in the window are scrolled |
| 312 | horizontally together, but if you set the variable | ||
| 313 | @code{auto-hscroll-mode} to the special value of @code{current-line}, | ||
| 314 | only the line showing the cursor will be scrolled. To disable | ||
| 315 | automatic horizontal scrolling entirely, set the variable | ||
| 312 | @code{auto-hscroll-mode} to @code{nil}. Note that when the automatic | 316 | @code{auto-hscroll-mode} to @code{nil}. Note that when the automatic |
| 313 | horizontal scrolling is turned off, if point moves off the edge of the | 317 | horizontal scrolling is turned off, if point moves off the edge of the |
| 314 | screen, the cursor disappears to indicate that. (On text terminals, | 318 | screen, the cursor disappears to indicate that. (On text terminals, |
| @@ -366,7 +370,10 @@ sufficiently large argument will restore the normal display. | |||
| 366 | If you use those commands to scroll a window horizontally, that sets | 370 | If you use those commands to scroll a window horizontally, that sets |
| 367 | a lower bound for automatic horizontal scrolling. Automatic scrolling | 371 | a lower bound for automatic horizontal scrolling. Automatic scrolling |
| 368 | will continue to scroll the window, but never farther to the right | 372 | will continue to scroll the window, but never farther to the right |
| 369 | than the amount you previously set by @code{scroll-left}. | 373 | than the amount you previously set by @code{scroll-left}. When |
| 374 | @code{auto-hscroll-mode} is set to @code{current-line}, all the lines | ||
| 375 | other than the one showing the cursor will be scrolled by that minimal | ||
| 376 | amount. | ||
| 370 | 377 | ||
| 371 | @node Narrowing | 378 | @node Narrowing |
| 372 | @section Narrowing | 379 | @section Narrowing |
| @@ -377,6 +377,7 @@ you may set this variable to nil. (Behind the scenes, there is now a | |||
| 377 | new mode line construct, '%C', which operates exactly as '%c' does | 377 | new mode line construct, '%C', which operates exactly as '%c' does |
| 378 | except that it counts from one.) | 378 | except that it counts from one.) |
| 379 | 379 | ||
| 380 | +++ | ||
| 380 | ** New single-line horizontal scrolling mode. | 381 | ** New single-line horizontal scrolling mode. |
| 381 | The 'auto-hscroll-mode' variable can now have a new special value, | 382 | The 'auto-hscroll-mode' variable can now have a new special value, |
| 382 | 'current-line', which causes only the line where the cursor is | 383 | 'current-line', which causes only the line where the cursor is |
diff --git a/src/xdisp.c b/src/xdisp.c index f4461c1627a..eaa701e9cf1 100644 --- a/src/xdisp.c +++ b/src/xdisp.c | |||
| @@ -2890,8 +2890,19 @@ init_iterator (struct it *it, struct window *w, | |||
| 2890 | } | 2890 | } |
| 2891 | else | 2891 | else |
| 2892 | { | 2892 | { |
| 2893 | /* When hscrolling only the current line, don't apply the | ||
| 2894 | hscroll here, it will be applied by display_line when it gets | ||
| 2895 | to laying out the line showing point. However, if the | ||
| 2896 | window's min_hscroll is positive, the user specified a lower | ||
| 2897 | bound for automatic hscrolling, so they expect the | ||
| 2898 | non-current lines to obey that hscroll amount. */ | ||
| 2893 | if (hscrolling_current_line_p (w)) | 2899 | if (hscrolling_current_line_p (w)) |
| 2894 | it->first_visible_x = 0; | 2900 | { |
| 2901 | if (w->min_hscroll > 0) | ||
| 2902 | it->first_visible_x = w->min_hscroll * FRAME_COLUMN_WIDTH (it->f); | ||
| 2903 | else | ||
| 2904 | it->first_visible_x = 0; | ||
| 2905 | } | ||
| 2895 | else | 2906 | else |
| 2896 | it->first_visible_x = | 2907 | it->first_visible_x = |
| 2897 | window_hscroll_limited (w, it->f) * FRAME_COLUMN_WIDTH (it->f); | 2908 | window_hscroll_limited (w, it->f) * FRAME_COLUMN_WIDTH (it->f); |
| @@ -13099,7 +13110,9 @@ hscroll_window_tree (Lisp_Object window) | |||
| 13099 | that doesn't need to be hscrolled. If we omit | 13110 | that doesn't need to be hscrolled. If we omit |
| 13100 | this condition, the line from which we move will | 13111 | this condition, the line from which we move will |
| 13101 | remain hscrolled. */ | 13112 | remain hscrolled. */ |
| 13102 | || (hscl && w->hscroll && !cursor_row->truncated_on_left_p))) | 13113 | || (hscl |
| 13114 | && w->hscroll != w->min_hscroll | ||
| 13115 | && !cursor_row->truncated_on_left_p))) | ||
| 13103 | { | 13116 | { |
| 13104 | struct it it; | 13117 | struct it it; |
| 13105 | ptrdiff_t hscroll; | 13118 | ptrdiff_t hscroll; |
| @@ -20717,9 +20730,12 @@ display_line (struct it *it, int cursor_vpos) | |||
| 20717 | recenter_overlay_lists (current_buffer, IT_CHARPOS (*it)); | 20730 | recenter_overlay_lists (current_buffer, IT_CHARPOS (*it)); |
| 20718 | 20731 | ||
| 20719 | /* If we are going to display the cursor's line, account for the | 20732 | /* If we are going to display the cursor's line, account for the |
| 20720 | hscroll of that line. */ | 20733 | hscroll of that line. We subtract the window's min_hscroll, |
| 20734 | because that was already accounted for in init_iterator. */ | ||
| 20721 | if (hscroll_this_line) | 20735 | if (hscroll_this_line) |
| 20722 | x_incr = window_hscroll_limited (it->w, it->f) * FRAME_COLUMN_WIDTH (it->f); | 20736 | x_incr = |
| 20737 | (window_hscroll_limited (it->w, it->f) - it->w->min_hscroll) | ||
| 20738 | * FRAME_COLUMN_WIDTH (it->f); | ||
| 20723 | 20739 | ||
| 20724 | /* Move over display elements that are not visible because we are | 20740 | /* Move over display elements that are not visible because we are |
| 20725 | hscrolled. This may stop at an x-position < first_visible_x | 20741 | hscrolled. This may stop at an x-position < first_visible_x |