Mercurial > emacs
comparison src/xdisp.c @ 39858:13bf107afa6d
(init_iterator): Be more strict with bytepos and charspos.
(DOLIST, LOOP_PROPVAL): New macros.
(invisible_p, invisible_ellipsis_p): Use them.
(invisible_noellipsis_p): New function.
(syms_of_xdisp): Use empty_string.
author | Stefan Monnier <monnier@iro.umontreal.ca> |
---|---|
date | Fri, 12 Oct 2001 22:15:07 +0000 |
parents | dae975f461fa |
children | 91951fb5b9e5 |
comparison
equal
deleted
inserted
replaced
39857:6235c0f8e52c | 39858:13bf107afa6d |
---|---|
708 static int make_cursor_line_fully_visible P_ ((struct window *)); | 708 static int make_cursor_line_fully_visible P_ ((struct window *)); |
709 static int try_scrolling P_ ((Lisp_Object, int, int, int, int)); | 709 static int try_scrolling P_ ((Lisp_Object, int, int, int, int)); |
710 static int try_cursor_movement P_ ((Lisp_Object, struct text_pos, int *)); | 710 static int try_cursor_movement P_ ((Lisp_Object, struct text_pos, int *)); |
711 static int trailing_whitespace_p P_ ((int)); | 711 static int trailing_whitespace_p P_ ((int)); |
712 static int message_log_check_duplicate P_ ((int, int, int, int)); | 712 static int message_log_check_duplicate P_ ((int, int, int, int)); |
713 int invisible_p P_ ((Lisp_Object, Lisp_Object)); | |
714 int invisible_ellipsis_p P_ ((Lisp_Object, Lisp_Object)); | |
715 static void push_it P_ ((struct it *)); | 713 static void push_it P_ ((struct it *)); |
716 static void pop_it P_ ((struct it *)); | 714 static void pop_it P_ ((struct it *)); |
717 static void sync_frame_with_window_matrix_rows P_ ((struct window *)); | 715 static void sync_frame_with_window_matrix_rows P_ ((struct window *)); |
718 static void redisplay_internal P_ ((int)); | 716 static void redisplay_internal P_ ((int)); |
719 static int echo_area_display P_ ((int)); | 717 static int echo_area_display P_ ((int)); |
1427 | 1425 |
1428 /* Initialize IT for displaying current_buffer in window W, starting | 1426 /* Initialize IT for displaying current_buffer in window W, starting |
1429 at character position CHARPOS. CHARPOS < 0 means that no buffer | 1427 at character position CHARPOS. CHARPOS < 0 means that no buffer |
1430 position is specified which is useful when the iterator is assigned | 1428 position is specified which is useful when the iterator is assigned |
1431 a position later. BYTEPOS is the byte position corresponding to | 1429 a position later. BYTEPOS is the byte position corresponding to |
1432 CHARPOS. BYTEPOS <= 0 means compute it from CHARPOS. | 1430 CHARPOS. BYTEPOS < 0 means compute it from CHARPOS. |
1433 | 1431 |
1434 If ROW is not null, calls to produce_glyphs with IT as parameter | 1432 If ROW is not null, calls to produce_glyphs with IT as parameter |
1435 will produce glyphs in that row. | 1433 will produce glyphs in that row. |
1436 | 1434 |
1437 BASE_FACE_ID is the id of a base face to use. It must be one of | 1435 BASE_FACE_ID is the id of a base face to use. It must be one of |
1533 /* Are multibyte characters enabled in current_buffer? */ | 1531 /* Are multibyte characters enabled in current_buffer? */ |
1534 it->multibyte_p = !NILP (current_buffer->enable_multibyte_characters); | 1532 it->multibyte_p = !NILP (current_buffer->enable_multibyte_characters); |
1535 | 1533 |
1536 /* Non-zero if we should highlight the region. */ | 1534 /* Non-zero if we should highlight the region. */ |
1537 highlight_region_p | 1535 highlight_region_p |
1538 = (!NILP (Vtransient_mark_mode) | 1536 = (!NILP (Vtransient_mark_mode) |
1539 && !NILP (current_buffer->mark_active) | 1537 && !NILP (current_buffer->mark_active) |
1540 && XMARKER (current_buffer->mark)->buffer != 0); | 1538 && XMARKER (current_buffer->mark)->buffer != 0); |
1541 | 1539 |
1542 /* Set IT->region_beg_charpos and IT->region_end_charpos to the | 1540 /* Set IT->region_beg_charpos and IT->region_end_charpos to the |
1543 start and end of a visible region in window IT->w. Set both to | 1541 start and end of a visible region in window IT->w. Set both to |
1670 it->start_of_box_run_p = 1; | 1668 it->start_of_box_run_p = 1; |
1671 } | 1669 } |
1672 | 1670 |
1673 /* If a buffer position was specified, set the iterator there, | 1671 /* If a buffer position was specified, set the iterator there, |
1674 getting overlays and face properties from that position. */ | 1672 getting overlays and face properties from that position. */ |
1675 if (charpos > 0) | 1673 if (charpos >= BUF_BEG (current_buffer)) |
1676 { | 1674 { |
1677 it->end_charpos = ZV; | 1675 it->end_charpos = ZV; |
1678 it->face_id = -1; | 1676 it->face_id = -1; |
1679 IT_CHARPOS (*it) = charpos; | 1677 IT_CHARPOS (*it) = charpos; |
1680 | 1678 |
1681 /* Compute byte position if not specified. */ | 1679 /* Compute byte position if not specified. */ |
1682 if (bytepos <= 0) | 1680 if (bytepos < charpos) |
1683 IT_BYTEPOS (*it) = CHAR_TO_BYTE (charpos); | 1681 IT_BYTEPOS (*it) = CHAR_TO_BYTE (charpos); |
1684 else | 1682 else |
1685 IT_BYTEPOS (*it) = bytepos; | 1683 IT_BYTEPOS (*it) = bytepos; |
1686 | 1684 |
1687 /* Compute faces etc. */ | 1685 /* Compute faces etc. */ |
7989 | 7987 |
7990 window_box (w, TEXT_AREA, &text_area_x, &text_area_y, | 7988 window_box (w, TEXT_AREA, &text_area_x, &text_area_y, |
7991 &text_area_width, &text_area_height); | 7989 &text_area_width, &text_area_height); |
7992 | 7990 |
7993 /* Scroll when cursor is inside this scroll margin. */ | 7991 /* Scroll when cursor is inside this scroll margin. */ |
7992 /* Shouldn't we export this `5' for customization ? -stef */ | |
7994 hscroll_margin = 5 * CANON_X_UNIT (XFRAME (w->frame)); | 7993 hscroll_margin = 5 * CANON_X_UNIT (XFRAME (w->frame)); |
7995 | 7994 |
7996 if ((XFASTINT (w->hscroll) | 7995 if ((XFASTINT (w->hscroll) |
7997 && w->cursor.x < hscroll_margin) | 7996 && w->cursor.x < hscroll_margin) |
7998 || (cursor_row->enabled_p | 7997 || (cursor_row->enabled_p |
14499 return it->hpos - hpos_at_start; | 14498 return it->hpos - hpos_at_start; |
14500 } | 14499 } |
14501 | 14500 |
14502 | 14501 |
14503 | 14502 |
14503 #define DOLIST(var, list, code) \ | |
14504 { \ | |
14505 register Lisp_Object tail; \ | |
14506 for (tail = list; CONSP (tail); tail = XCDR (tail)) \ | |
14507 { \ | |
14508 var = XCAR (tail); \ | |
14509 code; \ | |
14510 } \ | |
14511 } | |
14512 | |
14513 /* Loop through the properties in PROPVAL and call CODE for each. | |
14514 CODE can access the current element in `propelt'. */ | |
14515 | |
14516 #define LOOP_PROPVAL(var, propval, code) \ | |
14517 { \ | |
14518 var = (propval); \ | |
14519 code; \ | |
14520 \ | |
14521 if (CONSP (propval)) \ | |
14522 { \ | |
14523 register Lisp_Object tail; \ | |
14524 for (tail = propval; CONSP (tail); tail = XCDR (tail)) \ | |
14525 { \ | |
14526 var = XCAR (tail); \ | |
14527 code; \ | |
14528 } \ | |
14529 } \ | |
14530 return 0; \ | |
14531 } | |
14532 | |
14504 /* This is like a combination of memq and assq. Return 1 if PROPVAL | 14533 /* This is like a combination of memq and assq. Return 1 if PROPVAL |
14505 appears as an element of LIST or as the car of an element of LIST. | 14534 appears as an element of LIST or as the car of an element of LIST. |
14506 If PROPVAL is a list, compare each element against LIST in that | 14535 If PROPVAL is a list, compare each element against LIST in that |
14507 way, and return 1 if any element of PROPVAL is found in LIST. | 14536 way, and return 1 if any element of PROPVAL is found in LIST. |
14508 Otherwise return 0. This function cannot quit. */ | 14537 Otherwise return 0. This function cannot quit. */ |
14510 int | 14539 int |
14511 invisible_p (propval, list) | 14540 invisible_p (propval, list) |
14512 register Lisp_Object propval; | 14541 register Lisp_Object propval; |
14513 Lisp_Object list; | 14542 Lisp_Object list; |
14514 { | 14543 { |
14515 register Lisp_Object tail, proptail; | 14544 register Lisp_Object propelt, tem; |
14516 | 14545 LOOP_PROPVAL (propelt, propval, |
14517 for (tail = list; CONSP (tail); tail = XCDR (tail)) | 14546 DOLIST (tem, list, |
14518 { | 14547 if (EQ (propelt, tem)) |
14519 register Lisp_Object tem; | 14548 return 1; |
14520 tem = XCAR (tail); | 14549 if (CONSP (tem) && EQ (propelt, XCAR (tem))) |
14521 if (EQ (propval, tem)) | 14550 return 1;)); |
14522 return 1; | |
14523 if (CONSP (tem) && EQ (propval, XCAR (tem))) | |
14524 return 1; | |
14525 } | |
14526 | |
14527 if (CONSP (propval)) | |
14528 { | |
14529 for (proptail = propval; CONSP (proptail); proptail = XCDR (proptail)) | |
14530 { | |
14531 Lisp_Object propelt; | |
14532 propelt = XCAR (proptail); | |
14533 for (tail = list; CONSP (tail); tail = XCDR (tail)) | |
14534 { | |
14535 register Lisp_Object tem; | |
14536 tem = XCAR (tail); | |
14537 if (EQ (propelt, tem)) | |
14538 return 1; | |
14539 if (CONSP (tem) && EQ (propelt, XCAR (tem))) | |
14540 return 1; | |
14541 } | |
14542 } | |
14543 } | |
14544 | |
14545 return 0; | |
14546 } | 14551 } |
14547 | 14552 |
14548 | 14553 |
14549 /* Return 1 if PROPVAL appears as the car of an element of LIST and | 14554 /* Return 1 if PROPVAL appears as the car of an element of LIST and |
14550 the cdr of that element is non-nil. If PROPVAL is a list, check | 14555 the cdr of that element is non-nil. If PROPVAL is a list, check |
14555 int | 14560 int |
14556 invisible_ellipsis_p (propval, list) | 14561 invisible_ellipsis_p (propval, list) |
14557 register Lisp_Object propval; | 14562 register Lisp_Object propval; |
14558 Lisp_Object list; | 14563 Lisp_Object list; |
14559 { | 14564 { |
14560 register Lisp_Object tail, proptail; | 14565 register Lisp_Object propelt, tem; |
14561 | 14566 LOOP_PROPVAL (propelt, propval, |
14562 for (tail = list; CONSP (tail); tail = XCDR (tail)) | 14567 DOLIST (tem, list, |
14563 { | 14568 if (CONSP (tem) && EQ (propelt, XCAR (tem))) |
14564 register Lisp_Object tem; | 14569 return !NILP (XCDR (tem)))); |
14565 tem = XCAR (tail); | 14570 } |
14566 if (CONSP (tem) && EQ (propval, XCAR (tem))) | 14571 |
14567 return ! NILP (XCDR (tem)); | 14572 /* As above but for "completely" invisible (no ellipsis). */ |
14568 } | 14573 |
14569 | 14574 int |
14570 if (CONSP (propval)) | 14575 invisible_noellipsis_p (propval, list) |
14571 for (proptail = propval; CONSP (proptail); proptail = XCDR (proptail)) | 14576 register Lisp_Object propval; |
14572 { | 14577 Lisp_Object list; |
14573 Lisp_Object propelt; | 14578 { |
14574 propelt = XCAR (proptail); | 14579 register Lisp_Object propelt, tem; |
14575 for (tail = list; CONSP (tail); tail = XCDR (tail)) | 14580 LOOP_PROPVAL (propelt, propval, |
14576 { | 14581 DOLIST (tem, list, |
14577 register Lisp_Object tem; | 14582 if (EQ (propelt, tem)) |
14578 tem = XCAR (tail); | 14583 return 1; |
14579 if (CONSP (tem) && EQ (propelt, XCAR (tem))) | 14584 if (CONSP (tem) && EQ (propelt, XCAR (tem))) |
14580 return ! NILP (XCDR (tem)); | 14585 return NILP (XCDR (tem)))); |
14581 } | |
14582 } | |
14583 | |
14584 return 0; | |
14585 } | 14586 } |
14586 | 14587 |
14587 | 14588 |
14588 | 14589 |
14589 /*********************************************************************** | 14590 /*********************************************************************** |
14799 \(see `modify-frame-parameters')."); | 14800 \(see `modify-frame-parameters')."); |
14800 Vicon_title_format | 14801 Vicon_title_format |
14801 = Vframe_title_format | 14802 = Vframe_title_format |
14802 = Fcons (intern ("multiple-frames"), | 14803 = Fcons (intern ("multiple-frames"), |
14803 Fcons (build_string ("%b"), | 14804 Fcons (build_string ("%b"), |
14804 Fcons (Fcons (build_string (""), | 14805 Fcons (Fcons (empty_string, |
14805 Fcons (intern ("invocation-name"), | 14806 Fcons (intern ("invocation-name"), |
14806 Fcons (build_string ("@"), | 14807 Fcons (build_string ("@"), |
14807 Fcons (intern ("system-name"), | 14808 Fcons (intern ("system-name"), |
14808 Qnil)))), | 14809 Qnil)))), |
14809 Qnil))); | 14810 Qnil))); |
14854 | 14855 |
14855 DEFVAR_LISP ("fontification-functions", &Vfontification_functions, | 14856 DEFVAR_LISP ("fontification-functions", &Vfontification_functions, |
14856 "List of functions to call to fontify regions of text.\n\ | 14857 "List of functions to call to fontify regions of text.\n\ |
14857 Each function is called with one argument POS. Functions must\n\ | 14858 Each function is called with one argument POS. Functions must\n\ |
14858 fontify a region starting at POS in the current buffer, and give\n\ | 14859 fontify a region starting at POS in the current buffer, and give\n\ |
14859 fontified regions the property `fontified'.\n\ | 14860 fontified regions the property `fontified'."); |
14860 This variable automatically becomes buffer-local when set."); | |
14861 Vfontification_functions = Qnil; | 14861 Vfontification_functions = Qnil; |
14862 Fmake_variable_buffer_local (Qfontification_functions); | 14862 Fmake_variable_buffer_local (Qfontification_functions); |
14863 | 14863 |
14864 DEFVAR_BOOL ("unibyte-display-via-language-environment", | 14864 DEFVAR_BOOL ("unibyte-display-via-language-environment", |
14865 &unibyte_display_via_language_environment, | 14865 &unibyte_display_via_language_environment, |