diff options
| author | Thien-Thi Nguyen | 2002-06-03 01:52:02 +0000 |
|---|---|---|
| committer | Thien-Thi Nguyen | 2002-06-03 01:52:02 +0000 |
| commit | 097812fb661072fcf0bdfa38e93cda596ac9b2c2 (patch) | |
| tree | 69b001358f2e84470571d88a3967a7164d943c4c | |
| parent | 2311178e46c8b3bf678e25bb1c88b6c4724d9baa (diff) | |
| download | emacs-097812fb661072fcf0bdfa38e93cda596ac9b2c2.tar.gz emacs-097812fb661072fcf0bdfa38e93cda596ac9b2c2.zip | |
(last_known_column): Now a float.
(current_column_1, position_indentation, current_column,
string_display_width): Return float.
(Fcurrent_column): Cast `current_column' return value to int.
(Fcurrent_indentation): Cast `position_indentation' retval to int.
(indented_beyond_p): Third arg now a float.
(compute_motion, vmotion): Cast `indented_beyond_p' 3rd arg to float.
| -rw-r--r-- | src/indent.c | 78 |
1 files changed, 41 insertions, 37 deletions
diff --git a/src/indent.c b/src/indent.c index e6f6c31a277..521f27f15d3 100644 --- a/src/indent.c +++ b/src/indent.c | |||
| @@ -47,7 +47,7 @@ int indent_tabs_mode; | |||
| 47 | Some things in set last_known_column_point to -1 | 47 | Some things in set last_known_column_point to -1 |
| 48 | to mark the memorized value as invalid. */ | 48 | to mark the memorized value as invalid. */ |
| 49 | 49 | ||
| 50 | int last_known_column; | 50 | float last_known_column; |
| 51 | 51 | ||
| 52 | /* Value of point when current_column was called. */ | 52 | /* Value of point when current_column was called. */ |
| 53 | 53 | ||
| @@ -57,8 +57,8 @@ int last_known_column_point; | |||
| 57 | 57 | ||
| 58 | int last_known_column_modified; | 58 | int last_known_column_modified; |
| 59 | 59 | ||
| 60 | static int current_column_1 P_ ((void)); | 60 | static float current_column_1 P_ ((void)); |
| 61 | static int position_indentation P_ ((int)); | 61 | static float position_indentation P_ ((int)); |
| 62 | 62 | ||
| 63 | /* Cache of beginning of line found by the last call of | 63 | /* Cache of beginning of line found by the last call of |
| 64 | current_column. */ | 64 | current_column. */ |
| @@ -329,6 +329,7 @@ check_composition (pos, pos_byte, point, len, len_byte, width) | |||
| 329 | } \ | 329 | } \ |
| 330 | } while (0) | 330 | } while (0) |
| 331 | 331 | ||
| 332 | |||
| 332 | DEFUN ("current-column", Fcurrent_column, Scurrent_column, 0, 0, 0, | 333 | DEFUN ("current-column", Fcurrent_column, Scurrent_column, 0, 0, 0, |
| 333 | doc: /* Return the horizontal position of point. Beginning of line is column 0. | 334 | doc: /* Return the horizontal position of point. Beginning of line is column 0. |
| 334 | This is calculated by adding together the widths of all the displayed | 335 | This is calculated by adding together the widths of all the displayed |
| @@ -342,7 +343,7 @@ however, ^M is treated as end of line when `selective-display' is t. */) | |||
| 342 | () | 343 | () |
| 343 | { | 344 | { |
| 344 | Lisp_Object temp; | 345 | Lisp_Object temp; |
| 345 | XSETFASTINT (temp, current_column ()); | 346 | XSETFASTINT (temp, (int) current_column ()); /* iftc */ |
| 346 | return temp; | 347 | return temp; |
| 347 | } | 348 | } |
| 348 | 349 | ||
| @@ -354,7 +355,7 @@ invalidate_current_column () | |||
| 354 | last_known_column_point = 0; | 355 | last_known_column_point = 0; |
| 355 | } | 356 | } |
| 356 | 357 | ||
| 357 | int | 358 | float |
| 358 | current_column () | 359 | current_column () |
| 359 | { | 360 | { |
| 360 | register int col; | 361 | register int col; |
| @@ -401,25 +402,25 @@ current_column () | |||
| 401 | { | 402 | { |
| 402 | EMACS_INT i, n; | 403 | EMACS_INT i, n; |
| 403 | Lisp_Object charvec; | 404 | Lisp_Object charvec; |
| 404 | 405 | ||
| 405 | if (ptr == stop) | 406 | if (ptr == stop) |
| 406 | { | 407 | { |
| 407 | /* We stopped either for the beginning of the buffer | 408 | /* We stopped either for the beginning of the buffer |
| 408 | or for the gap. */ | 409 | or for the gap. */ |
| 409 | if (ptr == BEGV_ADDR) | 410 | if (ptr == BEGV_ADDR) |
| 410 | break; | 411 | break; |
| 411 | 412 | ||
| 412 | /* It was the gap. Jump back over it. */ | 413 | /* It was the gap. Jump back over it. */ |
| 413 | stop = BEGV_ADDR; | 414 | stop = BEGV_ADDR; |
| 414 | ptr = GPT_ADDR; | 415 | ptr = GPT_ADDR; |
| 415 | 416 | ||
| 416 | /* Check whether that brings us to beginning of buffer. */ | 417 | /* Check whether that brings us to beginning of buffer. */ |
| 417 | if (BEGV >= GPT) | 418 | if (BEGV >= GPT) |
| 418 | break; | 419 | break; |
| 419 | } | 420 | } |
| 420 | 421 | ||
| 421 | c = *--ptr; | 422 | c = *--ptr; |
| 422 | 423 | ||
| 423 | if (dp && VECTORP (DISP_CHAR_VECTOR (dp, c))) | 424 | if (dp && VECTORP (DISP_CHAR_VECTOR (dp, c))) |
| 424 | { | 425 | { |
| 425 | charvec = DISP_CHAR_VECTOR (dp, c); | 426 | charvec = DISP_CHAR_VECTOR (dp, c); |
| @@ -430,7 +431,7 @@ current_column () | |||
| 430 | charvec = Qnil; | 431 | charvec = Qnil; |
| 431 | n = 1; | 432 | n = 1; |
| 432 | } | 433 | } |
| 433 | 434 | ||
| 434 | for (i = n - 1; i >= 0; --i) | 435 | for (i = n - 1; i >= 0; --i) |
| 435 | { | 436 | { |
| 436 | if (VECTORP (charvec)) | 437 | if (VECTORP (charvec)) |
| @@ -438,14 +439,14 @@ current_column () | |||
| 438 | /* This should be handled the same as | 439 | /* This should be handled the same as |
| 439 | next_element_from_display_vector does it. */ | 440 | next_element_from_display_vector does it. */ |
| 440 | Lisp_Object entry = AREF (charvec, i); | 441 | Lisp_Object entry = AREF (charvec, i); |
| 441 | 442 | ||
| 442 | if (INTEGERP (entry) | 443 | if (INTEGERP (entry) |
| 443 | && GLYPH_CHAR_VALID_P (XFASTINT (entry))) | 444 | && GLYPH_CHAR_VALID_P (XFASTINT (entry))) |
| 444 | c = FAST_GLYPH_CHAR (XFASTINT (entry)); | 445 | c = FAST_GLYPH_CHAR (XFASTINT (entry)); |
| 445 | else | 446 | else |
| 446 | c = ' '; | 447 | c = ' '; |
| 447 | } | 448 | } |
| 448 | 449 | ||
| 449 | if (c >= 040 && c < 0177) | 450 | if (c >= 040 && c < 0177) |
| 450 | col++; | 451 | col++; |
| 451 | else if (c == '\n' | 452 | else if (c == '\n' |
| @@ -459,7 +460,7 @@ current_column () | |||
| 459 | { | 460 | { |
| 460 | if (tab_seen) | 461 | if (tab_seen) |
| 461 | col = ((col + tab_width) / tab_width) * tab_width; | 462 | col = ((col + tab_width) / tab_width) * tab_width; |
| 462 | 463 | ||
| 463 | post_tab += col; | 464 | post_tab += col; |
| 464 | col = 0; | 465 | col = 0; |
| 465 | tab_seen = 1; | 466 | tab_seen = 1; |
| @@ -501,7 +502,7 @@ current_column () | |||
| 501 | This function handles characters that are invisible | 502 | This function handles characters that are invisible |
| 502 | due to text properties or overlays. */ | 503 | due to text properties or overlays. */ |
| 503 | 504 | ||
| 504 | static int | 505 | static float |
| 505 | current_column_1 () | 506 | current_column_1 () |
| 506 | { | 507 | { |
| 507 | register int tab_width = XINT (current_buffer->tab_width); | 508 | register int tab_width = XINT (current_buffer->tab_width); |
| @@ -615,7 +616,7 @@ current_column_1 () | |||
| 615 | { | 616 | { |
| 616 | unsigned char *ptr; | 617 | unsigned char *ptr; |
| 617 | int bytes, width, wide_column; | 618 | int bytes, width, wide_column; |
| 618 | 619 | ||
| 619 | ptr = BYTE_POS_ADDR (scan_byte); | 620 | ptr = BYTE_POS_ADDR (scan_byte); |
| 620 | MULTIBYTE_BYTES_WIDTH (ptr, dp); | 621 | MULTIBYTE_BYTES_WIDTH (ptr, dp); |
| 621 | scan_byte += bytes; | 622 | scan_byte += bytes; |
| @@ -651,7 +652,7 @@ current_column_1 () | |||
| 651 | If BEG is nil, that stands for the beginning of STRING. | 652 | If BEG is nil, that stands for the beginning of STRING. |
| 652 | If END is nil, that stands for the end of STRING. */ | 653 | If END is nil, that stands for the end of STRING. */ |
| 653 | 654 | ||
| 654 | static int | 655 | static float |
| 655 | string_display_width (string, beg, end) | 656 | string_display_width (string, beg, end) |
| 656 | Lisp_Object string, beg, end; | 657 | Lisp_Object string, beg, end; |
| 657 | { | 658 | { |
| @@ -777,7 +778,7 @@ even if that goes past COLUMN; by default, MININUM is zero. */) | |||
| 777 | } | 778 | } |
| 778 | 779 | ||
| 779 | 780 | ||
| 780 | static int position_indentation P_ ((int)); | 781 | static float position_indentation P_ ((int)); |
| 781 | 782 | ||
| 782 | DEFUN ("current-indentation", Fcurrent_indentation, Scurrent_indentation, | 783 | DEFUN ("current-indentation", Fcurrent_indentation, Scurrent_indentation, |
| 783 | 0, 0, 0, | 784 | 0, 0, 0, |
| @@ -791,12 +792,12 @@ following any initial whitespace. */) | |||
| 791 | 792 | ||
| 792 | scan_newline (PT, PT_BYTE, BEGV, BEGV_BYTE, -1, 1); | 793 | scan_newline (PT, PT_BYTE, BEGV, BEGV_BYTE, -1, 1); |
| 793 | 794 | ||
| 794 | XSETFASTINT (val, position_indentation (PT_BYTE)); | 795 | XSETFASTINT (val, (int) position_indentation (PT_BYTE)); /* iftc */ |
| 795 | SET_PT_BOTH (opoint, opoint_byte); | 796 | SET_PT_BOTH (opoint, opoint_byte); |
| 796 | return val; | 797 | return val; |
| 797 | } | 798 | } |
| 798 | 799 | ||
| 799 | static int | 800 | static float |
| 800 | position_indentation (pos_byte) | 801 | position_indentation (pos_byte) |
| 801 | register int pos_byte; | 802 | register int pos_byte; |
| 802 | { | 803 | { |
| @@ -846,7 +847,7 @@ position_indentation (pos_byte) | |||
| 846 | /* The -1 and +1 arrange to point at the first byte of gap | 847 | /* The -1 and +1 arrange to point at the first byte of gap |
| 847 | (if STOP_POS_BYTE is the position of the gap) | 848 | (if STOP_POS_BYTE is the position of the gap) |
| 848 | rather than at the data after the gap. */ | 849 | rather than at the data after the gap. */ |
| 849 | 850 | ||
| 850 | stop = BYTE_POS_ADDR (stop_pos_byte - 1) + 1; | 851 | stop = BYTE_POS_ADDR (stop_pos_byte - 1) + 1; |
| 851 | p = BYTE_POS_ADDR (pos_byte); | 852 | p = BYTE_POS_ADDR (pos_byte); |
| 852 | } | 853 | } |
| @@ -888,9 +889,10 @@ position_indentation (pos_byte) | |||
| 888 | 889 | ||
| 889 | int | 890 | int |
| 890 | indented_beyond_p (pos, pos_byte, column) | 891 | indented_beyond_p (pos, pos_byte, column) |
| 891 | int pos, pos_byte, column; | 892 | int pos, pos_byte; |
| 893 | float column; | ||
| 892 | { | 894 | { |
| 893 | int val; | 895 | float val; |
| 894 | int opoint = PT, opoint_byte = PT_BYTE; | 896 | int opoint = PT, opoint_byte = PT_BYTE; |
| 895 | 897 | ||
| 896 | SET_PT_BOTH (pos, pos_byte); | 898 | SET_PT_BOTH (pos, pos_byte); |
| @@ -899,7 +901,7 @@ indented_beyond_p (pos, pos_byte, column) | |||
| 899 | 901 | ||
| 900 | val = position_indentation (PT_BYTE); | 902 | val = position_indentation (PT_BYTE); |
| 901 | SET_PT_BOTH (opoint, opoint_byte); | 903 | SET_PT_BOTH (opoint, opoint_byte); |
| 902 | return val >= column; | 904 | return val >= column; /* hmm, float comparison */ |
| 903 | } | 905 | } |
| 904 | 906 | ||
| 905 | DEFUN ("move-to-column", Fmove_to_column, Smove_to_column, 1, 2, "p", | 907 | DEFUN ("move-to-column", Fmove_to_column, Smove_to_column, 1, 2, "p", |
| @@ -1093,7 +1095,7 @@ The return value is the current column. */) | |||
| 1093 | goal_pt_byte = PT_BYTE; | 1095 | goal_pt_byte = PT_BYTE; |
| 1094 | Findent_to (make_number (col), Qnil); | 1096 | Findent_to (make_number (col), Qnil); |
| 1095 | SET_PT_BOTH (goal_pt, goal_pt_byte); | 1097 | SET_PT_BOTH (goal_pt, goal_pt_byte); |
| 1096 | 1098 | ||
| 1097 | /* Set the last_known... vars consistently. */ | 1099 | /* Set the last_known... vars consistently. */ |
| 1098 | col = goal; | 1100 | col = goal; |
| 1099 | } | 1101 | } |
| @@ -1352,7 +1354,7 @@ compute_motion (from, fromvpos, fromhpos, did_motion, to, tovpos, tohpos, width, | |||
| 1352 | W_ ^---- next after the point | 1354 | W_ ^---- next after the point |
| 1353 | ^---- next char. after the point. | 1355 | ^---- next char. after the point. |
| 1354 | ---------- | 1356 | ---------- |
| 1355 | In case of wide-column character | 1357 | In case of wide-column character |
| 1356 | 1358 | ||
| 1357 | The problem here is continuation at a wide-column character. | 1359 | The problem here is continuation at a wide-column character. |
| 1358 | In this case, the line may shorter less than WIDTH. | 1360 | In this case, the line may shorter less than WIDTH. |
| @@ -1522,7 +1524,7 @@ compute_motion (from, fromvpos, fromhpos, did_motion, to, tovpos, tohpos, width, | |||
| 1522 | { | 1524 | { |
| 1523 | EMACS_INT i, n; | 1525 | EMACS_INT i, n; |
| 1524 | Lisp_Object charvec; | 1526 | Lisp_Object charvec; |
| 1525 | 1527 | ||
| 1526 | c = FETCH_BYTE (pos_byte); | 1528 | c = FETCH_BYTE (pos_byte); |
| 1527 | 1529 | ||
| 1528 | /* Check composition sequence. */ | 1530 | /* Check composition sequence. */ |
| @@ -1588,14 +1590,14 @@ compute_motion (from, fromvpos, fromhpos, did_motion, to, tovpos, tohpos, width, | |||
| 1588 | /* This should be handled the same as | 1590 | /* This should be handled the same as |
| 1589 | next_element_from_display_vector does it. */ | 1591 | next_element_from_display_vector does it. */ |
| 1590 | Lisp_Object entry = AREF (charvec, i); | 1592 | Lisp_Object entry = AREF (charvec, i); |
| 1591 | 1593 | ||
| 1592 | if (INTEGERP (entry) | 1594 | if (INTEGERP (entry) |
| 1593 | && GLYPH_CHAR_VALID_P (XFASTINT (entry))) | 1595 | && GLYPH_CHAR_VALID_P (XFASTINT (entry))) |
| 1594 | c = FAST_GLYPH_CHAR (XFASTINT (entry)); | 1596 | c = FAST_GLYPH_CHAR (XFASTINT (entry)); |
| 1595 | else | 1597 | else |
| 1596 | c = ' '; | 1598 | c = ' '; |
| 1597 | } | 1599 | } |
| 1598 | 1600 | ||
| 1599 | if (c >= 040 && c < 0177) | 1601 | if (c >= 040 && c < 0177) |
| 1600 | hpos++; | 1602 | hpos++; |
| 1601 | else if (c == '\t') | 1603 | else if (c == '\t') |
| @@ -1609,7 +1611,8 @@ compute_motion (from, fromvpos, fromhpos, did_motion, to, tovpos, tohpos, width, | |||
| 1609 | else if (c == '\n') | 1611 | else if (c == '\n') |
| 1610 | { | 1612 | { |
| 1611 | if (selective > 0 | 1613 | if (selective > 0 |
| 1612 | && indented_beyond_p (pos, pos_byte, selective)) | 1614 | && indented_beyond_p (pos, pos_byte, |
| 1615 | (float) selective)) /* iftc */ | ||
| 1613 | { | 1616 | { |
| 1614 | /* If (pos == to), we don't have to take care of | 1617 | /* If (pos == to), we don't have to take care of |
| 1615 | selective display. */ | 1618 | selective display. */ |
| @@ -1624,7 +1627,8 @@ compute_motion (from, fromvpos, fromhpos, did_motion, to, tovpos, tohpos, width, | |||
| 1624 | pos_byte = CHAR_TO_BYTE (pos); | 1627 | pos_byte = CHAR_TO_BYTE (pos); |
| 1625 | } | 1628 | } |
| 1626 | while (pos < to | 1629 | while (pos < to |
| 1627 | && indented_beyond_p (pos, pos_byte, selective)); | 1630 | && indented_beyond_p (pos, pos_byte, |
| 1631 | (float) selective)); /* iftc */ | ||
| 1628 | /* Allow for the " ..." that is displayed for them. */ | 1632 | /* Allow for the " ..." that is displayed for them. */ |
| 1629 | if (selective_rlen) | 1633 | if (selective_rlen) |
| 1630 | { | 1634 | { |
| @@ -1874,7 +1878,7 @@ vmotion (from, vtarget, w) | |||
| 1874 | && ((selective > 0 | 1878 | && ((selective > 0 |
| 1875 | && indented_beyond_p (XFASTINT (prevline), | 1879 | && indented_beyond_p (XFASTINT (prevline), |
| 1876 | CHAR_TO_BYTE (XFASTINT (prevline)), | 1880 | CHAR_TO_BYTE (XFASTINT (prevline)), |
| 1877 | selective)) | 1881 | (float) selective)) /* iftc */ |
| 1878 | /* watch out for newlines with `invisible' property */ | 1882 | /* watch out for newlines with `invisible' property */ |
| 1879 | || (propval = Fget_char_property (prevline, | 1883 | || (propval = Fget_char_property (prevline, |
| 1880 | Qinvisible, | 1884 | Qinvisible, |
| @@ -1887,7 +1891,7 @@ vmotion (from, vtarget, w) | |||
| 1887 | lmargin + (XFASTINT (prevline) == BEG | 1891 | lmargin + (XFASTINT (prevline) == BEG |
| 1888 | ? start_hpos : 0), | 1892 | ? start_hpos : 0), |
| 1889 | 0, | 1893 | 0, |
| 1890 | from, | 1894 | from, |
| 1891 | /* Don't care for VPOS... */ | 1895 | /* Don't care for VPOS... */ |
| 1892 | 1 << (BITS_PER_SHORT - 1), | 1896 | 1 << (BITS_PER_SHORT - 1), |
| 1893 | /* ... nor HPOS. */ | 1897 | /* ... nor HPOS. */ |
| @@ -1934,7 +1938,7 @@ vmotion (from, vtarget, w) | |||
| 1934 | && ((selective > 0 | 1938 | && ((selective > 0 |
| 1935 | && indented_beyond_p (XFASTINT (prevline), | 1939 | && indented_beyond_p (XFASTINT (prevline), |
| 1936 | CHAR_TO_BYTE (XFASTINT (prevline)), | 1940 | CHAR_TO_BYTE (XFASTINT (prevline)), |
| 1937 | selective)) | 1941 | (float) selective)) /* iftc */ |
| 1938 | /* watch out for newlines with `invisible' property */ | 1942 | /* watch out for newlines with `invisible' property */ |
| 1939 | || (propval = Fget_char_property (prevline, Qinvisible, | 1943 | || (propval = Fget_char_property (prevline, Qinvisible, |
| 1940 | text_prop_object), | 1944 | text_prop_object), |
| @@ -1946,7 +1950,7 @@ vmotion (from, vtarget, w) | |||
| 1946 | lmargin + (XFASTINT (prevline) == BEG | 1950 | lmargin + (XFASTINT (prevline) == BEG |
| 1947 | ? start_hpos : 0), | 1951 | ? start_hpos : 0), |
| 1948 | 0, | 1952 | 0, |
| 1949 | from, | 1953 | from, |
| 1950 | /* Don't care for VPOS... */ | 1954 | /* Don't care for VPOS... */ |
| 1951 | 1 << (BITS_PER_SHORT - 1), | 1955 | 1 << (BITS_PER_SHORT - 1), |
| 1952 | /* ... nor HPOS. */ | 1956 | /* ... nor HPOS. */ |
| @@ -2015,7 +2019,7 @@ whether or not it is currently displayed in some window. */) | |||
| 2015 | old_buffer = w->buffer; | 2019 | old_buffer = w->buffer; |
| 2016 | XSETBUFFER (w->buffer, current_buffer); | 2020 | XSETBUFFER (w->buffer, current_buffer); |
| 2017 | } | 2021 | } |
| 2018 | 2022 | ||
| 2019 | SET_TEXT_POS (pt, PT, PT_BYTE); | 2023 | SET_TEXT_POS (pt, PT, PT_BYTE); |
| 2020 | start_display (&it, w, pt); | 2024 | start_display (&it, w, pt); |
| 2021 | 2025 | ||
| @@ -2028,12 +2032,12 @@ whether or not it is currently displayed in some window. */) | |||
| 2028 | 2032 | ||
| 2029 | if (XINT (lines) != 0) | 2033 | if (XINT (lines) != 0) |
| 2030 | move_it_by_lines (&it, XINT (lines), 0); | 2034 | move_it_by_lines (&it, XINT (lines), 0); |
| 2031 | 2035 | ||
| 2032 | SET_PT_BOTH (IT_CHARPOS (it), IT_BYTEPOS (it)); | 2036 | SET_PT_BOTH (IT_CHARPOS (it), IT_BYTEPOS (it)); |
| 2033 | 2037 | ||
| 2034 | if (BUFFERP (old_buffer)) | 2038 | if (BUFFERP (old_buffer)) |
| 2035 | w->buffer = old_buffer; | 2039 | w->buffer = old_buffer; |
| 2036 | 2040 | ||
| 2037 | RETURN_UNGCPRO (make_number (it.vpos)); | 2041 | RETURN_UNGCPRO (make_number (it.vpos)); |
| 2038 | } | 2042 | } |
| 2039 | 2043 | ||