comparison src/intervals.c @ 29278:fcb030c7708e

(get_local_map): Extra arg to allow looking for `keymap' too.
author Dave Love <fx@gnu.org>
date Mon, 29 May 2000 11:41:13 +0000
parents 451721e784a8
children c3435dc00ed7
comparison
equal deleted inserted replaced
29277:6f7f86b93247 29278:fcb030c7708e
2159 *end = i->position + LENGTH (i); 2159 *end = i->position + LENGTH (i);
2160 2160
2161 return 1; 2161 return 1;
2162 } 2162 }
2163 2163
2164 /* Return the proper local map for position POSITION in BUFFER. 2164 /* If TYPE is `keymap', return the map specified by the `keymap'
2165 Use the map specified by the local-map property, if any. 2165 property at POSITION in BUFFER or nil.
2166
2167 Otherwise return the proper local map for position POSITION in
2168 BUFFER. Use the map specified by the local-map property, if any.
2166 Otherwise, use BUFFER's local map. */ 2169 Otherwise, use BUFFER's local map. */
2167 2170
2168 Lisp_Object 2171 Lisp_Object
2169 get_local_map (position, buffer) 2172 get_local_map (position, buffer, type)
2170 register int position; 2173 register int position;
2171 register struct buffer *buffer; 2174 register struct buffer *buffer;
2175 enum map_property type;
2172 { 2176 {
2173 Lisp_Object prop, tem, lispy_position, lispy_buffer; 2177 Lisp_Object prop, tem, lispy_position, lispy_buffer;
2174 int old_begv, old_zv, old_begv_byte, old_zv_byte; 2178 int old_begv, old_zv, old_begv_byte, old_zv_byte;
2175 2179
2176 /* Perhaps we should just change `position' to the limit. */ 2180 /* Perhaps we should just change `position' to the limit. */
2192 check for a local map on the last character of the buffer instead. */ 2196 check for a local map on the last character of the buffer instead. */
2193 if (position == BUF_Z (buffer) && BUF_Z (buffer) > BUF_BEG (buffer)) 2197 if (position == BUF_Z (buffer) && BUF_Z (buffer) > BUF_BEG (buffer))
2194 --position; 2198 --position;
2195 XSETFASTINT (lispy_position, position); 2199 XSETFASTINT (lispy_position, position);
2196 XSETBUFFER (lispy_buffer, buffer); 2200 XSETBUFFER (lispy_buffer, buffer);
2197 prop = Fget_char_property (lispy_position, Qlocal_map, lispy_buffer); 2201 prop = Fget_char_property (lispy_position,
2202 type == keymap ? Qkeymap : Qlocal_map,
2203 lispy_buffer);
2198 2204
2199 BUF_BEGV (buffer) = old_begv; 2205 BUF_BEGV (buffer) = old_begv;
2200 BUF_ZV (buffer) = old_zv; 2206 BUF_ZV (buffer) = old_zv;
2201 BUF_BEGV_BYTE (buffer) = old_begv_byte; 2207 BUF_BEGV_BYTE (buffer) = old_begv_byte;
2202 BUF_ZV_BYTE (buffer) = old_zv_byte; 2208 BUF_ZV_BYTE (buffer) = old_zv_byte;
2207 prop = indirect_function (prop); 2213 prop = indirect_function (prop);
2208 if (!NILP (prop) 2214 if (!NILP (prop)
2209 && (tem = Fkeymapp (prop), !NILP (tem))) 2215 && (tem = Fkeymapp (prop), !NILP (tem)))
2210 return prop; 2216 return prop;
2211 2217
2212 return buffer->keymap; 2218 if (type == keymap)
2219 return Qnil;
2220 else
2221 return buffer->keymap;
2213 } 2222 }
2214 2223
2215 /* Produce an interval tree reflecting the intervals in 2224 /* Produce an interval tree reflecting the intervals in
2216 TREE from START to START + LENGTH. 2225 TREE from START to START + LENGTH.
2217 The new interval tree has no parent and has a starting-position of 0. */ 2226 The new interval tree has no parent and has a starting-position of 0. */