emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] master 140ddc3: Support lower bound on hscrolling when onl


From: Eli Zaretskii
Subject: [Emacs-diffs] master 140ddc3: Support lower bound on hscrolling when only current line scrolls
Date: Wed, 31 May 2017 12:03:16 -0400 (EDT)

branch: master
commit 140ddc321be96c03ef234a12c56cef97a078fc07
Author: Eli Zaretskii <address@hidden>
Commit: Eli Zaretskii <address@hidden>

    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 <address@hidden>.
    (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)
---
 doc/emacs/display.texi | 11 +++++++++--
 etc/NEWS               |  1 +
 src/xdisp.c            | 24 ++++++++++++++++++++----
 3 files changed, 30 insertions(+), 6 deletions(-)

diff --git a/doc/emacs/display.texi b/doc/emacs/display.texi
index d07913c..a0d0792 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
 lines are truncated rather than continued (@pxref{Line Truncation}).
 If a window shows truncated lines, Emacs performs automatic horizontal
 scrolling whenever point moves off the left or right edge of the
-screen.  To disable automatic horizontal scrolling, set the variable
+screen.  By default, all the lines in the window are scrolled
+horizontally together, but if you set the variable
address@hidden to the special value of @code{current-line},
+only the line showing the cursor will be scrolled.  To disable
+automatic horizontal scrolling entirely, set the variable
 @code{auto-hscroll-mode} to @code{nil}.  Note that when the automatic
 horizontal scrolling is turned off, if point moves off the edge of the
 screen, the cursor disappears to indicate that.  (On text terminals,
@@ -366,7 +370,10 @@ sufficiently large argument will restore the normal 
display.
   If you use those commands to scroll a window horizontally, that sets
 a lower bound for automatic horizontal scrolling.  Automatic scrolling
 will continue to scroll the window, but never farther to the right
-than the amount you previously set by @code{scroll-left}.
+than the amount you previously set by @code{scroll-left}.  When
address@hidden is set to @code{current-line}, all the lines
+other than the one showing the cursor will be scrolled by that minimal
+amount.
 
 @node Narrowing
 @section Narrowing
diff --git a/etc/NEWS b/etc/NEWS
index 14cada4..43e7897 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -377,6 +377,7 @@ you may set this variable to nil.  (Behind the scenes, 
there is now a
 new mode line construct, '%C', which operates exactly as '%c' does
 except that it counts from one.)
 
++++
 ** New single-line horizontal scrolling mode.
 The 'auto-hscroll-mode' variable can now have a new special value,
 'current-line', which causes only the line where the cursor is
diff --git a/src/xdisp.c b/src/xdisp.c
index f4461c1..eaa701e 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -2890,8 +2890,19 @@ init_iterator (struct it *it, struct window *w,
     }
   else
     {
+      /* When hscrolling only the current line, don't apply the
+        hscroll here, it will be applied by display_line when it gets
+        to laying out the line showing point.  However, if the
+        window's min_hscroll is positive, the user specified a lower
+        bound for automatic hscrolling, so they expect the
+        non-current lines to obey that hscroll amount.  */
       if (hscrolling_current_line_p (w))
-       it->first_visible_x = 0;
+       {
+         if (w->min_hscroll > 0)
+           it->first_visible_x = w->min_hscroll * FRAME_COLUMN_WIDTH (it->f);
+         else
+           it->first_visible_x = 0;
+       }
       else
        it->first_visible_x =
          window_hscroll_limited (w, it->f) * FRAME_COLUMN_WIDTH (it->f);
@@ -13099,7 +13110,9 @@ hscroll_window_tree (Lisp_Object window)
                     that doesn't need to be hscrolled.  If we omit
                     this condition, the line from which we move will
                     remain hscrolled.  */
-                 || (hscl && w->hscroll && !cursor_row->truncated_on_left_p)))
+                 || (hscl
+                     && w->hscroll != w->min_hscroll
+                     && !cursor_row->truncated_on_left_p)))
            {
              struct it it;
              ptrdiff_t hscroll;
@@ -20717,9 +20730,12 @@ display_line (struct it *it, int cursor_vpos)
   recenter_overlay_lists (current_buffer, IT_CHARPOS (*it));
 
   /* If we are going to display the cursor's line, account for the
-     hscroll of that line.  */
+     hscroll of that line.  We subtract the window's min_hscroll,
+     because that was already accounted for in init_iterator.  */
   if (hscroll_this_line)
-    x_incr = window_hscroll_limited (it->w, it->f) * FRAME_COLUMN_WIDTH 
(it->f);
+    x_incr =
+      (window_hscroll_limited (it->w, it->f) - it->w->min_hscroll)
+      * FRAME_COLUMN_WIDTH (it->f);
 
   /* Move over display elements that are not visible because we are
      hscrolled.  This may stop at an x-position < first_visible_x



reply via email to

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