diff options
| author | Stefan Monnier | 2008-03-20 18:38:34 +0000 |
|---|---|---|
| committer | Stefan Monnier | 2008-03-20 18:38:34 +0000 |
| commit | 6ba7f443e926fc6c6b2e14f0e4ace5dba1269720 (patch) | |
| tree | d0f13d15f5aab6cafcc9d37c2fd8fb3e5baba5f1 /src/intervals.c | |
| parent | bf1c0f273079b617703d7e875880db85da127493 (diff) | |
| download | emacs-6ba7f443e926fc6c6b2e14f0e4ace5dba1269720.tar.gz emacs-6ba7f443e926fc6c6b2e14f0e4ace5dba1269720.zip | |
* intervals.c (temp_set_point, temp_set_point_both): Use EMACS_INT.
(set_point, set_point_both): Use EMACS_INT. Remove `buffer' arg,
work on current_buffer only instead (that was already the case
for some of the code anyway).
* buffer.h (set_point, set_point_both): Remove buffer arg, use long int.
(temp_set_point, temp_set_point_both): Use EMACS_INT.
(SET_PT, SET_PT_BOTH): Adjust.
* intervals.h (set_point, temp_set_point, set_point_both)
(temp_set_point_both): Remove redundant declarations.
Diffstat (limited to 'src/intervals.c')
| -rw-r--r-- | src/intervals.c | 73 |
1 files changed, 31 insertions, 42 deletions
diff --git a/src/intervals.c b/src/intervals.c index fa40253c0cc..d350d148b8e 100644 --- a/src/intervals.c +++ b/src/intervals.c | |||
| @@ -1926,9 +1926,7 @@ lookup_char_property (plist, prop, textprop) | |||
| 1926 | /* Set point "temporarily", without checking any text properties. */ | 1926 | /* Set point "temporarily", without checking any text properties. */ |
| 1927 | 1927 | ||
| 1928 | INLINE void | 1928 | INLINE void |
| 1929 | temp_set_point (buffer, charpos) | 1929 | temp_set_point (struct buffer *buffer, EMACS_INT charpos) |
| 1930 | struct buffer *buffer; | ||
| 1931 | int charpos; | ||
| 1932 | { | 1930 | { |
| 1933 | temp_set_point_both (buffer, charpos, | 1931 | temp_set_point_both (buffer, charpos, |
| 1934 | buf_charpos_to_bytepos (buffer, charpos)); | 1932 | buf_charpos_to_bytepos (buffer, charpos)); |
| @@ -1938,9 +1936,8 @@ temp_set_point (buffer, charpos) | |||
| 1938 | byte position BYTEPOS. */ | 1936 | byte position BYTEPOS. */ |
| 1939 | 1937 | ||
| 1940 | INLINE void | 1938 | INLINE void |
| 1941 | temp_set_point_both (buffer, charpos, bytepos) | 1939 | temp_set_point_both (struct buffer *buffer, |
| 1942 | int charpos, bytepos; | 1940 | EMACS_INT charpos, EMACS_INT bytepos) |
| 1943 | struct buffer *buffer; | ||
| 1944 | { | 1941 | { |
| 1945 | /* In a single-byte buffer, the two positions must be equal. */ | 1942 | /* In a single-byte buffer, the two positions must be equal. */ |
| 1946 | if (BUF_ZV (buffer) == BUF_ZV_BYTE (buffer) | 1943 | if (BUF_ZV (buffer) == BUF_ZV_BYTE (buffer) |
| @@ -1961,11 +1958,9 @@ temp_set_point_both (buffer, charpos, bytepos) | |||
| 1961 | before an intangible character, move to an ok place. */ | 1958 | before an intangible character, move to an ok place. */ |
| 1962 | 1959 | ||
| 1963 | void | 1960 | void |
| 1964 | set_point (buffer, charpos) | 1961 | set_point (EMACS_INT charpos) |
| 1965 | register struct buffer *buffer; | ||
| 1966 | register int charpos; | ||
| 1967 | { | 1962 | { |
| 1968 | set_point_both (buffer, charpos, buf_charpos_to_bytepos (buffer, charpos)); | 1963 | set_point_both (charpos, buf_charpos_to_bytepos (current_buffer, charpos)); |
| 1969 | } | 1964 | } |
| 1970 | 1965 | ||
| 1971 | /* If there's an invisible character at position POS + TEST_OFFS in the | 1966 | /* If there's an invisible character at position POS + TEST_OFFS in the |
| @@ -2019,72 +2014,66 @@ adjust_for_invis_intang (pos, test_offs, adj, test_intang) | |||
| 2019 | before an intangible character, move to an ok place. */ | 2014 | before an intangible character, move to an ok place. */ |
| 2020 | 2015 | ||
| 2021 | void | 2016 | void |
| 2022 | set_point_both (buffer, charpos, bytepos) | 2017 | set_point_both (EMACS_INT charpos, EMACS_INT bytepos) |
| 2023 | register struct buffer *buffer; | ||
| 2024 | register int charpos, bytepos; | ||
| 2025 | { | 2018 | { |
| 2026 | register INTERVAL to, from, toprev, fromprev; | 2019 | register INTERVAL to, from, toprev, fromprev; |
| 2027 | int buffer_point; | 2020 | EMACS_INT buffer_point; |
| 2028 | int old_position = BUF_PT (buffer); | 2021 | EMACS_INT old_position = PT; |
| 2029 | /* This ensures that we move forward past intangible text when the | 2022 | /* This ensures that we move forward past intangible text when the |
| 2030 | initial position is the same as the destination, in the rare | 2023 | initial position is the same as the destination, in the rare |
| 2031 | instances where this is important, e.g. in line-move-finish | 2024 | instances where this is important, e.g. in line-move-finish |
| 2032 | (simple.el). */ | 2025 | (simple.el). */ |
| 2033 | int backwards = (charpos < old_position ? 1 : 0); | 2026 | int backwards = (charpos < old_position ? 1 : 0); |
| 2034 | int have_overlays; | 2027 | int have_overlays; |
| 2035 | int original_position; | 2028 | EMACS_INT original_position; |
| 2036 | 2029 | ||
| 2037 | buffer->point_before_scroll = Qnil; | 2030 | current_buffer->point_before_scroll = Qnil; |
| 2038 | 2031 | ||
| 2039 | if (charpos == BUF_PT (buffer)) | 2032 | if (charpos == PT) |
| 2040 | return; | 2033 | return; |
| 2041 | 2034 | ||
| 2042 | /* In a single-byte buffer, the two positions must be equal. */ | 2035 | /* In a single-byte buffer, the two positions must be equal. */ |
| 2043 | if (BUF_ZV (buffer) == BUF_ZV_BYTE (buffer) | 2036 | eassert (ZV != ZV_BYTE || charpos == bytepos); |
| 2044 | && charpos != bytepos) | ||
| 2045 | abort (); | ||
| 2046 | 2037 | ||
| 2047 | /* Check this now, before checking if the buffer has any intervals. | 2038 | /* Check this now, before checking if the buffer has any intervals. |
| 2048 | That way, we can catch conditions which break this sanity check | 2039 | That way, we can catch conditions which break this sanity check |
| 2049 | whether or not there are intervals in the buffer. */ | 2040 | whether or not there are intervals in the buffer. */ |
| 2050 | if (charpos > BUF_ZV (buffer) || charpos < BUF_BEGV (buffer)) | 2041 | eassert (charpos <= ZV && charpos >= BEGV); |
| 2051 | abort (); | ||
| 2052 | 2042 | ||
| 2053 | have_overlays = (buffer->overlays_before || buffer->overlays_after); | 2043 | have_overlays = (current_buffer->overlays_before |
| 2044 | || current_buffer->overlays_after); | ||
| 2054 | 2045 | ||
| 2055 | /* If we have no text properties and overlays, | 2046 | /* If we have no text properties and overlays, |
| 2056 | then we can do it quickly. */ | 2047 | then we can do it quickly. */ |
| 2057 | if (NULL_INTERVAL_P (BUF_INTERVALS (buffer)) && ! have_overlays) | 2048 | if (NULL_INTERVAL_P (BUF_INTERVALS (current_buffer)) && ! have_overlays) |
| 2058 | { | 2049 | { |
| 2059 | temp_set_point_both (buffer, charpos, bytepos); | 2050 | temp_set_point_both (current_buffer, charpos, bytepos); |
| 2060 | return; | 2051 | return; |
| 2061 | } | 2052 | } |
| 2062 | 2053 | ||
| 2063 | /* Set TO to the interval containing the char after CHARPOS, | 2054 | /* Set TO to the interval containing the char after CHARPOS, |
| 2064 | and TOPREV to the interval containing the char before CHARPOS. | 2055 | and TOPREV to the interval containing the char before CHARPOS. |
| 2065 | Either one may be null. They may be equal. */ | 2056 | Either one may be null. They may be equal. */ |
| 2066 | to = find_interval (BUF_INTERVALS (buffer), charpos); | 2057 | to = find_interval (BUF_INTERVALS (current_buffer), charpos); |
| 2067 | if (charpos == BUF_BEGV (buffer)) | 2058 | if (charpos == BEGV) |
| 2068 | toprev = 0; | 2059 | toprev = 0; |
| 2069 | else if (to && to->position == charpos) | 2060 | else if (to && to->position == charpos) |
| 2070 | toprev = previous_interval (to); | 2061 | toprev = previous_interval (to); |
| 2071 | else | 2062 | else |
| 2072 | toprev = to; | 2063 | toprev = to; |
| 2073 | 2064 | ||
| 2074 | buffer_point = (BUF_PT (buffer) == BUF_ZV (buffer) | 2065 | buffer_point = (PT == ZV ? ZV - 1 : PT); |
| 2075 | ? BUF_ZV (buffer) - 1 | ||
| 2076 | : BUF_PT (buffer)); | ||
| 2077 | 2066 | ||
| 2078 | /* Set FROM to the interval containing the char after PT, | 2067 | /* Set FROM to the interval containing the char after PT, |
| 2079 | and FROMPREV to the interval containing the char before PT. | 2068 | and FROMPREV to the interval containing the char before PT. |
| 2080 | Either one may be null. They may be equal. */ | 2069 | Either one may be null. They may be equal. */ |
| 2081 | /* We could cache this and save time. */ | 2070 | /* We could cache this and save time. */ |
| 2082 | from = find_interval (BUF_INTERVALS (buffer), buffer_point); | 2071 | from = find_interval (BUF_INTERVALS (current_buffer), buffer_point); |
| 2083 | if (buffer_point == BUF_BEGV (buffer)) | 2072 | if (buffer_point == BEGV) |
| 2084 | fromprev = 0; | 2073 | fromprev = 0; |
| 2085 | else if (from && from->position == BUF_PT (buffer)) | 2074 | else if (from && from->position == PT) |
| 2086 | fromprev = previous_interval (from); | 2075 | fromprev = previous_interval (from); |
| 2087 | else if (buffer_point != BUF_PT (buffer)) | 2076 | else if (buffer_point != PT) |
| 2088 | fromprev = from, from = 0; | 2077 | fromprev = from, from = 0; |
| 2089 | else | 2078 | else |
| 2090 | fromprev = from; | 2079 | fromprev = from; |
| @@ -2093,7 +2082,7 @@ set_point_both (buffer, charpos, bytepos) | |||
| 2093 | if (to == from && toprev == fromprev && INTERVAL_VISIBLE_P (to) | 2082 | if (to == from && toprev == fromprev && INTERVAL_VISIBLE_P (to) |
| 2094 | && ! have_overlays) | 2083 | && ! have_overlays) |
| 2095 | { | 2084 | { |
| 2096 | temp_set_point_both (buffer, charpos, bytepos); | 2085 | temp_set_point_both (current_buffer, charpos, bytepos); |
| 2097 | return; | 2086 | return; |
| 2098 | } | 2087 | } |
| 2099 | 2088 | ||
| @@ -2130,7 +2119,7 @@ set_point_both (buffer, charpos, bytepos) | |||
| 2130 | 2119 | ||
| 2131 | if (! NILP (intangible_propval)) | 2120 | if (! NILP (intangible_propval)) |
| 2132 | { | 2121 | { |
| 2133 | while (XINT (pos) > BUF_BEGV (buffer) | 2122 | while (XINT (pos) > BEGV |
| 2134 | && EQ (Fget_char_property (make_number (XINT (pos) - 1), | 2123 | && EQ (Fget_char_property (make_number (XINT (pos) - 1), |
| 2135 | Qintangible, Qnil), | 2124 | Qintangible, Qnil), |
| 2136 | intangible_propval)) | 2125 | intangible_propval)) |
| @@ -2163,7 +2152,7 @@ set_point_both (buffer, charpos, bytepos) | |||
| 2163 | 2152 | ||
| 2164 | if (! NILP (intangible_propval)) | 2153 | if (! NILP (intangible_propval)) |
| 2165 | { | 2154 | { |
| 2166 | while (XINT (pos) < BUF_ZV (buffer) | 2155 | while (XINT (pos) < ZV |
| 2167 | && EQ (Fget_char_property (pos, Qintangible, Qnil), | 2156 | && EQ (Fget_char_property (pos, Qintangible, Qnil), |
| 2168 | intangible_propval)) | 2157 | intangible_propval)) |
| 2169 | pos = Fnext_char_property_change (pos, Qnil); | 2158 | pos = Fnext_char_property_change (pos, Qnil); |
| @@ -2177,7 +2166,7 @@ set_point_both (buffer, charpos, bytepos) | |||
| 2177 | } | 2166 | } |
| 2178 | } | 2167 | } |
| 2179 | 2168 | ||
| 2180 | bytepos = buf_charpos_to_bytepos (buffer, charpos); | 2169 | bytepos = buf_charpos_to_bytepos (current_buffer, charpos); |
| 2181 | } | 2170 | } |
| 2182 | 2171 | ||
| 2183 | if (charpos != original_position) | 2172 | if (charpos != original_position) |
| @@ -2185,8 +2174,8 @@ set_point_both (buffer, charpos, bytepos) | |||
| 2185 | /* Set TO to the interval containing the char after CHARPOS, | 2174 | /* Set TO to the interval containing the char after CHARPOS, |
| 2186 | and TOPREV to the interval containing the char before CHARPOS. | 2175 | and TOPREV to the interval containing the char before CHARPOS. |
| 2187 | Either one may be null. They may be equal. */ | 2176 | Either one may be null. They may be equal. */ |
| 2188 | to = find_interval (BUF_INTERVALS (buffer), charpos); | 2177 | to = find_interval (BUF_INTERVALS (current_buffer), charpos); |
| 2189 | if (charpos == BUF_BEGV (buffer)) | 2178 | if (charpos == BEGV) |
| 2190 | toprev = 0; | 2179 | toprev = 0; |
| 2191 | else if (to && to->position == charpos) | 2180 | else if (to && to->position == charpos) |
| 2192 | toprev = previous_interval (to); | 2181 | toprev = previous_interval (to); |
| @@ -2198,7 +2187,7 @@ set_point_both (buffer, charpos, bytepos) | |||
| 2198 | and TOPREV is the interval before the stopping point. | 2187 | and TOPREV is the interval before the stopping point. |
| 2199 | One or the other may be null. */ | 2188 | One or the other may be null. */ |
| 2200 | 2189 | ||
| 2201 | temp_set_point_both (buffer, charpos, bytepos); | 2190 | temp_set_point_both (current_buffer, charpos, bytepos); |
| 2202 | 2191 | ||
| 2203 | /* We run point-left and point-entered hooks here, if the | 2192 | /* We run point-left and point-entered hooks here, if the |
| 2204 | two intervals are not equivalent. These hooks take | 2193 | two intervals are not equivalent. These hooks take |