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 | |
| 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')
| -rw-r--r-- | src/ChangeLog | 12 | ||||
| -rw-r--r-- | src/buffer.h | 16 | ||||
| -rw-r--r-- | src/intervals.c | 73 | ||||
| -rw-r--r-- | src/intervals.h | 4 |
4 files changed, 51 insertions, 54 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 8d077381c8d..633553b4c37 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,5 +1,17 @@ | |||
| 1 | 2008-03-20 Stefan Monnier <monnier@iro.umontreal.ca> | 1 | 2008-03-20 Stefan Monnier <monnier@iro.umontreal.ca> |
| 2 | 2 | ||
| 3 | * intervals.c (temp_set_point, temp_set_point_both): Use EMACS_INT. | ||
| 4 | (set_point, set_point_both): Use EMACS_INT. Remove `buffer' arg, | ||
| 5 | work on current_buffer only instead (that was already the case | ||
| 6 | for some of the code anyway). | ||
| 7 | * buffer.h (set_point, set_point_both): Remove buffer arg, use long int. | ||
| 8 | (temp_set_point, temp_set_point_both): Use EMACS_INT. | ||
| 9 | (SET_PT, SET_PT_BOTH): Adjust. | ||
| 10 | * intervals.h (set_point, temp_set_point, set_point_both) | ||
| 11 | (temp_set_point_both): Remove redundant declarations. | ||
| 12 | |||
| 13 | 2008-03-20 Stefan Monnier <monnier@iro.umontreal.ca> | ||
| 14 | |||
| 3 | * fileio.c (Finsert_file_contents): | 15 | * fileio.c (Finsert_file_contents): |
| 4 | * lread.c (Feval_buffer): Use BUF_TEMP_SET_PT. | 16 | * lread.c (Feval_buffer): Use BUF_TEMP_SET_PT. |
| 5 | * buffer.h (BUF_SET_PT): Remove. set_point_both doesn't work right | 17 | * buffer.h (BUF_SET_PT): Remove. set_point_both doesn't work right |
diff --git a/src/buffer.h b/src/buffer.h index eb1f0a71686..a12e72374ed 100644 --- a/src/buffer.h +++ b/src/buffer.h | |||
| @@ -208,22 +208,22 @@ Boston, MA 02110-1301, USA. */ | |||
| 208 | 208 | ||
| 209 | /* Macros to set PT in the current buffer, or another buffer. */ | 209 | /* Macros to set PT in the current buffer, or another buffer. */ |
| 210 | 210 | ||
| 211 | #define SET_PT(position) (set_point (current_buffer, (position))) | 211 | #define SET_PT(position) (set_point (position)) |
| 212 | #define TEMP_SET_PT(position) (temp_set_point (current_buffer, (position))) | 212 | #define TEMP_SET_PT(position) (temp_set_point (current_buffer, (position))) |
| 213 | 213 | ||
| 214 | #define SET_PT_BOTH(position, byte) \ | 214 | #define SET_PT_BOTH(position, byte) (set_point_both (position, byte)) |
| 215 | (set_point_both (current_buffer, (position), (byte))) | ||
| 216 | #define TEMP_SET_PT_BOTH(position, byte) \ | 215 | #define TEMP_SET_PT_BOTH(position, byte) \ |
| 217 | (temp_set_point_both (current_buffer, (position), (byte))) | 216 | (temp_set_point_both (current_buffer, (position), (byte))) |
| 218 | 217 | ||
| 219 | #define BUF_TEMP_SET_PT(buffer, position) \ | 218 | #define BUF_TEMP_SET_PT(buffer, position) \ |
| 220 | (temp_set_point ((buffer), (position))) | 219 | (temp_set_point ((buffer), (position))) |
| 221 | 220 | ||
| 222 | extern void set_point P_ ((struct buffer *, int)); | 221 | extern void set_point P_ ((EMACS_INT)); |
| 223 | extern INLINE void temp_set_point P_ ((struct buffer *, int)); | 222 | extern INLINE void temp_set_point P_ ((struct buffer *, EMACS_INT)); |
| 224 | extern void set_point_both P_ ((struct buffer *, int, int)); | 223 | extern void set_point_both P_ ((EMACS_INT, EMACS_INT)); |
| 225 | extern INLINE void temp_set_point_both P_ ((struct buffer *, int, int)); | 224 | extern INLINE void temp_set_point_both P_ ((struct buffer *, |
| 226 | extern void enlarge_buffer_text P_ ((struct buffer *, int)); | 225 | EMACS_INT, EMACS_INT)); |
| 226 | extern void enlarge_buffer_text P_ ((struct buffer *, EMACS_INT)); | ||
| 227 | 227 | ||
| 228 | 228 | ||
| 229 | /* Macros for setting the BEGV, ZV or PT of a given buffer. | 229 | /* Macros for setting the BEGV, ZV or PT of a given buffer. |
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 |
diff --git a/src/intervals.h b/src/intervals.h index 228c249f41b..d6bcaa28ee9 100644 --- a/src/intervals.h +++ b/src/intervals.h | |||
| @@ -269,10 +269,6 @@ extern void delete_interval P_ ((INTERVAL)); | |||
| 269 | extern INLINE void offset_intervals P_ ((struct buffer *, int, int)); | 269 | extern INLINE void offset_intervals P_ ((struct buffer *, int, int)); |
| 270 | extern void graft_intervals_into_buffer P_ ((INTERVAL, int, int, | 270 | extern void graft_intervals_into_buffer P_ ((INTERVAL, int, int, |
| 271 | struct buffer *, int)); | 271 | struct buffer *, int)); |
| 272 | extern void set_point P_ ((struct buffer *, int)); | ||
| 273 | extern INLINE void temp_set_point P_ ((struct buffer *, int)); | ||
| 274 | extern void set_point_both P_ ((struct buffer *, int, int)); | ||
| 275 | extern INLINE void temp_set_point_both P_ ((struct buffer *, int, int)); | ||
| 276 | extern void verify_interval_modification P_ ((struct buffer *, int, int)); | 272 | extern void verify_interval_modification P_ ((struct buffer *, int, int)); |
| 277 | extern INTERVAL balance_intervals P_ ((INTERVAL)); | 273 | extern INTERVAL balance_intervals P_ ((INTERVAL)); |
| 278 | extern INLINE void copy_intervals_to_string P_ ((Lisp_Object, struct buffer *, | 274 | extern INLINE void copy_intervals_to_string P_ ((Lisp_Object, struct buffer *, |