aboutsummaryrefslogtreecommitdiffstats
path: root/src/indent.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/indent.c')
-rw-r--r--src/indent.c20
1 files changed, 15 insertions, 5 deletions
diff --git a/src/indent.c b/src/indent.c
index 02d99d14ded..aaeaaf591ef 100644
--- a/src/indent.c
+++ b/src/indent.c
@@ -725,8 +725,7 @@ current_column_1 (void)
725 If END is nil, that stands for the end of STRING. */ 725 If END is nil, that stands for the end of STRING. */
726 726
727static double 727static double
728string_display_width (string, beg, end) 728string_display_width (Lisp_Object string, Lisp_Object beg, Lisp_Object end)
729 Lisp_Object string, beg, end;
730{ 729{
731 register int col; 730 register int col;
732 register unsigned char *ptr, *stop; 731 register unsigned char *ptr, *stop;
@@ -1986,9 +1985,11 @@ whether or not it is currently displayed in some window. */)
1986 struct text_pos pt; 1985 struct text_pos pt;
1987 struct window *w; 1986 struct window *w;
1988 Lisp_Object old_buffer; 1987 Lisp_Object old_buffer;
1989 struct gcpro gcpro1; 1988 EMACS_INT old_charpos IF_LINT (= 0), old_bytepos IF_LINT (= 0);
1989 struct gcpro gcpro1, gcpro2, gcpro3;
1990 Lisp_Object lcols = Qnil; 1990 Lisp_Object lcols = Qnil;
1991 double cols IF_LINT (= 0); 1991 double cols IF_LINT (= 0);
1992 void *itdata = NULL;
1992 1993
1993 /* Allow LINES to be of the form (HPOS . VPOS) aka (COLUMNS . LINES). */ 1994 /* Allow LINES to be of the form (HPOS . VPOS) aka (COLUMNS . LINES). */
1994 if (CONSP (lines) && (NUMBERP (XCAR (lines)))) 1995 if (CONSP (lines) && (NUMBERP (XCAR (lines))))
@@ -2006,12 +2007,16 @@ whether or not it is currently displayed in some window. */)
2006 w = XWINDOW (window); 2007 w = XWINDOW (window);
2007 2008
2008 old_buffer = Qnil; 2009 old_buffer = Qnil;
2009 GCPRO1 (old_buffer); 2010 GCPRO3 (old_buffer, old_charpos, old_bytepos);
2010 if (XBUFFER (w->buffer) != current_buffer) 2011 if (XBUFFER (w->buffer) != current_buffer)
2011 { 2012 {
2012 /* Set the window's buffer temporarily to the current buffer. */ 2013 /* Set the window's buffer temporarily to the current buffer. */
2013 old_buffer = w->buffer; 2014 old_buffer = w->buffer;
2015 old_charpos = XMARKER (w->pointm)->charpos;
2016 old_bytepos = XMARKER (w->pointm)->bytepos;
2014 XSETBUFFER (w->buffer, current_buffer); 2017 XSETBUFFER (w->buffer, current_buffer);
2018 set_marker_both
2019 (w->pointm, w->buffer, BUF_PT (current_buffer), BUF_PT_BYTE (current_buffer));
2015 } 2020 }
2016 2021
2017 if (noninteractive) 2022 if (noninteractive)
@@ -2025,6 +2030,7 @@ whether or not it is currently displayed in some window. */)
2025 EMACS_INT it_start; 2030 EMACS_INT it_start;
2026 int first_x, it_overshoot_expected IF_LINT (= 0); 2031 int first_x, it_overshoot_expected IF_LINT (= 0);
2027 2032
2033 itdata = bidi_shelve_cache ();
2028 SET_TEXT_POS (pt, PT, PT_BYTE); 2034 SET_TEXT_POS (pt, PT, PT_BYTE);
2029 start_display (&it, w, pt); 2035 start_display (&it, w, pt);
2030 first_x = it.first_visible_x; 2036 first_x = it.first_visible_x;
@@ -2129,10 +2135,14 @@ whether or not it is currently displayed in some window. */)
2129 } 2135 }
2130 2136
2131 SET_PT_BOTH (IT_CHARPOS (it), IT_BYTEPOS (it)); 2137 SET_PT_BOTH (IT_CHARPOS (it), IT_BYTEPOS (it));
2138 bidi_unshelve_cache (itdata);
2132 } 2139 }
2133 2140
2134 if (BUFFERP (old_buffer)) 2141 if (BUFFERP (old_buffer))
2135 w->buffer = old_buffer; 2142 {
2143 w->buffer = old_buffer;
2144 set_marker_both (w->pointm, w->buffer, old_charpos, old_bytepos);
2145 }
2136 2146
2137 RETURN_UNGCPRO (make_number (it.vpos)); 2147 RETURN_UNGCPRO (make_number (it.vpos));
2138} 2148}