aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRichard M. Stallman1997-12-31 05:05:32 +0000
committerRichard M. Stallman1997-12-31 05:05:32 +0000
commitaa406bac5f53646bf6919084362452d13dc10a4c (patch)
tree8103d783bbe654f99d7eb0a4e5dda76d57c3d4dc /src
parent92bb366afa2b675c16e05df5fcf0caba50f407f7 (diff)
downloademacs-aa406bac5f53646bf6919084362452d13dc10a4c.tar.gz
emacs-aa406bac5f53646bf6919084362452d13dc10a4c.zip
(describe_abbrev): Return void.
(write_abbrev): Return void. (Fexpand_abbrev): Scan in bytepos along with charpos. (Funexpand_abbrev): Use bytepos to delete the expansion.
Diffstat (limited to 'src')
-rw-r--r--src/abbrev.c41
1 files changed, 27 insertions, 14 deletions
diff --git a/src/abbrev.c b/src/abbrev.c
index 8c28e1c3ff0..49b94565aa0 100644
--- a/src/abbrev.c
+++ b/src/abbrev.c
@@ -218,7 +218,8 @@ Returns the abbrev symbol, if expansion took place.")
218 () 218 ()
219{ 219{
220 register char *buffer, *p; 220 register char *buffer, *p;
221 register int wordstart, wordend, idx; 221 int wordstart, wordend;
222 register int wordstart_byte, wordend_byte, idx;
222 int whitecnt; 223 int whitecnt;
223 int uccount = 0, lccount = 0; 224 int uccount = 0, lccount = 0;
224 register Lisp_Object sym; 225 register Lisp_Object sym;
@@ -243,8 +244,12 @@ Returns the abbrev symbol, if expansion took place.")
243 Vabbrev_start_location = Qnil; 244 Vabbrev_start_location = Qnil;
244 if (wordstart < BEGV || wordstart > ZV) 245 if (wordstart < BEGV || wordstart > ZV)
245 wordstart = 0; 246 wordstart = 0;
246 if (wordstart && wordstart != ZV && FETCH_BYTE (wordstart) == '-') 247 if (wordstart && wordstart != ZV)
247 del_range (wordstart, wordstart + 1); 248 {
249 wordstart_byte = CHAR_TO_BYTE (wordstart);
250 if (FETCH_BYTE (wordstart_byte) == '-')
251 del_range (wordstart, wordstart + 1);
252 }
248 } 253 }
249 if (!wordstart) 254 if (!wordstart)
250 wordstart = scan_words (PT, -1); 255 wordstart = scan_words (PT, -1);
@@ -252,20 +257,24 @@ Returns the abbrev symbol, if expansion took place.")
252 if (!wordstart) 257 if (!wordstart)
253 return value; 258 return value;
254 259
260 wordstart_byte = CHAR_TO_BYTE (wordstart);
255 wordend = scan_words (wordstart, 1); 261 wordend = scan_words (wordstart, 1);
256 if (!wordend) 262 if (!wordend)
257 return value; 263 return value;
258 264
259 if (wordend > PT) 265 if (wordend > PT)
260 wordend = PT; 266 wordend = PT;
267
268 wordend_byte = CHAR_TO_BYTE (wordend);
261 whitecnt = PT - wordend; 269 whitecnt = PT - wordend;
262 if (wordend <= wordstart) 270 if (wordend <= wordstart)
263 return value; 271 return value;
264 272
265 p = buffer = (char *) alloca (wordend - wordstart); 273 p = buffer = (char *) alloca (wordend_byte - wordstart_byte);
266 274
267 for (idx = wordstart; idx < wordend; idx++) 275 for (idx = wordstart_byte; idx < wordend_byte; idx++)
268 { 276 {
277 /* ??? This loop needs to go by characters! */
269 register int c = FETCH_BYTE (idx); 278 register int c = FETCH_BYTE (idx);
270 if (UPPERCASEP (c)) 279 if (UPPERCASEP (c))
271 c = DOWNCASE (c), uccount++; 280 c = DOWNCASE (c), uccount++;
@@ -310,7 +319,7 @@ Returns the abbrev symbol, if expansion took place.")
310 { 319 {
311 SET_PT (wordstart); 320 SET_PT (wordstart);
312 321
313 del_range (wordstart, wordend); 322 del_range_both (wordstart, wordend, wordstart_byte, wordend_byte, 1);
314 323
315 insert_from_string (expansion, 0, XSTRING (expansion)->size, 1); 324 insert_from_string (expansion, 0, XSTRING (expansion)->size, 1);
316 SET_PT (PT + whitecnt); 325 SET_PT (PT + whitecnt);
@@ -335,14 +344,15 @@ Returns the abbrev symbol, if expansion took place.")
335 else if (uccount) 344 else if (uccount)
336 { 345 {
337 /* Abbrev included some caps. Cap first initial of expansion */ 346 /* Abbrev included some caps. Cap first initial of expansion */
338 int pos = wordstart; 347 int pos = wordstart_byte;
339 348
340 /* Find the initial. */ 349 /* Find the initial. */
341 while (pos < PT 350 while (pos < PT_BYTE
342 && SYNTAX (*BUF_CHAR_ADDRESS (current_buffer, pos)) != Sword) 351 && SYNTAX (*BUF_BYTE_ADDRESS (current_buffer, pos)) != Sword)
343 pos++; 352 pos++;
344 353
345 /* Change just that. */ 354 /* Change just that. */
355 pos = BYTE_TO_CHAR (pos);
346 Fupcase_initials_region (make_number (pos), make_number (pos + 1)); 356 Fupcase_initials_region (make_number (pos), make_number (pos + 1));
347 } 357 }
348 } 358 }
@@ -371,22 +381,25 @@ is not undone.")
371 /* This isn't correct if Vlast_abbrev->function was used 381 /* This isn't correct if Vlast_abbrev->function was used
372 to do the expansion */ 382 to do the expansion */
373 Lisp_Object val; 383 Lisp_Object val;
384 int zv_before;
385
374 val = XSYMBOL (Vlast_abbrev)->value; 386 val = XSYMBOL (Vlast_abbrev)->value;
375 if (!STRINGP (val)) 387 if (!STRINGP (val))
376 error ("value of abbrev-symbol must be a string"); 388 error ("value of abbrev-symbol must be a string");
377 adjust = XSTRING (val)->size; 389 zv_before = ZV;
378 del_range (PT, PT + adjust); 390 del_range_byte (PT_BYTE, PT_BYTE + XSTRING (val)->size, 1);
379 /* Don't inherit properties here; just copy from old contents. */ 391 /* Don't inherit properties here; just copy from old contents. */
380 insert_from_string (Vlast_abbrev_text, 0, 392 insert_from_string (Vlast_abbrev_text, 0,
381 XSTRING (Vlast_abbrev_text)->size, 0); 393 XSTRING (Vlast_abbrev_text)->size, 0);
382 adjust -= XSTRING (Vlast_abbrev_text)->size;
383 Vlast_abbrev_text = Qnil; 394 Vlast_abbrev_text = Qnil;
395 /* Total number of characters deleted. */
396 adjust = ZV - zv_before;
384 } 397 }
385 SET_PT (last_abbrev_point < opoint ? opoint - adjust : opoint); 398 SET_PT (last_abbrev_point < opoint ? opoint - adjust : opoint);
386 return Qnil; 399 return Qnil;
387} 400}
388 401
389static 402static void
390write_abbrev (sym, stream) 403write_abbrev (sym, stream)
391 Lisp_Object sym, stream; 404 Lisp_Object sym, stream;
392{ 405{
@@ -405,7 +418,7 @@ write_abbrev (sym, stream)
405 insert (")\n", 2); 418 insert (")\n", 2);
406} 419}
407 420
408static 421static void
409describe_abbrev (sym, stream) 422describe_abbrev (sym, stream)
410 Lisp_Object sym, stream; 423 Lisp_Object sym, stream;
411{ 424{