emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] scratch/line-numbers 52bfb7d: Avoid errors in vertical-mot


From: Eli Zaretskii
Subject: [Emacs-diffs] scratch/line-numbers 52bfb7d: Avoid errors in vertical-motion when buffer is narrowed
Date: Mon, 3 Jul 2017 11:57:52 -0400 (EDT)

branch: scratch/line-numbers
commit 52bfb7d4d6595302b5261ff810951e0b3281352c
Author: Eli Zaretskii <address@hidden>
Commit: Eli Zaretskii <address@hidden>

    Avoid errors in vertical-motion when buffer is narrowed
    
    * src/indent.c (Fvertical_motion): If need to start from
    window-start, and it is outside of the accessible portion,
    temporarily widen the buffer.  This avoids errors in evil-mode.
    Reported by James Nguyen <address@hidden>.
---
 src/indent.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/src/indent.c b/src/indent.c
index 2cacfbb..70351f9 100644
--- a/src/indent.c
+++ b/src/indent.c
@@ -2077,11 +2077,24 @@ whether or not it is currently displayed in some 
window.  */)
          && !EQ (Vdisplay_line_numbers, Qvisual))
        {
          struct text_pos wstart;
+         bool saved_restriction = false;
+         ptrdiff_t count1 = SPECPDL_INDEX ();
          SET_TEXT_POS_FROM_MARKER (wstart, w->start);
          itdata = bidi_shelve_cache ();
+         /* We must start from window's start point, but it could be
+            outside the accessible region.  */
+         if (wstart.charpos < BEGV || wstart.charpos > ZV)
+           {
+             record_unwind_protect (save_restriction_restore,
+                                    save_restriction_save ());
+             Fwiden ();
+             saved_restriction = true;
+           }
          start_display (&it, w, wstart);
          move_it_by_lines (&it, 1);
          lnum_width = it.lnum_width;
+         if (saved_restriction)
+           unbind_to (count1, Qnil);
          bidi_unshelve_cache (itdata, 0);
        }
       SET_TEXT_POS (pt, PT, PT_BYTE);



reply via email to

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