aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKenichi Handa2011-09-27 11:18:32 +0900
committerKenichi Handa2011-09-27 11:18:32 +0900
commit9aa99d0176c2021194f38eb27668395cd242395f (patch)
tree7a297fd59f2f77833e94d3b0f8ce84d89d3f413c /src
parentdd7aa8dd07c456d5519194c279a808213b63cb3d (diff)
parentd594cb6163558c29797f8fc6939666574ea4a617 (diff)
downloademacs-9aa99d0176c2021194f38eb27668395cd242395f.tar.gz
emacs-9aa99d0176c2021194f38eb27668395cd242395f.zip
merge trunk
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog85
-rw-r--r--src/ChangeLog.112
-rw-r--r--src/bidi.c160
-rw-r--r--src/buffer.c4
-rw-r--r--src/dbusbind.c15
-rw-r--r--src/dispextern.h16
-rw-r--r--src/dispnew.c4
-rw-r--r--src/emacs.c6
-rw-r--r--src/indent.c101
-rw-r--r--src/minibuf.c4
-rw-r--r--src/window.c20
-rw-r--r--src/xdisp.c291
12 files changed, 533 insertions, 175 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 12a45918e87..3282654ab06 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,88 @@
12011-09-25 Michael Albinus <michael.albinus@gmx.de>
2
3 * dbusbind.c (Fdbus_register_signal): When service is not
4 registered, use nil in Vdbus_registered_objects_table. (Bug#9581)
5
62011-09-25 Glenn Morris <rgm@gnu.org>
7
8 * buffer.c (truncate-lines): Doc fix.
9
102011-09-24 Chong Yidong <cyd@stupidchicken.com>
11
12 * window.c (Fwindow_prev_buffers, Fset_window_prev_buffers)
13 (Fset_window_next_buffers): Doc fix.
14
152011-09-24 Glenn Morris <rgm@gnu.org>
16
17 * minibuf.c (read_minibuf): Disable line truncation. (Bug#5715)
18
192011-09-24 Paul Eggert <eggert@cs.ucla.edu>
20
21 Fix minor problems found by static checking.
22 * xdisp.c (string_from_display_spec): Don't assume vecsize fits in int.
23 * indent.c (Fvertical_motion): Fix == vs = typo.
24
252011-09-24 Eli Zaretskii <eliz@gnu.org>
26
27 * dispnew.c (syms_of_display) <redisplay-dont-pause>: Default
28 value is now t. Doc fix.
29
30 * indent.c (Fvertical_motion): Compute and apply the overshoot
31 logic when moving up, not only when moving down. Fix the
32 confusing name and values of the it_overshoot_expected variable;
33 logic changes accordingly. (Bug#9254) (Bug#9549)
34
35 * xdisp.c (pos_visible_p): Produce correct pixel coordinates when
36 CHARPOS is covered by a display string which includes newlines.
37 (move_it_vertically_backward): Avoid inflooping when START_CHARPOS
38 is covered by a display string with embedded newlines.
39
402011-09-24 Michael Albinus <michael.albinus@gmx.de>
41
42 * dbusbind.c (Fdbus_register_signal): Add match rule to
43 Vdbus_registered_objects_table. (Bug#9581)
44 (Fdbus_register_method, Vdbus_registered_objects_table): Fix
45 docstring.
46
472011-09-24 Jim Meyering <meyering@redhat.com>
48
49 do not ignore write error for any output size
50 The previous change was incomplete.
51 While it makes emacs --batch detect the vast majority of stdout
52 write failures, errors were still ignored whenever the output size is
53 k * (BUFSIZ+1) - 4. E.g., on a system with BUFSIZ of 4096,
54 $ emacs --batch --eval '(print (format "%4093d" 0))' > /dev/full \
55 && echo FAIL: ignored write error
56 FAIL: ignored write error
57 $ emacs --batch --eval '(print (format "%20481d" 0))' > /dev/full \
58 && echo FAIL: ignored write error
59 FAIL: ignored write error
60 * emacs.c (Fkill_emacs): Also test ferror. (Bug#9574)
61
622011-09-23 Andreas Schwab <schwab@linux-m68k.org>
63
64 * emacs.c (Fkill_emacs): In noninteractive mode exit
65 non-successfully if a write error occurred on stdout. (Bug#9574)
66
672011-09-21 Eli Zaretskii <eliz@gnu.org>
68
69 * xdisp.c (pop_it): Allow it->object that is a cons cell to pass
70 the xassert test.
71
72 * dispextern.h (struct it): Update the comment documenting what
73 can it->OBJECT be.
74
752011-09-20 Eli Zaretskii <eliz@gnu.org>
76
77 * xdisp.c (set_cursor_from_row): If the row ends in a newline from
78 a display string, extend search for cursor position to end of row.
79 (find_row_edges): If the row ends in a newline from a display
80 string, increment its MATRIX_ROW_END_CHARPOS by one. (Bug#9549)
81 Handle the case of a display string with multiple newlines.
82 (Fcurrent_bidi_paragraph_direction): Fix search for previous
83 non-empty line. Fixes confusing cursor motion with arrow keys at
84 the beginning of a line that starts with whitespace.
85
12011-09-19 Lars Magne Ingebrigtsen <larsi@gnus.org> 862011-09-19 Lars Magne Ingebrigtsen <larsi@gnus.org>
2 87
3 * lread.c (Fread_from_string): Document what FINAL-STRING-INDEX is 88 * lread.c (Fread_from_string): Document what FINAL-STRING-INDEX is
diff --git a/src/ChangeLog.11 b/src/ChangeLog.11
index 6f462e32534..b64736459c8 100644
--- a/src/ChangeLog.11
+++ b/src/ChangeLog.11
@@ -2927,7 +2927,7 @@
2927 * nsimage.m (EmacsImage-setXBMColor:): Correct previous patch: 2927 * nsimage.m (EmacsImage-setXBMColor:): Correct previous patch:
2928 don't change the method signature, change the return. 2928 don't change the method signature, change the return.
2929 2929
29302010-11-04 Ismail Donmez <ismail@namtrac.org> (tiny change) 29302010-11-04 İsmail Dönmez <ismail@namtrac.org> (tiny change)
2931 2931
2932 * nsfont.m (nsfont_draw) 2932 * nsfont.m (nsfont_draw)
2933 * nsimage.m (EmacsImage-setXBMColor:) 2933 * nsimage.m (EmacsImage-setXBMColor:)
diff --git a/src/bidi.c b/src/bidi.c
index 3efdc1590df..599c00449b5 100644
--- a/src/bidi.c
+++ b/src/bidi.c
@@ -222,7 +222,7 @@ bidi_mirror_char (int c)
222static inline void 222static inline void
223bidi_set_sor_type (struct bidi_it *bidi_it, int level_before, int level_after) 223bidi_set_sor_type (struct bidi_it *bidi_it, int level_before, int level_after)
224{ 224{
225 int higher_level = level_before > level_after ? level_before : level_after; 225 int higher_level = (level_before > level_after ? level_before : level_after);
226 226
227 /* The prev_was_pdf gork is required for when we have several PDFs 227 /* The prev_was_pdf gork is required for when we have several PDFs
228 in a row. In that case, we want to compute the sor type for the 228 in a row. In that case, we want to compute the sor type for the
@@ -233,18 +233,18 @@ bidi_set_sor_type (struct bidi_it *bidi_it, int level_before, int level_after)
233 level to which we descend after processing all the PDFs. */ 233 level to which we descend after processing all the PDFs. */
234 if (!bidi_it->prev_was_pdf || level_before < level_after) 234 if (!bidi_it->prev_was_pdf || level_before < level_after)
235 /* FIXME: should the default sor direction be user selectable? */ 235 /* FIXME: should the default sor direction be user selectable? */
236 bidi_it->sor = (higher_level & 1) != 0 ? R2L : L2R; 236 bidi_it->sor = ((higher_level & 1) != 0 ? R2L : L2R);
237 if (level_before > level_after) 237 if (level_before > level_after)
238 bidi_it->prev_was_pdf = 1; 238 bidi_it->prev_was_pdf = 1;
239 239
240 bidi_it->prev.type = UNKNOWN_BT; 240 bidi_it->prev.type = UNKNOWN_BT;
241 bidi_it->last_strong.type = bidi_it->last_strong.type_after_w1 = 241 bidi_it->last_strong.type = bidi_it->last_strong.type_after_w1
242 bidi_it->last_strong.orig_type = UNKNOWN_BT; 242 = bidi_it->last_strong.orig_type = UNKNOWN_BT;
243 bidi_it->prev_for_neutral.type = bidi_it->sor == R2L ? STRONG_R : STRONG_L; 243 bidi_it->prev_for_neutral.type = (bidi_it->sor == R2L ? STRONG_R : STRONG_L);
244 bidi_it->prev_for_neutral.charpos = bidi_it->charpos; 244 bidi_it->prev_for_neutral.charpos = bidi_it->charpos;
245 bidi_it->prev_for_neutral.bytepos = bidi_it->bytepos; 245 bidi_it->prev_for_neutral.bytepos = bidi_it->bytepos;
246 bidi_it->next_for_neutral.type = bidi_it->next_for_neutral.type_after_w1 = 246 bidi_it->next_for_neutral.type = bidi_it->next_for_neutral.type_after_w1
247 bidi_it->next_for_neutral.orig_type = UNKNOWN_BT; 247 = bidi_it->next_for_neutral.orig_type = UNKNOWN_BT;
248 bidi_it->ignore_bn_limit = -1; /* meaning it's unknown */ 248 bidi_it->ignore_bn_limit = -1; /* meaning it's unknown */
249} 249}
250 250
@@ -325,10 +325,10 @@ static int bidi_cache_sp;
325/* Size of header used by bidi_shelve_cache. */ 325/* Size of header used by bidi_shelve_cache. */
326enum 326enum
327 { 327 {
328 bidi_shelve_header_size = 328 bidi_shelve_header_size
329 (sizeof (bidi_cache_idx) + sizeof (bidi_cache_start_stack) 329 = (sizeof (bidi_cache_idx) + sizeof (bidi_cache_start_stack)
330 + sizeof (bidi_cache_sp) + sizeof (bidi_cache_start) 330 + sizeof (bidi_cache_sp) + sizeof (bidi_cache_start)
331 + sizeof (bidi_cache_last_idx)) 331 + sizeof (bidi_cache_last_idx))
332 }; 332 };
333 333
334/* Reset the cache state to the empty state. We only reset the part 334/* Reset the cache state to the empty state. We only reset the part
@@ -353,8 +353,8 @@ bidi_cache_shrink (void)
353{ 353{
354 if (bidi_cache_size > BIDI_CACHE_CHUNK) 354 if (bidi_cache_size > BIDI_CACHE_CHUNK)
355 { 355 {
356 bidi_cache = 356 bidi_cache
357 (struct bidi_it *) xrealloc (bidi_cache, BIDI_CACHE_CHUNK * elsz); 357 = (struct bidi_it *) xrealloc (bidi_cache, BIDI_CACHE_CHUNK * elsz);
358 bidi_cache_size = BIDI_CACHE_CHUNK; 358 bidi_cache_size = BIDI_CACHE_CHUNK;
359 } 359 }
360 bidi_cache_reset (); 360 bidi_cache_reset ();
@@ -490,17 +490,17 @@ bidi_cache_ensure_space (ptrdiff_t idx)
490 { 490 {
491 /* The bidi cache cannot be larger than the largest Lisp string 491 /* The bidi cache cannot be larger than the largest Lisp string
492 or buffer. */ 492 or buffer. */
493 ptrdiff_t string_or_buffer_bound = 493 ptrdiff_t string_or_buffer_bound
494 max (BUF_BYTES_MAX, STRING_BYTES_BOUND); 494 = max (BUF_BYTES_MAX, STRING_BYTES_BOUND);
495 495
496 /* Also, it cannot be larger than what C can represent. */ 496 /* Also, it cannot be larger than what C can represent. */
497 ptrdiff_t c_bound = 497 ptrdiff_t c_bound
498 (min (PTRDIFF_MAX, SIZE_MAX) - bidi_shelve_header_size) / elsz; 498 = (min (PTRDIFF_MAX, SIZE_MAX) - bidi_shelve_header_size) / elsz;
499 499
500 bidi_cache = 500 bidi_cache
501 xpalloc (bidi_cache, &bidi_cache_size, 501 = xpalloc (bidi_cache, &bidi_cache_size,
502 max (BIDI_CACHE_CHUNK, idx - bidi_cache_size + 1), 502 max (BIDI_CACHE_CHUNK, idx - bidi_cache_size + 1),
503 min (string_or_buffer_bound, c_bound), elsz); 503 min (string_or_buffer_bound, c_bound), elsz);
504 } 504 }
505} 505}
506 506
@@ -708,8 +708,8 @@ bidi_unshelve_cache (void *databuf, int just_free)
708 ptrdiff_t idx; 708 ptrdiff_t idx;
709 709
710 memcpy (&idx, p, sizeof (bidi_cache_idx)); 710 memcpy (&idx, p, sizeof (bidi_cache_idx));
711 bidi_cache_total_alloc -= 711 bidi_cache_total_alloc
712 bidi_shelve_header_size + idx * sizeof (struct bidi_it); 712 -= bidi_shelve_header_size + idx * sizeof (struct bidi_it);
713 } 713 }
714 else 714 else
715 { 715 {
@@ -737,8 +737,9 @@ bidi_unshelve_cache (void *databuf, int just_free)
737 + sizeof (bidi_cache_start_stack) + sizeof (bidi_cache_sp) 737 + sizeof (bidi_cache_start_stack) + sizeof (bidi_cache_sp)
738 + sizeof (bidi_cache_start), 738 + sizeof (bidi_cache_start),
739 sizeof (bidi_cache_last_idx)); 739 sizeof (bidi_cache_last_idx));
740 bidi_cache_total_alloc -= 740 bidi_cache_total_alloc
741 bidi_shelve_header_size + bidi_cache_idx * sizeof (struct bidi_it); 741 -= (bidi_shelve_header_size
742 + bidi_cache_idx * sizeof (struct bidi_it));
742 } 743 }
743 744
744 xfree (p); 745 xfree (p);
@@ -813,18 +814,18 @@ bidi_init_it (EMACS_INT charpos, EMACS_INT bytepos, int frame_window_p,
813 bidi_it->type_after_w1 = NEUTRAL_B; 814 bidi_it->type_after_w1 = NEUTRAL_B;
814 bidi_it->orig_type = NEUTRAL_B; 815 bidi_it->orig_type = NEUTRAL_B;
815 bidi_it->prev_was_pdf = 0; 816 bidi_it->prev_was_pdf = 0;
816 bidi_it->prev.type = bidi_it->prev.type_after_w1 = 817 bidi_it->prev.type = bidi_it->prev.type_after_w1
817 bidi_it->prev.orig_type = UNKNOWN_BT; 818 = bidi_it->prev.orig_type = UNKNOWN_BT;
818 bidi_it->last_strong.type = bidi_it->last_strong.type_after_w1 = 819 bidi_it->last_strong.type = bidi_it->last_strong.type_after_w1
819 bidi_it->last_strong.orig_type = UNKNOWN_BT; 820 = bidi_it->last_strong.orig_type = UNKNOWN_BT;
820 bidi_it->next_for_neutral.charpos = -1; 821 bidi_it->next_for_neutral.charpos = -1;
821 bidi_it->next_for_neutral.type = 822 bidi_it->next_for_neutral.type
822 bidi_it->next_for_neutral.type_after_w1 = 823 = bidi_it->next_for_neutral.type_after_w1
823 bidi_it->next_for_neutral.orig_type = UNKNOWN_BT; 824 = bidi_it->next_for_neutral.orig_type = UNKNOWN_BT;
824 bidi_it->prev_for_neutral.charpos = -1; 825 bidi_it->prev_for_neutral.charpos = -1;
825 bidi_it->prev_for_neutral.type = 826 bidi_it->prev_for_neutral.type
826 bidi_it->prev_for_neutral.type_after_w1 = 827 = bidi_it->prev_for_neutral.type_after_w1
827 bidi_it->prev_for_neutral.orig_type = UNKNOWN_BT; 828 = bidi_it->prev_for_neutral.orig_type = UNKNOWN_BT;
828 bidi_it->sor = L2R; /* FIXME: should it be user-selectable? */ 829 bidi_it->sor = L2R; /* FIXME: should it be user-selectable? */
829 bidi_it->disp_pos = -1; /* invalid/unknown */ 830 bidi_it->disp_pos = -1; /* invalid/unknown */
830 bidi_it->disp_prop = 0; 831 bidi_it->disp_prop = 0;
@@ -848,7 +849,7 @@ bidi_line_init (struct bidi_it *bidi_it)
848 bidi_it->next_en_pos = -1; 849 bidi_it->next_en_pos = -1;
849 bidi_it->next_for_ws.type = UNKNOWN_BT; 850 bidi_it->next_for_ws.type = UNKNOWN_BT;
850 bidi_set_sor_type (bidi_it, 851 bidi_set_sor_type (bidi_it,
851 bidi_it->paragraph_dir == R2L ? 1 : 0, 852 (bidi_it->paragraph_dir == R2L ? 1 : 0),
852 bidi_it->level_stack[0].level); /* X10 */ 853 bidi_it->level_stack[0].level); /* X10 */
853 854
854 bidi_cache_reset (); 855 bidi_cache_reset ();
@@ -925,8 +926,8 @@ bidi_fetch_char (EMACS_INT bytepos, EMACS_INT charpos, EMACS_INT *disp_pos,
925 int frame_window_p, EMACS_INT *ch_len, EMACS_INT *nchars) 926 int frame_window_p, EMACS_INT *ch_len, EMACS_INT *nchars)
926{ 927{
927 int ch; 928 int ch;
928 EMACS_INT endpos = 929 EMACS_INT endpos
929 (string->s || STRINGP (string->lstring)) ? string->schars : ZV; 930 = (string->s || STRINGP (string->lstring)) ? string->schars : ZV;
930 struct text_pos pos; 931 struct text_pos pos;
931 932
932 /* If we got past the last known position of display string, compute 933 /* If we got past the last known position of display string, compute
@@ -1173,8 +1174,9 @@ bidi_paragraph_init (bidi_dir_t dir, struct bidi_it *bidi_it, int no_default_p)
1173 we are potentially in a new paragraph that doesn't yet 1174 we are potentially in a new paragraph that doesn't yet
1174 exist. */ 1175 exist. */
1175 pos = bidi_it->charpos; 1176 pos = bidi_it->charpos;
1176 s = STRINGP (bidi_it->string.lstring) ? 1177 s = (STRINGP (bidi_it->string.lstring)
1177 SDATA (bidi_it->string.lstring) : bidi_it->string.s; 1178 ? SDATA (bidi_it->string.lstring)
1179 : bidi_it->string.s);
1178 if (bytepos > begbyte 1180 if (bytepos > begbyte
1179 && bidi_char_at_pos (bytepos, s, bidi_it->string.unibyte) == '\n') 1181 && bidi_char_at_pos (bytepos, s, bidi_it->string.unibyte) == '\n')
1180 { 1182 {
@@ -1324,9 +1326,10 @@ bidi_resolve_explicit_1 (struct bidi_it *bidi_it)
1324 bidi_it->first_elt = 0; 1326 bidi_it->first_elt = 0;
1325 if (string_p) 1327 if (string_p)
1326 { 1328 {
1327 const unsigned char *p = 1329 const unsigned char *p
1328 STRINGP (bidi_it->string.lstring) 1330 = (STRINGP (bidi_it->string.lstring)
1329 ? SDATA (bidi_it->string.lstring) : bidi_it->string.s; 1331 ? SDATA (bidi_it->string.lstring)
1332 : bidi_it->string.s);
1330 1333
1331 if (bidi_it->charpos < 0) 1334 if (bidi_it->charpos < 0)
1332 bidi_it->charpos = 0; 1335 bidi_it->charpos = 0;
@@ -1509,8 +1512,10 @@ bidi_resolve_explicit (struct bidi_it *bidi_it)
1509 int prev_level = bidi_it->level_stack[bidi_it->stack_idx].level; 1512 int prev_level = bidi_it->level_stack[bidi_it->stack_idx].level;
1510 int new_level = bidi_resolve_explicit_1 (bidi_it); 1513 int new_level = bidi_resolve_explicit_1 (bidi_it);
1511 EMACS_INT eob = bidi_it->string.s ? bidi_it->string.schars : ZV; 1514 EMACS_INT eob = bidi_it->string.s ? bidi_it->string.schars : ZV;
1512 const unsigned char *s = STRINGP (bidi_it->string.lstring) 1515 const unsigned char *s
1513 ? SDATA (bidi_it->string.lstring) : bidi_it->string.s; 1516 = (STRINGP (bidi_it->string.lstring)
1517 ? SDATA (bidi_it->string.lstring)
1518 : bidi_it->string.s);
1514 1519
1515 if (prev_level < new_level 1520 if (prev_level < new_level
1516 && bidi_it->type == WEAK_BN 1521 && bidi_it->type == WEAK_BN
@@ -1594,9 +1599,9 @@ bidi_resolve_weak (struct bidi_it *bidi_it)
1594 int next_char; 1599 int next_char;
1595 bidi_type_t type_of_next; 1600 bidi_type_t type_of_next;
1596 struct bidi_it saved_it; 1601 struct bidi_it saved_it;
1597 EMACS_INT eob = 1602 EMACS_INT eob
1598 (STRINGP (bidi_it->string.lstring) || bidi_it->string.s) 1603 = ((STRINGP (bidi_it->string.lstring) || bidi_it->string.s)
1599 ? bidi_it->string.schars : ZV; 1604 ? bidi_it->string.schars : ZV);
1600 1605
1601 type = bidi_it->type; 1606 type = bidi_it->type;
1602 override = bidi_it->level_stack[bidi_it->stack_idx].override; 1607 override = bidi_it->level_stack[bidi_it->stack_idx].override;
@@ -1663,15 +1668,15 @@ bidi_resolve_weak (struct bidi_it *bidi_it)
1663 && bidi_it->prev.orig_type == WEAK_EN) 1668 && bidi_it->prev.orig_type == WEAK_EN)
1664 || bidi_it->prev.type_after_w1 == WEAK_AN))) 1669 || bidi_it->prev.type_after_w1 == WEAK_AN)))
1665 { 1670 {
1666 const unsigned char *s = 1671 const unsigned char *s
1667 STRINGP (bidi_it->string.lstring) 1672 = (STRINGP (bidi_it->string.lstring)
1668 ? SDATA (bidi_it->string.lstring) : bidi_it->string.s; 1673 ? SDATA (bidi_it->string.lstring)
1669 1674 : bidi_it->string.s);
1670 next_char = 1675
1671 bidi_it->charpos + bidi_it->nchars >= eob 1676 next_char = (bidi_it->charpos + bidi_it->nchars >= eob
1672 ? BIDI_EOB 1677 ? BIDI_EOB
1673 : bidi_char_at_pos (bidi_it->bytepos + bidi_it->ch_len, s, 1678 : bidi_char_at_pos (bidi_it->bytepos + bidi_it->ch_len,
1674 bidi_it->string.unibyte); 1679 s, bidi_it->string.unibyte));
1675 type_of_next = bidi_get_type (next_char, override); 1680 type_of_next = bidi_get_type (next_char, override);
1676 1681
1677 if (type_of_next == WEAK_BN 1682 if (type_of_next == WEAK_BN
@@ -1720,17 +1725,17 @@ bidi_resolve_weak (struct bidi_it *bidi_it)
1720 else /* W5: ET/BN with EN after it. */ 1725 else /* W5: ET/BN with EN after it. */
1721 { 1726 {
1722 EMACS_INT en_pos = bidi_it->charpos + bidi_it->nchars; 1727 EMACS_INT en_pos = bidi_it->charpos + bidi_it->nchars;
1723 const unsigned char *s = 1728 const unsigned char *s = (STRINGP (bidi_it->string.lstring)
1724 STRINGP (bidi_it->string.lstring) 1729 ? SDATA (bidi_it->string.lstring)
1725 ? SDATA (bidi_it->string.lstring) : bidi_it->string.s; 1730 : bidi_it->string.s);
1726 1731
1727 if (bidi_it->nchars <= 0) 1732 if (bidi_it->nchars <= 0)
1728 abort (); 1733 abort ();
1729 next_char = 1734 next_char
1730 bidi_it->charpos + bidi_it->nchars >= eob 1735 = (bidi_it->charpos + bidi_it->nchars >= eob
1731 ? BIDI_EOB 1736 ? BIDI_EOB
1732 : bidi_char_at_pos (bidi_it->bytepos + bidi_it->ch_len, s, 1737 : bidi_char_at_pos (bidi_it->bytepos + bidi_it->ch_len, s,
1733 bidi_it->string.unibyte); 1738 bidi_it->string.unibyte));
1734 type_of_next = bidi_get_type (next_char, override); 1739 type_of_next = bidi_get_type (next_char, override);
1735 1740
1736 if (type_of_next == WEAK_ET 1741 if (type_of_next == WEAK_ET
@@ -1875,8 +1880,8 @@ bidi_resolve_neutral (struct bidi_it *bidi_it)
1875 && bidi_get_category (type) != NEUTRAL) 1880 && bidi_get_category (type) != NEUTRAL)
1876 /* This is all per level run, so stop when we 1881 /* This is all per level run, so stop when we
1877 reach the end of this level run. */ 1882 reach the end of this level run. */
1878 || bidi_it->level_stack[bidi_it->stack_idx].level != 1883 || (bidi_it->level_stack[bidi_it->stack_idx].level
1879 current_level)); 1884 != current_level)));
1880 1885
1881 bidi_remember_char (&saved_it.next_for_neutral, bidi_it); 1886 bidi_remember_char (&saved_it.next_for_neutral, bidi_it);
1882 1887
@@ -1971,9 +1976,9 @@ bidi_level_of_next_char (struct bidi_it *bidi_it)
1971 1976
1972 if (bidi_it->scan_dir == 1) 1977 if (bidi_it->scan_dir == 1)
1973 { 1978 {
1974 EMACS_INT eob = 1979 EMACS_INT eob
1975 (bidi_it->string.s || STRINGP (bidi_it->string.lstring)) 1980 = ((bidi_it->string.s || STRINGP (bidi_it->string.lstring))
1976 ? bidi_it->string.schars : ZV; 1981 ? bidi_it->string.schars : ZV);
1977 1982
1978 /* There's no sense in trying to advance if we hit end of text. */ 1983 /* There's no sense in trying to advance if we hit end of text. */
1979 if (bidi_it->charpos >= eob) 1984 if (bidi_it->charpos >= eob)
@@ -2018,9 +2023,8 @@ bidi_level_of_next_char (struct bidi_it *bidi_it)
2018 UNKNOWN_BT. */ 2023 UNKNOWN_BT. */
2019 if (bidi_cache_idx > bidi_cache_start && !bidi_it->first_elt) 2024 if (bidi_cache_idx > bidi_cache_start && !bidi_it->first_elt)
2020 { 2025 {
2021 int bob = 2026 int bob = ((bidi_it->string.s || STRINGP (bidi_it->string.lstring))
2022 (bidi_it->string.s || STRINGP (bidi_it->string.lstring)) ? 0 : 1; 2027 ? 0 : 1);
2023
2024 if (bidi_it->scan_dir > 0) 2028 if (bidi_it->scan_dir > 0)
2025 { 2029 {
2026 if (bidi_it->nchars <= 0) 2030 if (bidi_it->nchars <= 0)
@@ -2345,9 +2349,9 @@ bidi_move_to_visually_next (struct bidi_it *bidi_it)
2345 bidi_it->separator_limit = bidi_it->string.schars; 2349 bidi_it->separator_limit = bidi_it->string.schars;
2346 else if (bidi_it->bytepos < ZV_BYTE) 2350 else if (bidi_it->bytepos < ZV_BYTE)
2347 { 2351 {
2348 EMACS_INT sep_len = 2352 EMACS_INT sep_len
2349 bidi_at_paragraph_end (bidi_it->charpos + bidi_it->nchars, 2353 = bidi_at_paragraph_end (bidi_it->charpos + bidi_it->nchars,
2350 bidi_it->bytepos + bidi_it->ch_len); 2354 bidi_it->bytepos + bidi_it->ch_len);
2351 if (bidi_it->nchars <= 0) 2355 if (bidi_it->nchars <= 0)
2352 abort (); 2356 abort ();
2353 if (sep_len >= 0) 2357 if (sep_len >= 0)
@@ -2355,8 +2359,8 @@ bidi_move_to_visually_next (struct bidi_it *bidi_it)
2355 bidi_it->new_paragraph = 1; 2359 bidi_it->new_paragraph = 1;
2356 /* Record the buffer position of the last character of the 2360 /* Record the buffer position of the last character of the
2357 paragraph separator. */ 2361 paragraph separator. */
2358 bidi_it->separator_limit = 2362 bidi_it->separator_limit
2359 bidi_it->charpos + bidi_it->nchars + sep_len; 2363 = bidi_it->charpos + bidi_it->nchars + sep_len;
2360 } 2364 }
2361 } 2365 }
2362 } 2366 }
diff --git a/src/buffer.c b/src/buffer.c
index 37d2975c8c7..dffdeb536fc 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -5493,7 +5493,9 @@ Instead, give each line of text just one screen line.
5493 5493
5494Note that this is overridden by the variable 5494Note that this is overridden by the variable
5495`truncate-partial-width-windows' if that variable is non-nil 5495`truncate-partial-width-windows' if that variable is non-nil
5496and this buffer is not full-frame width. */); 5496and this buffer is not full-frame width.
5497
5498Minibuffers set this variable to nil. */);
5497 5499
5498 DEFVAR_PER_BUFFER ("word-wrap", &BVAR (current_buffer, word_wrap), Qnil, 5500 DEFVAR_PER_BUFFER ("word-wrap", &BVAR (current_buffer, word_wrap), Qnil,
5499 doc: /* *Non-nil means to use word-wrapping for continuation lines. 5501 doc: /* *Non-nil means to use word-wrapping for continuation lines.
diff --git a/src/dbusbind.c b/src/dbusbind.c
index 227d4e647e9..52e08d8ee2a 100644
--- a/src/dbusbind.c
+++ b/src/dbusbind.c
@@ -2071,13 +2071,7 @@ usage: (dbus-register-signal BUS SERVICE PATH INTERFACE SIGNAL HANDLER &rest ARG
2071 && (SBYTES (service) > 0) 2071 && (SBYTES (service) > 0)
2072 && (strcmp (SSDATA (service), DBUS_SERVICE_DBUS) != 0) 2072 && (strcmp (SSDATA (service), DBUS_SERVICE_DBUS) != 0)
2073 && (strncmp (SSDATA (service), ":", 1) != 0)) 2073 && (strncmp (SSDATA (service), ":", 1) != 0))
2074 { 2074 uname = call2 (intern ("dbus-get-name-owner"), bus, service);
2075 uname = call2 (intern ("dbus-get-name-owner"), bus, service);
2076 /* When there is no unique name, we mark it with an empty
2077 string. */
2078 if (NILP (uname))
2079 uname = empty_unibyte_string;
2080 }
2081 else 2075 else
2082 uname = service; 2076 uname = service;
2083 2077
@@ -2145,7 +2139,7 @@ usage: (dbus-register-signal BUS SERVICE PATH INTERFACE SIGNAL HANDLER &rest ARG
2145 2139
2146 /* Create a hash table entry. */ 2140 /* Create a hash table entry. */
2147 key = list3 (bus, interface, signal); 2141 key = list3 (bus, interface, signal);
2148 key1 = list4 (uname, service, path, handler); 2142 key1 = list5 (uname, service, path, handler, build_string (rule));
2149 value = Fgethash (key, Vdbus_registered_objects_table, Qnil); 2143 value = Fgethash (key, Vdbus_registered_objects_table, Qnil);
2150 2144
2151 if (NILP (Fmember (key1, value))) 2145 if (NILP (Fmember (key1, value)))
@@ -2177,7 +2171,7 @@ When DONT-REGISTER-SERVICE is non-nil, the known name SERVICE is not
2177registered. This means that other D-Bus clients have no way of 2171registered. This means that other D-Bus clients have no way of
2178noticing the newly registered method. When interfaces are constructed 2172noticing the newly registered method. When interfaces are constructed
2179incrementally by adding single methods or properties at a time, 2173incrementally by adding single methods or properties at a time,
2180DONT-REGISTER-SERVICE can be use to prevent other clients from 2174DONT-REGISTER-SERVICE can be used to prevent other clients from
2181discovering the still incomplete interface.*/) 2175discovering the still incomplete interface.*/)
2182 (Lisp_Object bus, Lisp_Object service, Lisp_Object path, 2176 (Lisp_Object bus, Lisp_Object service, Lisp_Object path,
2183 Lisp_Object interface, Lisp_Object method, Lisp_Object handler, 2177 Lisp_Object interface, Lisp_Object method, Lisp_Object handler,
@@ -2319,6 +2313,9 @@ be called when a D-Bus message, which matches the key criteria,
2319arrives (methods and signals), or a cons cell containing the value of 2313arrives (methods and signals), or a cons cell containing the value of
2320the property. 2314the property.
2321 2315
2316For signals, there is also a fifth element RULE, which keeps the match
2317string the signal is registered with.
2318
2322In the second case, the key in the hash table is the list (BUS 2319In the second case, the key in the hash table is the list (BUS
2323SERIAL). BUS is either a Lisp symbol, `:system' or `:session', or a 2320SERIAL). BUS is either a Lisp symbol, `:system' or `:session', or a
2324string denoting the bus address. SERIAL is the serial number of the 2321string denoting the bus address. SERIAL is the serial number of the
diff --git a/src/dispextern.h b/src/dispextern.h
index 65284121588..3c157371ef3 100644
--- a/src/dispextern.h
+++ b/src/dispextern.h
@@ -2398,9 +2398,19 @@ struct it
2398 Lisp_Object font_height; 2398 Lisp_Object font_height;
2399 2399
2400 /* Object and position where the current display element came from. 2400 /* Object and position where the current display element came from.
2401 Object can be a Lisp string in case the current display element 2401 Object is normally the buffer which is being rendered, but it can
2402 comes from an overlay string, or it is buffer. It may also be nil 2402 also be a Lisp string in case the current display element comes
2403 during mode-line update. Position is a position in object. */ 2403 from an overlay string or from a display string (before- or
2404 after-string). It may also be nil when a C string is being
2405 rendered, e.g., during mode-line or header-line update. It can
2406 also be a cons cell of the form `(space ...)', when we produce a
2407 stretch glyph from a `display' specification. Finally, it can be
2408 a zero-valued Lisp integer, but only temporarily, when we are
2409 producing special glyphs for display purposes, like truncation
2410 and continuation glyphs, or blanks that extend each line to the
2411 edge of the window on a TTY.
2412
2413 Position is the current iterator position in object. */
2404 Lisp_Object object; 2414 Lisp_Object object;
2405 struct text_pos position; 2415 struct text_pos position;
2406 2416
diff --git a/src/dispnew.c b/src/dispnew.c
index 958420d3081..51b17fc0f11 100644
--- a/src/dispnew.c
+++ b/src/dispnew.c
@@ -6494,8 +6494,8 @@ See `buffer-display-table' for more information. */);
6494 Vstandard_display_table = Qnil; 6494 Vstandard_display_table = Qnil;
6495 6495
6496 DEFVAR_BOOL ("redisplay-dont-pause", redisplay_dont_pause, 6496 DEFVAR_BOOL ("redisplay-dont-pause", redisplay_dont_pause,
6497 doc: /* *Non-nil means update isn't paused when input is detected. */); 6497 doc: /* *Non-nil means display update isn't paused when input is detected. */);
6498 redisplay_dont_pause = 0; 6498 redisplay_dont_pause = 1;
6499 6499
6500#if PERIODIC_PREEMPTION_CHECKING 6500#if PERIODIC_PREEMPTION_CHECKING
6501 DEFVAR_LISP ("redisplay-preemption-period", Vredisplay_preemption_period, 6501 DEFVAR_LISP ("redisplay-preemption-period", Vredisplay_preemption_period,
diff --git a/src/emacs.c b/src/emacs.c
index 321e7919c93..073156bb0c9 100644
--- a/src/emacs.c
+++ b/src/emacs.c
@@ -1993,6 +1993,7 @@ all of which are called before Emacs is actually killed. */)
1993{ 1993{
1994 struct gcpro gcpro1; 1994 struct gcpro gcpro1;
1995 Lisp_Object hook; 1995 Lisp_Object hook;
1996 int exit_code;
1996 1997
1997 GCPRO1 (arg); 1998 GCPRO1 (arg);
1998 1999
@@ -2017,7 +2018,10 @@ all of which are called before Emacs is actually killed. */)
2017 if (STRINGP (Vauto_save_list_file_name)) 2018 if (STRINGP (Vauto_save_list_file_name))
2018 unlink (SSDATA (Vauto_save_list_file_name)); 2019 unlink (SSDATA (Vauto_save_list_file_name));
2019 2020
2020 exit (INTEGERP (arg) ? XINT (arg) : EXIT_SUCCESS); 2021 exit_code = EXIT_SUCCESS;
2022 if (noninteractive && (fflush (stdout) || ferror (stdout)))
2023 exit_code = EXIT_FAILURE;
2024 exit (INTEGERP (arg) ? XINT (arg) : exit_code);
2021} 2025}
2022 2026
2023 2027
diff --git a/src/indent.c b/src/indent.c
index e00d2152577..a70b7971b96 100644
--- a/src/indent.c
+++ b/src/indent.c
@@ -2019,7 +2019,8 @@ whether or not it is currently displayed in some window. */)
2019 else 2019 else
2020 { 2020 {
2021 EMACS_INT it_start; 2021 EMACS_INT it_start;
2022 int first_x, it_overshoot_expected IF_LINT (= 0); 2022 int first_x, it_overshoot_count = 0;
2023 int overshoot_handled = 0;
2023 2024
2024 itdata = bidi_shelve_cache (); 2025 itdata = bidi_shelve_cache ();
2025 SET_TEXT_POS (pt, PT, PT_BYTE); 2026 SET_TEXT_POS (pt, PT, PT_BYTE);
@@ -2028,22 +2029,23 @@ whether or not it is currently displayed in some window. */)
2028 it_start = IT_CHARPOS (it); 2029 it_start = IT_CHARPOS (it);
2029 2030
2030 /* See comments below for why we calculate this. */ 2031 /* See comments below for why we calculate this. */
2031 if (XINT (lines) > 0) 2032 if (it.cmp_it.id >= 0)
2033 it_overshoot_count = 0;
2034 else if (it.method == GET_FROM_STRING)
2032 { 2035 {
2033 if (it.cmp_it.id >= 0) 2036 const char *s = SSDATA (it.string);
2034 it_overshoot_expected = 1; 2037 const char *e = s + SBYTES (it.string);
2035 else if (it.method == GET_FROM_STRING) 2038 while (s < e)
2036 { 2039 {
2037 const char *s = SSDATA (it.string); 2040 if (*s++ == '\n')
2038 const char *e = s + SBYTES (it.string); 2041 it_overshoot_count++;
2039 while (s < e && *s != '\n')
2040 ++s;
2041 it_overshoot_expected = (s == e) ? -1 : 0;
2042 } 2042 }
2043 else 2043 if (!it_overshoot_count)
2044 it_overshoot_expected = (it.method == GET_FROM_IMAGE 2044 it_overshoot_count = -1;
2045 || it.method == GET_FROM_STRETCH);
2046 } 2045 }
2046 else
2047 it_overshoot_count =
2048 !(it.method == GET_FROM_IMAGE || it.method == GET_FROM_STRETCH);
2047 2049
2048 /* Scan from the start of the line containing PT. If we don't 2050 /* Scan from the start of the line containing PT. If we don't
2049 do this, we start moving with IT->current_x == 0, while PT is 2051 do this, we start moving with IT->current_x == 0, while PT is
@@ -2057,6 +2059,25 @@ whether or not it is currently displayed in some window. */)
2057 tell, and it causes Bug#2694 . -- cyd */ 2059 tell, and it causes Bug#2694 . -- cyd */
2058 move_it_to (&it, PT, -1, -1, -1, MOVE_TO_POS); 2060 move_it_to (&it, PT, -1, -1, -1, MOVE_TO_POS);
2059 2061
2062 /* IT may move too far if truncate-lines is on and PT lies
2063 beyond the right margin. IT may also move too far if the
2064 starting point is on a Lisp string that has embedded
2065 newlines. In these cases, backtrack. */
2066 if (IT_CHARPOS (it) > it_start)
2067 {
2068 /* We need to backtrack also if the Lisp string contains no
2069 newlines, but there is a newline right after it. In this
2070 case, IT overshoots if there is an after-string just
2071 before the newline. */
2072 if (it_overshoot_count < 0
2073 && it.method == GET_FROM_BUFFER
2074 && it.c == '\n')
2075 it_overshoot_count = 1;
2076 if (it_overshoot_count > 0)
2077 move_it_by_lines (&it, -it_overshoot_count);
2078
2079 overshoot_handled = 1;
2080 }
2060 if (XINT (lines) <= 0) 2081 if (XINT (lines) <= 0)
2061 { 2082 {
2062 it.vpos = 0; 2083 it.vpos = 0;
@@ -2065,47 +2086,31 @@ whether or not it is currently displayed in some window. */)
2065 if (XINT (lines) == 0 || IT_CHARPOS (it) > 0) 2086 if (XINT (lines) == 0 || IT_CHARPOS (it) > 0)
2066 move_it_by_lines (&it, max (INT_MIN, XINT (lines))); 2087 move_it_by_lines (&it, max (INT_MIN, XINT (lines)));
2067 } 2088 }
2089 else if (overshoot_handled)
2090 {
2091 it.vpos = 0;
2092 move_it_by_lines (&it, min (INT_MAX, XINT (lines)));
2093 }
2068 else 2094 else
2069 { 2095 {
2070 if (IT_CHARPOS (it) > it_start) 2096 /* Otherwise, we are at the first row occupied by PT, which
2071 { 2097 might span multiple screen lines (e.g., if it's on a
2072 /* IT may move too far if truncate-lines is on and PT 2098 multi-line display string). We want to start from the
2073 lies beyond the right margin. In that case, 2099 last line that it occupies. */
2074 backtrack unless the starting point is on an image, 2100 if (it_start < ZV)
2075 stretch glyph, composition, or Lisp string. */
2076 if (!it_overshoot_expected
2077 /* Also, backtrack if the Lisp string contains no
2078 newline, but there is a newline right after it.
2079 In this case, IT overshoots if there is an
2080 after-string just before the newline. */
2081 || (it_overshoot_expected < 0
2082 && it.method == GET_FROM_BUFFER
2083 && it.c == '\n'))
2084 move_it_by_lines (&it, -1);
2085 it.vpos = 0;
2086 move_it_by_lines (&it, min (INT_MAX, XINT (lines)));
2087 }
2088 else
2089 { 2101 {
2090 /* Otherwise, we are at the first row occupied by PT, 2102 while (IT_CHARPOS (it) <= it_start)
2091 which might span multiple screen lines (e.g., if it's
2092 on a multi-line display string). We want to start
2093 from the last line that it occupies. */
2094 if (it_start < ZV)
2095 {
2096 while (IT_CHARPOS (it) <= it_start)
2097 {
2098 it.vpos = 0;
2099 move_it_by_lines (&it, 1);
2100 }
2101 if (XINT (lines) > 1)
2102 move_it_by_lines (&it, min (INT_MAX, XINT (lines) - 1));
2103 }
2104 else
2105 { 2103 {
2106 it.vpos = 0; 2104 it.vpos = 0;
2107 move_it_by_lines (&it, min (INT_MAX, XINT (lines))); 2105 move_it_by_lines (&it, 1);
2108 } 2106 }
2107 if (XINT (lines) > 1)
2108 move_it_by_lines (&it, min (INT_MAX, XINT (lines) - 1));
2109 }
2110 else
2111 {
2112 it.vpos = 0;
2113 move_it_by_lines (&it, min (INT_MAX, XINT (lines)));
2109 } 2114 }
2110 } 2115 }
2111 2116
diff --git a/src/minibuf.c b/src/minibuf.c
index d3f43b06254..341d544ef51 100644
--- a/src/minibuf.c
+++ b/src/minibuf.c
@@ -559,6 +559,10 @@ read_minibuf (Lisp_Object map, Lisp_Object initial, Lisp_Object prompt,
559 minibuffer = get_minibuffer (minibuf_level); 559 minibuffer = get_minibuffer (minibuf_level);
560 Fset_buffer (minibuffer); 560 Fset_buffer (minibuffer);
561 561
562 /* Defeat (setq-default truncate-lines t), since truncated lines do
563 not work correctly in minibuffers. (Bug#5715, etc) */
564 BVAR (current_buffer, truncate_lines) = Qnil;
565
562 /* If appropriate, copy enable-multibyte-characters into the minibuffer. */ 566 /* If appropriate, copy enable-multibyte-characters into the minibuffer. */
563 if (inherit_input_method) 567 if (inherit_input_method)
564 BVAR (current_buffer, enable_multibyte_characters) = enable_multibyte; 568 BVAR (current_buffer, enable_multibyte_characters) = enable_multibyte;
diff --git a/src/window.c b/src/window.c
index 39210b91616..ba06779846a 100644
--- a/src/window.c
+++ b/src/window.c
@@ -1665,8 +1665,9 @@ DEFUN ("window-prev-buffers", Fwindow_prev_buffers, Swindow_prev_buffers,
1665 doc: /* Return buffers previously shown in WINDOW. 1665 doc: /* Return buffers previously shown in WINDOW.
1666WINDOW must be a live window and defaults to the selected one. 1666WINDOW must be a live window and defaults to the selected one.
1667 1667
1668The return value is either nil or a list of <buffer, window-start, 1668The return value is a list of elements (BUFFER WINDOW-START POS),
1669window-point> triples where buffer was previously shown in WINDOW. */) 1669where BUFFER is a buffer, WINDOW-START is the start position of the
1670window for that buffer, and POS is a window-specific point value. */)
1670 (Lisp_Object window) 1671 (Lisp_Object window)
1671{ 1672{
1672 return decode_window (window)->prev_buffers; 1673 return decode_window (window)->prev_buffers;
@@ -1675,11 +1676,11 @@ window-point> triples where buffer was previously shown in WINDOW. */)
1675DEFUN ("set-window-prev-buffers", Fset_window_prev_buffers, 1676DEFUN ("set-window-prev-buffers", Fset_window_prev_buffers,
1676 Sset_window_prev_buffers, 2, 2, 0, 1677 Sset_window_prev_buffers, 2, 2, 0,
1677 doc: /* Set WINDOW's previous buffers to PREV-BUFFERS. 1678 doc: /* Set WINDOW's previous buffers to PREV-BUFFERS.
1678WINDOW must be a live window and defaults to the selected one. Return 1679WINDOW must be a live window and defaults to the selected one.
1679PREV-BUFFERS.
1680 1680
1681PREV-BUFFERS should be either nil or a list of <buffer, window-start, 1681PREV-BUFFERS should be a list of elements (BUFFER WINDOW-START POS),
1682window-point> triples where buffer was previously shown in WINDOW. */) 1682where BUFFER is a buffer, WINDOW-START is the start position of the
1683window for that buffer, and POS is a window-specific point value. */)
1683 (Lisp_Object window, Lisp_Object prev_buffers) 1684 (Lisp_Object window, Lisp_Object prev_buffers)
1684{ 1685{
1685 return decode_window (window)->prev_buffers = prev_buffers; 1686 return decode_window (window)->prev_buffers = prev_buffers;
@@ -1697,11 +1698,8 @@ WINDOW must be a live window and defaults to the selected one. */)
1697DEFUN ("set-window-next-buffers", Fset_window_next_buffers, 1698DEFUN ("set-window-next-buffers", Fset_window_next_buffers,
1698 Sset_window_next_buffers, 2, 2, 0, 1699 Sset_window_next_buffers, 2, 2, 0,
1699 doc: /* Set WINDOW's next buffers to NEXT-BUFFERS. 1700 doc: /* Set WINDOW's next buffers to NEXT-BUFFERS.
1700WINDOW must be a live window and defaults to the selected one. Return 1701WINDOW must be a live window and defaults to the selected one.
1701NEXT-BUFFERS. 1702NEXT-BUFFERS should be a list of buffers. */)
1702
1703NEXT-BUFFERS should be either nil or a list of buffers that have been
1704recently re-shown in WINDOW. */)
1705 (Lisp_Object window, Lisp_Object next_buffers) 1703 (Lisp_Object window, Lisp_Object next_buffers)
1706{ 1704{
1707 return decode_window (window)->next_buffers = next_buffers; 1705 return decode_window (window)->next_buffers = next_buffers;
diff --git a/src/xdisp.c b/src/xdisp.c
index d58eea538f5..a556236835c 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -1210,6 +1210,34 @@ line_bottom_y (struct it *it)
1210 return line_top_y + line_height; 1210 return line_top_y + line_height;
1211} 1211}
1212 1212
1213/* Subroutine of pos_visible_p below. Extracts a display string, if
1214 any, from the display spec given as its argument. */
1215static Lisp_Object
1216string_from_display_spec (Lisp_Object spec)
1217{
1218 if (CONSP (spec))
1219 {
1220 while (CONSP (spec))
1221 {
1222 if (STRINGP (XCAR (spec)))
1223 return XCAR (spec);
1224 spec = XCDR (spec);
1225 }
1226 }
1227 else if (VECTORP (spec))
1228 {
1229 ptrdiff_t i;
1230
1231 for (i = 0; i < ASIZE (spec); i++)
1232 {
1233 if (STRINGP (AREF (spec, i)))
1234 return AREF (spec, i);
1235 }
1236 return Qnil;
1237 }
1238
1239 return spec;
1240}
1213 1241
1214/* Return 1 if position CHARPOS is visible in window W. 1242/* Return 1 if position CHARPOS is visible in window W.
1215 CHARPOS < 0 means return info about WINDOW_END position. 1243 CHARPOS < 0 means return info about WINDOW_END position.
@@ -1304,6 +1332,136 @@ pos_visible_p (struct window *w, EMACS_INT charpos, int *x, int *y,
1304 } 1332 }
1305 } 1333 }
1306 } 1334 }
1335 else if (IT_CHARPOS (it) != charpos)
1336 {
1337 Lisp_Object cpos = make_number (charpos);
1338 Lisp_Object spec = Fget_char_property (cpos, Qdisplay, Qnil);
1339 Lisp_Object string = string_from_display_spec (spec);
1340 int newline_in_string = 0;
1341
1342 if (STRINGP (string))
1343 {
1344 const char *s = SSDATA (string);
1345 const char *e = s + SBYTES (string);
1346 while (s < e)
1347 {
1348 if (*s++ == '\n')
1349 {
1350 newline_in_string = 1;
1351 break;
1352 }
1353 }
1354 }
1355 /* The tricky code below is needed because there's a
1356 discrepancy between move_it_to and how we set cursor
1357 when the display line ends in a newline from a
1358 display string. move_it_to will stop _after_ such
1359 display strings, whereas set_cursor_from_row
1360 conspires with cursor_row_p to place the cursor on
1361 the first glyph produced from the display string. */
1362
1363 /* We have overshoot PT because it is covered by a
1364 display property whose value is a string. If the
1365 string includes embedded newlines, we are also in the
1366 wrong display line. Backtrack to the correct line,
1367 where the display string begins. */
1368 if (newline_in_string)
1369 {
1370 Lisp_Object startpos, endpos;
1371 EMACS_INT start, end;
1372 struct it it3;
1373
1374 /* Find the first and the last buffer positions
1375 covered by the display string. */
1376 endpos =
1377 Fnext_single_char_property_change (cpos, Qdisplay,
1378 Qnil, Qnil);
1379 startpos =
1380 Fprevious_single_char_property_change (endpos, Qdisplay,
1381 Qnil, Qnil);
1382 start = XFASTINT (startpos);
1383 end = XFASTINT (endpos);
1384 /* Move to the last buffer position before the
1385 display property. */
1386 start_display (&it3, w, top);
1387 move_it_to (&it3, start - 1, -1, -1, -1, MOVE_TO_POS);
1388 /* Move forward one more line if the position before
1389 the display string is a newline or if it is the
1390 rightmost character on a line that is
1391 continued or word-wrapped. */
1392 if (it3.method == GET_FROM_BUFFER
1393 && it3.c == '\n')
1394 move_it_by_lines (&it3, 1);
1395 else if (move_it_in_display_line_to (&it3, -1,
1396 it3.current_x
1397 + it3.pixel_width,
1398 MOVE_TO_X)
1399 == MOVE_LINE_CONTINUED)
1400 {
1401 move_it_by_lines (&it3, 1);
1402 /* When we are under word-wrap, the #$@%!
1403 move_it_by_lines moves 2 lines, so we need to
1404 fix that up. */
1405 if (it3.line_wrap == WORD_WRAP)
1406 move_it_by_lines (&it3, -1);
1407 }
1408
1409 /* Record the vertical coordinate of the display
1410 line where we wound up. */
1411 top_y = it3.current_y;
1412 if (it3.bidi_p)
1413 {
1414 /* When characters are reordered for display,
1415 the character displayed to the left of the
1416 display string could be _after_ the display
1417 property in the logical order. Use the
1418 smallest vertical position of these two. */
1419 start_display (&it3, w, top);
1420 move_it_to (&it3, end + 1, -1, -1, -1, MOVE_TO_POS);
1421 if (it3.current_y < top_y)
1422 top_y = it3.current_y;
1423 }
1424 /* Move from the top of the window to the beginning
1425 of the display line where the display string
1426 begins. */
1427 start_display (&it3, w, top);
1428 move_it_to (&it3, -1, 0, top_y, -1, MOVE_TO_X | MOVE_TO_Y);
1429 /* Finally, advance the iterator until we hit the
1430 first display element whose character position is
1431 CHARPOS, or until the first newline from the
1432 display string, which signals the end of the
1433 display line. */
1434 while (get_next_display_element (&it3))
1435 {
1436 PRODUCE_GLYPHS (&it3);
1437 if (IT_CHARPOS (it3) == charpos
1438 || ITERATOR_AT_END_OF_LINE_P (&it3))
1439 break;
1440 set_iterator_to_next (&it3, 0);
1441 }
1442 top_x = it3.current_x - it3.pixel_width;
1443 /* Normally, we would exit the above loop because we
1444 found the display element whose character
1445 position is CHARPOS. For the contingency that we
1446 didn't, and stopped at the first newline from the
1447 display string, move back over the glyphs
1448 prfoduced from the string, until we find the
1449 rightmost glyph not from the string. */
1450 if (IT_CHARPOS (it3) != charpos && EQ (it3.object, string))
1451 {
1452 struct glyph *g = it3.glyph_row->glyphs[TEXT_AREA]
1453 + it3.glyph_row->used[TEXT_AREA];
1454
1455 while (EQ ((g - 1)->object, string))
1456 {
1457 --g;
1458 top_x -= g->pixel_width;
1459 }
1460 xassert (g < it3.glyph_row->glyphs[TEXT_AREA]
1461 + it3.glyph_row->used[TEXT_AREA]);
1462 }
1463 }
1464 }
1307 1465
1308 *x = top_x; 1466 *x = top_x;
1309 *y = max (top_y + max (0, it.max_ascent - it.ascent), window_top_y); 1467 *y = max (top_y + max (0, it.max_ascent - it.ascent), window_top_y);
@@ -5459,7 +5617,8 @@ pop_it (struct it *it)
5459 && IT_BYTEPOS (*it) == it->bidi_it.bytepos) 5617 && IT_BYTEPOS (*it) == it->bidi_it.bytepos)
5460 || (STRINGP (it->object) 5618 || (STRINGP (it->object)
5461 && IT_STRING_CHARPOS (*it) == it->bidi_it.charpos 5619 && IT_STRING_CHARPOS (*it) == it->bidi_it.charpos
5462 && IT_STRING_BYTEPOS (*it) == it->bidi_it.bytepos)); 5620 && IT_STRING_BYTEPOS (*it) == it->bidi_it.bytepos)
5621 || (CONSP (it->object) && it->method == GET_FROM_STRETCH));
5463 } 5622 }
5464} 5623}
5465 5624
@@ -8520,7 +8679,16 @@ move_it_vertically_backward (struct it *it, int dy)
8520 move_it_to (&it2, start_pos, -1, -1, it2.vpos + 1, 8679 move_it_to (&it2, start_pos, -1, -1, it2.vpos + 1,
8521 MOVE_TO_POS | MOVE_TO_VPOS); 8680 MOVE_TO_POS | MOVE_TO_VPOS);
8522 } 8681 }
8523 while (!IT_POS_VALID_AFTER_MOVE_P (&it2)); 8682 while (!(IT_POS_VALID_AFTER_MOVE_P (&it2)
8683 /* If we are in a display string which starts at START_POS,
8684 and that display string includes a newline, and we are
8685 right after that newline (i.e. at the beginning of a
8686 display line), exit the loop, because otherwise we will
8687 infloop, since move_it_to will see that it is already at
8688 START_POS and will not move. */
8689 || (it2.method == GET_FROM_STRING
8690 && IT_CHARPOS (it2) == start_pos
8691 && SREF (it2.string, IT_STRING_BYTEPOS (it2) - 1) == '\n')));
8524 xassert (IT_CHARPOS (*it) >= BEGV); 8692 xassert (IT_CHARPOS (*it) >= BEGV);
8525 SAVE_IT (it3, it2, it3data); 8693 SAVE_IT (it3, it2, it3data);
8526 8694
@@ -13666,6 +13834,17 @@ set_cursor_from_row (struct window *w, struct glyph_row *row,
13666 13834
13667 x = -1; 13835 x = -1;
13668 13836
13837 /* If the row ends in a newline from a display string,
13838 reordering could have moved the glyphs belonging to the
13839 string out of the [GLYPH_BEFORE..GLYPH_AFTER] range. So
13840 in this case we extend the search to the last glyph in
13841 the row that was not inserted by redisplay. */
13842 if (row->ends_in_newline_from_string_p)
13843 {
13844 glyph_after = end;
13845 pos_after = MATRIX_ROW_END_CHARPOS (row) + delta;
13846 }
13847
13669 /* GLYPH_BEFORE and GLYPH_AFTER are the glyphs that 13848 /* GLYPH_BEFORE and GLYPH_AFTER are the glyphs that
13670 correspond to POS_BEFORE and POS_AFTER, respectively. We 13849 correspond to POS_BEFORE and POS_AFTER, respectively. We
13671 need START and STOP in the order that corresponds to the 13850 need START and STOP in the order that corresponds to the
@@ -18341,7 +18520,8 @@ find_row_edges (struct it *it, struct glyph_row *row,
18341 Line ends in a newline from buffer eol_pos + 1 18520 Line ends in a newline from buffer eol_pos + 1
18342 Line is continued from buffer max_pos + 1 18521 Line is continued from buffer max_pos + 1
18343 Line is truncated on right it->current.pos 18522 Line is truncated on right it->current.pos
18344 Line ends in a newline from string max_pos 18523 Line ends in a newline from string max_pos + 1(*)
18524 (*) + 1 only when line ends in a forward scan
18345 Line is continued from string max_pos 18525 Line is continued from string max_pos
18346 Line is continued from display vector max_pos 18526 Line is continued from display vector max_pos
18347 Line is entirely from a string min_pos == max_pos 18527 Line is entirely from a string min_pos == max_pos
@@ -18354,8 +18534,76 @@ find_row_edges (struct it *it, struct glyph_row *row,
18354 row->maxpos = it->current.pos; 18534 row->maxpos = it->current.pos;
18355 else if (row->used[TEXT_AREA]) 18535 else if (row->used[TEXT_AREA])
18356 { 18536 {
18357 if (row->ends_in_newline_from_string_p) 18537 int seen_this_string = 0;
18358 SET_TEXT_POS (row->maxpos, max_pos, max_bpos); 18538 struct glyph_row *r1 = row - 1;
18539
18540 /* Did we see the same display string on the previous row? */
18541 if (STRINGP (it->object)
18542 /* this is not the first row */
18543 && row > it->w->desired_matrix->rows
18544 /* previous row is not the header line */
18545 && !r1->mode_line_p
18546 /* previous row also ends in a newline from a string */
18547 && r1->ends_in_newline_from_string_p)
18548 {
18549 struct glyph *start, *end;
18550
18551 /* Search for the last glyph of the previous row that came
18552 from buffer or string. Depending on whether the row is
18553 L2R or R2L, we need to process it front to back or the
18554 other way round. */
18555 if (!r1->reversed_p)
18556 {
18557 start = r1->glyphs[TEXT_AREA];
18558 end = start + r1->used[TEXT_AREA];
18559 /* Glyphs inserted by redisplay have an integer (zero)
18560 as their object. */
18561 while (end > start
18562 && INTEGERP ((end - 1)->object)
18563 && (end - 1)->charpos <= 0)
18564 --end;
18565 if (end > start)
18566 {
18567 if (EQ ((end - 1)->object, it->object))
18568 seen_this_string = 1;
18569 }
18570 else
18571 abort ();
18572 }
18573 else
18574 {
18575 end = r1->glyphs[TEXT_AREA] - 1;
18576 start = end + r1->used[TEXT_AREA];
18577 while (end < start
18578 && INTEGERP ((end + 1)->object)
18579 && (end + 1)->charpos <= 0)
18580 ++end;
18581 if (end < start)
18582 {
18583 if (EQ ((end + 1)->object, it->object))
18584 seen_this_string = 1;
18585 }
18586 else
18587 abort ();
18588 }
18589 }
18590 /* Take note of each display string that covers a newline only
18591 once, the first time we see it. This is for when a display
18592 string includes more than one newline in it. */
18593 if (row->ends_in_newline_from_string_p && !seen_this_string)
18594 {
18595 /* If we were scanning the buffer forward when we displayed
18596 the string, we want to account for at least one buffer
18597 position that belongs to this row (position covered by
18598 the display string), so that cursor positioning will
18599 consider this row as a candidate when point is at the end
18600 of the visual line represented by this row. This is not
18601 required when scanning back, because max_pos will already
18602 have a much larger value. */
18603 if (CHARPOS (row->end.pos) > max_pos)
18604 INC_BOTH (max_pos, max_bpos);
18605 SET_TEXT_POS (row->maxpos, max_pos, max_bpos);
18606 }
18359 else if (CHARPOS (it->eol_pos) > 0) 18607 else if (CHARPOS (it->eol_pos) > 0)
18360 SET_TEXT_POS (row->maxpos, 18608 SET_TEXT_POS (row->maxpos,
18361 CHARPOS (it->eol_pos) + 1, BYTEPOS (it->eol_pos) + 1); 18609 CHARPOS (it->eol_pos) + 1, BYTEPOS (it->eol_pos) + 1);
@@ -19125,6 +19373,7 @@ See also `bidi-paragraph-direction'. */)
19125 EMACS_INT pos = BUF_PT (buf); 19373 EMACS_INT pos = BUF_PT (buf);
19126 EMACS_INT bytepos = BUF_PT_BYTE (buf); 19374 EMACS_INT bytepos = BUF_PT_BYTE (buf);
19127 int c; 19375 int c;
19376 void *itb_data = bidi_shelve_cache ();
19128 19377
19129 set_buffer_temp (buf); 19378 set_buffer_temp (buf);
19130 /* bidi_paragraph_init finds the base direction of the paragraph 19379 /* bidi_paragraph_init finds the base direction of the paragraph
@@ -19137,27 +19386,27 @@ See also `bidi-paragraph-direction'. */)
19137 pos--; 19386 pos--;
19138 bytepos = CHAR_TO_BYTE (pos); 19387 bytepos = CHAR_TO_BYTE (pos);
19139 } 19388 }
19140 while ((c = FETCH_BYTE (bytepos)) == '\n' 19389 if (fast_looking_at (build_string ("[\f\t ]*\n"),
19141 || c == ' ' || c == '\t' || c == '\f') 19390 pos, bytepos, ZV, ZV_BYTE, Qnil) > 0)
19142 { 19391 {
19143 if (bytepos <= BEGV_BYTE) 19392 while ((c = FETCH_BYTE (bytepos)) == '\n'
19144 break; 19393 || c == ' ' || c == '\t' || c == '\f')
19145 bytepos--; 19394 {
19146 pos--; 19395 if (bytepos <= BEGV_BYTE)
19396 break;
19397 bytepos--;
19398 pos--;
19399 }
19400 while (!CHAR_HEAD_P (FETCH_BYTE (bytepos)))
19401 bytepos--;
19147 } 19402 }
19148 while (!CHAR_HEAD_P (FETCH_BYTE (bytepos))) 19403 bidi_init_it (pos, bytepos, FRAME_WINDOW_P (SELECTED_FRAME ()), &itb);
19149 bytepos--;
19150 itb.charpos = pos;
19151 itb.bytepos = bytepos;
19152 itb.nchars = -1;
19153 itb.string.s = NULL; 19404 itb.string.s = NULL;
19154 itb.string.lstring = Qnil; 19405 itb.string.lstring = Qnil;
19155 itb.frame_window_p = FRAME_WINDOW_P (SELECTED_FRAME ()); /* guesswork */ 19406 itb.string.bufpos = 0;
19156 itb.first_elt = 1; 19407 itb.string.unibyte = 0;
19157 itb.separator_limit = -1;
19158 itb.paragraph_dir = NEUTRAL_DIR;
19159
19160 bidi_paragraph_init (NEUTRAL_DIR, &itb, 1); 19408 bidi_paragraph_init (NEUTRAL_DIR, &itb, 1);
19409 bidi_unshelve_cache (itb_data, 0);
19161 set_buffer_temp (old); 19410 set_buffer_temp (old);
19162 switch (itb.paragraph_dir) 19411 switch (itb.paragraph_dir)
19163 { 19412 {