238 |
{ |
{ |
239 |
register char *buffer, *p; |
register char *buffer, *p; |
240 |
int wordstart, wordend; |
int wordstart, wordend; |
241 |
register int wordstart_byte, wordend_byte, idx; |
register int wordstart_byte, wordend_byte, idx, idx_byte; |
242 |
int whitecnt; |
int whitecnt; |
243 |
int uccount = 0, lccount = 0; |
int uccount = 0, lccount = 0; |
244 |
register Lisp_Object sym; |
register Lisp_Object sym; |
245 |
Lisp_Object expansion, hook, tem; |
Lisp_Object expansion, hook, tem; |
246 |
Lisp_Object value; |
Lisp_Object value; |
247 |
|
int multibyte = ! NILP (current_buffer->enable_multibyte_characters); |
248 |
|
|
249 |
value = Qnil; |
value = Qnil; |
250 |
|
|
290 |
|
|
291 |
p = buffer = (char *) alloca (wordend_byte - wordstart_byte); |
p = buffer = (char *) alloca (wordend_byte - wordstart_byte); |
292 |
|
|
293 |
for (idx = wordstart_byte; idx < wordend_byte; idx++) |
for (idx = wordstart, idx_byte = wordstart_byte; idx < wordend; ) |
294 |
{ |
{ |
295 |
/* ??? This loop needs to go by characters! */ |
register int c; |
296 |
register int c = FETCH_BYTE (idx); |
|
297 |
|
if (multibyte) |
298 |
|
{ |
299 |
|
FETCH_CHAR_ADVANCE (c, idx, idx_byte); |
300 |
|
} |
301 |
|
else |
302 |
|
{ |
303 |
|
c = FETCH_BYTE (idx_byte); |
304 |
|
idx++, idx_byte++; |
305 |
|
} |
306 |
|
|
307 |
if (UPPERCASEP (c)) |
if (UPPERCASEP (c)) |
308 |
c = DOWNCASE (c), uccount++; |
c = DOWNCASE (c), uccount++; |
309 |
else if (! NOCASEP (c)) |
else if (! NOCASEP (c)) |
310 |
lccount++; |
lccount++; |
311 |
*p++ = c; |
if (multibyte) |
312 |
|
p += CHAR_STRING (c, p); |
313 |
|
else |
314 |
|
*p++ = c; |
315 |
} |
} |
316 |
|
|
317 |
if (VECTORP (current_buffer->abbrev_table)) |
if (VECTORP (current_buffer->abbrev_table)) |
318 |
sym = oblookup (current_buffer->abbrev_table, buffer, |
sym = oblookup (current_buffer->abbrev_table, buffer, |
319 |
wordend - wordstart, wordend_byte - wordstart_byte); |
wordend - wordstart, p - buffer); |
320 |
else |
else |
321 |
XSETFASTINT (sym, 0); |
XSETFASTINT (sym, 0); |
322 |
|
|
323 |
if (INTEGERP (sym) || NILP (SYMBOL_VALUE (sym))) |
if (INTEGERP (sym) || NILP (SYMBOL_VALUE (sym))) |
324 |
sym = oblookup (Vglobal_abbrev_table, buffer, |
sym = oblookup (Vglobal_abbrev_table, buffer, |
325 |
wordend - wordstart, wordend_byte - wordstart_byte); |
wordend - wordstart, p - buffer); |
326 |
if (INTEGERP (sym) || NILP (SYMBOL_VALUE (sym))) |
if (INTEGERP (sym) || NILP (SYMBOL_VALUE (sym))) |
327 |
return value; |
return value; |
328 |
|
|
358 |
|
|
359 |
del_range_both (wordstart, wordstart_byte, wordend, wordend_byte, 1); |
del_range_both (wordstart, wordstart_byte, wordend, wordend_byte, 1); |
360 |
|
|
361 |
insert_from_string (expansion, 0, 0, XSTRING (expansion)->size, |
insert_from_string (expansion, 0, 0, SCHARS (expansion), |
362 |
STRING_BYTES (XSTRING (expansion)), 1); |
SBYTES (expansion), 1); |
363 |
SET_PT (PT + whitecnt); |
SET_PT (PT + whitecnt); |
364 |
|
|
365 |
if (uccount && !lccount) |
if (uccount && !lccount) |
441 |
if (!STRINGP (val)) |
if (!STRINGP (val)) |
442 |
error ("value of abbrev-symbol must be a string"); |
error ("value of abbrev-symbol must be a string"); |
443 |
zv_before = ZV; |
zv_before = ZV; |
444 |
del_range_byte (PT_BYTE, PT_BYTE + STRING_BYTES (XSTRING (val)), 1); |
del_range_byte (PT_BYTE, PT_BYTE + SBYTES (val), 1); |
445 |
/* Don't inherit properties here; just copy from old contents. */ |
/* Don't inherit properties here; just copy from old contents. */ |
446 |
insert_from_string (Vlast_abbrev_text, 0, 0, |
insert_from_string (Vlast_abbrev_text, 0, 0, |
447 |
XSTRING (Vlast_abbrev_text)->size, |
SCHARS (Vlast_abbrev_text), |
448 |
STRING_BYTES (XSTRING (Vlast_abbrev_text)), 0); |
SBYTES (Vlast_abbrev_text), 0); |
449 |
Vlast_abbrev_text = Qnil; |
Vlast_abbrev_text = Qnil; |
450 |
/* Total number of characters deleted. */ |
/* Total number of characters deleted. */ |
451 |
adjust = ZV - zv_before; |
adjust = ZV - zv_before; |