Mercurial > emacs
comparison src/undo.c @ 25663:a5eaace0fa01
Use XCAR and XCDR instead of explicit member access.
| author | Ken Raeburn <raeburn@raeburn.org> |
|---|---|
| date | Mon, 13 Sep 1999 03:35:33 +0000 |
| parents | fa9ff387d260 |
| children | c3c9cc1c2379 |
comparison
equal
deleted
inserted
replaced
| 25662:0a7261c1d487 | 25663:a5eaace0fa01 |
|---|---|
| 64 /* If this is following another insertion and consecutive with it | 64 /* If this is following another insertion and consecutive with it |
| 65 in the buffer, combine the two. */ | 65 in the buffer, combine the two. */ |
| 66 if (CONSP (current_buffer->undo_list)) | 66 if (CONSP (current_buffer->undo_list)) |
| 67 { | 67 { |
| 68 Lisp_Object elt; | 68 Lisp_Object elt; |
| 69 elt = XCONS (current_buffer->undo_list)->car; | 69 elt = XCAR (current_buffer->undo_list); |
| 70 if (CONSP (elt) | 70 if (CONSP (elt) |
| 71 && INTEGERP (XCONS (elt)->car) | 71 && INTEGERP (XCAR (elt)) |
| 72 && INTEGERP (XCONS (elt)->cdr) | 72 && INTEGERP (XCDR (elt)) |
| 73 && XINT (XCONS (elt)->cdr) == beg) | 73 && XINT (XCDR (elt)) == beg) |
| 74 { | 74 { |
| 75 XSETINT (XCONS (elt)->cdr, beg + length); | 75 XSETINT (XCDR (elt), beg + length); |
| 76 return; | 76 return; |
| 77 } | 77 } |
| 78 } | 78 } |
| 79 | 79 |
| 80 XSETFASTINT (lbeg, beg); | 80 XSETFASTINT (lbeg, beg); |
| 112 | 112 |
| 113 Lisp_Object tail = current_buffer->undo_list, elt; | 113 Lisp_Object tail = current_buffer->undo_list, elt; |
| 114 | 114 |
| 115 while (1) | 115 while (1) |
| 116 { | 116 { |
| 117 elt = XCONS (tail)->car; | 117 elt = XCAR (tail); |
| 118 if (NILP (elt) || ! (CONSP (elt) && MARKERP (XCONS (elt)->car))) | 118 if (NILP (elt) || ! (CONSP (elt) && MARKERP (XCAR (elt)))) |
| 119 break; | 119 break; |
| 120 tail = XCONS (tail)->cdr; | 120 tail = XCDR (tail); |
| 121 } | 121 } |
| 122 at_boundary = NILP (elt); | 122 at_boundary = NILP (elt); |
| 123 } | 123 } |
| 124 else | 124 else |
| 125 at_boundary = 0; | 125 at_boundary = 0; |
| 262 /* One way or another, cons nil onto the front of the undo list. */ | 262 /* One way or another, cons nil onto the front of the undo list. */ |
| 263 if (!NILP (pending_boundary)) | 263 if (!NILP (pending_boundary)) |
| 264 { | 264 { |
| 265 /* If we have preallocated the cons cell to use here, | 265 /* If we have preallocated the cons cell to use here, |
| 266 use that one. */ | 266 use that one. */ |
| 267 XCONS (pending_boundary)->cdr = current_buffer->undo_list; | 267 XCDR (pending_boundary) = current_buffer->undo_list; |
| 268 current_buffer->undo_list = pending_boundary; | 268 current_buffer->undo_list = pending_boundary; |
| 269 pending_boundary = Qnil; | 269 pending_boundary = Qnil; |
| 270 } | 270 } |
| 271 else | 271 else |
| 272 current_buffer->undo_list = Fcons (Qnil, current_buffer->undo_list); | 272 current_buffer->undo_list = Fcons (Qnil, current_buffer->undo_list); |
| 296 If the first element is an undo boundary, skip past it. | 296 If the first element is an undo boundary, skip past it. |
| 297 | 297 |
| 298 Skip, skip, skip the undo, skip, skip, skip the undo, | 298 Skip, skip, skip the undo, skip, skip, skip the undo, |
| 299 Skip, skip, skip the undo, skip to the undo bound'ry. | 299 Skip, skip, skip the undo, skip to the undo bound'ry. |
| 300 (Get it? "Skip to my Loo?") */ | 300 (Get it? "Skip to my Loo?") */ |
| 301 if (CONSP (next) && NILP (XCONS (next)->car)) | 301 if (CONSP (next) && NILP (XCAR (next))) |
| 302 { | 302 { |
| 303 /* Add in the space occupied by this element and its chain link. */ | 303 /* Add in the space occupied by this element and its chain link. */ |
| 304 size_so_far += sizeof (struct Lisp_Cons); | 304 size_so_far += sizeof (struct Lisp_Cons); |
| 305 | 305 |
| 306 /* Advance to next element. */ | 306 /* Advance to next element. */ |
| 307 prev = next; | 307 prev = next; |
| 308 next = XCONS (next)->cdr; | 308 next = XCDR (next); |
| 309 } | 309 } |
| 310 while (CONSP (next) && ! NILP (XCONS (next)->car)) | 310 while (CONSP (next) && ! NILP (XCAR (next))) |
| 311 { | 311 { |
| 312 Lisp_Object elt; | 312 Lisp_Object elt; |
| 313 elt = XCONS (next)->car; | 313 elt = XCAR (next); |
| 314 | 314 |
| 315 /* Add in the space occupied by this element and its chain link. */ | 315 /* Add in the space occupied by this element and its chain link. */ |
| 316 size_so_far += sizeof (struct Lisp_Cons); | 316 size_so_far += sizeof (struct Lisp_Cons); |
| 317 if (CONSP (elt)) | 317 if (CONSP (elt)) |
| 318 { | 318 { |
| 319 size_so_far += sizeof (struct Lisp_Cons); | 319 size_so_far += sizeof (struct Lisp_Cons); |
| 320 if (STRINGP (XCONS (elt)->car)) | 320 if (STRINGP (XCAR (elt))) |
| 321 size_so_far += (sizeof (struct Lisp_String) - 1 | 321 size_so_far += (sizeof (struct Lisp_String) - 1 |
| 322 + XSTRING (XCONS (elt)->car)->size); | 322 + XSTRING (XCAR (elt))->size); |
| 323 } | 323 } |
| 324 | 324 |
| 325 /* Advance to next element. */ | 325 /* Advance to next element. */ |
| 326 prev = next; | 326 prev = next; |
| 327 next = XCONS (next)->cdr; | 327 next = XCDR (next); |
| 328 } | 328 } |
| 329 if (CONSP (next)) | 329 if (CONSP (next)) |
| 330 last_boundary = prev; | 330 last_boundary = prev; |
| 331 | 331 |
| 332 while (CONSP (next)) | 332 while (CONSP (next)) |
| 333 { | 333 { |
| 334 Lisp_Object elt; | 334 Lisp_Object elt; |
| 335 elt = XCONS (next)->car; | 335 elt = XCAR (next); |
| 336 | 336 |
| 337 /* When we get to a boundary, decide whether to truncate | 337 /* When we get to a boundary, decide whether to truncate |
| 338 either before or after it. The lower threshold, MINSIZE, | 338 either before or after it. The lower threshold, MINSIZE, |
| 339 tells us to truncate after it. If its size pushes past | 339 tells us to truncate after it. If its size pushes past |
| 340 the higher threshold MAXSIZE as well, we truncate before it. */ | 340 the higher threshold MAXSIZE as well, we truncate before it. */ |
| 350 /* Add in the space occupied by this element and its chain link. */ | 350 /* Add in the space occupied by this element and its chain link. */ |
| 351 size_so_far += sizeof (struct Lisp_Cons); | 351 size_so_far += sizeof (struct Lisp_Cons); |
| 352 if (CONSP (elt)) | 352 if (CONSP (elt)) |
| 353 { | 353 { |
| 354 size_so_far += sizeof (struct Lisp_Cons); | 354 size_so_far += sizeof (struct Lisp_Cons); |
| 355 if (STRINGP (XCONS (elt)->car)) | 355 if (STRINGP (XCAR (elt))) |
| 356 size_so_far += (sizeof (struct Lisp_String) - 1 | 356 size_so_far += (sizeof (struct Lisp_String) - 1 |
| 357 + XSTRING (XCONS (elt)->car)->size); | 357 + XSTRING (XCAR (elt))->size); |
| 358 } | 358 } |
| 359 | 359 |
| 360 /* Advance to next element. */ | 360 /* Advance to next element. */ |
| 361 prev = next; | 361 prev = next; |
| 362 next = XCONS (next)->cdr; | 362 next = XCDR (next); |
| 363 } | 363 } |
| 364 | 364 |
| 365 /* If we scanned the whole list, it is short enough; don't change it. */ | 365 /* If we scanned the whole list, it is short enough; don't change it. */ |
| 366 if (NILP (next)) | 366 if (NILP (next)) |
| 367 return list; | 367 return list; |
| 368 | 368 |
| 369 /* Truncate at the boundary where we decided to truncate. */ | 369 /* Truncate at the boundary where we decided to truncate. */ |
| 370 if (!NILP (last_boundary)) | 370 if (!NILP (last_boundary)) |
| 371 { | 371 { |
| 372 XCONS (last_boundary)->cdr = Qnil; | 372 XCDR (last_boundary) = Qnil; |
| 373 return list; | 373 return list; |
| 374 } | 374 } |
| 375 else | 375 else |
| 376 return Qnil; | 376 return Qnil; |
| 377 } | 377 } |
