diff options
| author | Dmitry Antipov | 2012-07-24 10:45:44 +0400 |
|---|---|---|
| committer | Dmitry Antipov | 2012-07-24 10:45:44 +0400 |
| commit | fa691a83f0f67db762d8d8d9d05d9ff97f25841f (patch) | |
| tree | a66fd4ee200f1ff0213fa5bee3a544a146659014 /src | |
| parent | ec1b09b12339df0920e8901c6bd355a7afd2bc11 (diff) | |
| download | emacs-fa691a83f0f67db762d8d8d9d05d9ff97f25841f.tar.gz emacs-fa691a83f0f67db762d8d8d9d05d9ff97f25841f.zip | |
Simplify copy_overlay.
* buffer.c (copy_overlay): Simplify, use build_marker.
* lisp.h (struct Lisp_Overlay): Restore comment with minor tweaks.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 6 | ||||
| -rw-r--r-- | src/buffer.c | 30 | ||||
| -rw-r--r-- | src/lisp.h | 11 |
3 files changed, 28 insertions, 19 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 40654e5a492..833fd8cc3c4 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,9 @@ | |||
| 1 | 2012-07-24 Dmitry Antipov <dmantipov@yandex.ru> | ||
| 2 | |||
| 3 | Simplify copy_overlay. | ||
| 4 | * buffer.c (copy_overlay): Simplify, use build_marker. | ||
| 5 | * lisp.h (struct Lisp_Overlay): Restore comment with minor tweaks. | ||
| 6 | |||
| 1 | 2012-07-23 Eli Zaretskii <eliz@gnu.org> | 7 | 2012-07-23 Eli Zaretskii <eliz@gnu.org> |
| 2 | 8 | ||
| 3 | * print.c (print_object): Don't crash when a frame's name is nil | 9 | * print.c (print_object): Don't crash when a frame's name is nil |
diff --git a/src/buffer.c b/src/buffer.c index 734ddb5a1c1..c017db7b034 100644 --- a/src/buffer.c +++ b/src/buffer.c | |||
| @@ -410,32 +410,24 @@ even if it is dead. The return value is never nil. */) | |||
| 410 | static struct Lisp_Overlay * | 410 | static struct Lisp_Overlay * |
| 411 | copy_overlays (struct buffer *b, struct Lisp_Overlay *list) | 411 | copy_overlays (struct buffer *b, struct Lisp_Overlay *list) |
| 412 | { | 412 | { |
| 413 | Lisp_Object buffer; | ||
| 414 | struct Lisp_Overlay *result = NULL, *tail = NULL; | 413 | struct Lisp_Overlay *result = NULL, *tail = NULL; |
| 415 | 414 | ||
| 416 | XSETBUFFER (buffer, b); | ||
| 417 | |||
| 418 | for (; list; list = list->next) | 415 | for (; list; list = list->next) |
| 419 | { | 416 | { |
| 420 | Lisp_Object overlay, start, end, old_overlay; | 417 | Lisp_Object overlay, start, end; |
| 421 | ptrdiff_t charpos; | 418 | struct Lisp_Marker *m; |
| 422 | |||
| 423 | XSETMISC (old_overlay, list); | ||
| 424 | charpos = marker_position (OVERLAY_START (old_overlay)); | ||
| 425 | start = Fmake_marker (); | ||
| 426 | Fset_marker (start, make_number (charpos), buffer); | ||
| 427 | XMARKER (start)->insertion_type | ||
| 428 | = XMARKER (OVERLAY_START (old_overlay))->insertion_type; | ||
| 429 | 419 | ||
| 430 | charpos = marker_position (OVERLAY_END (old_overlay)); | 420 | eassert (MARKERP (list->start)); |
| 431 | end = Fmake_marker (); | 421 | m = XMARKER (list->start); |
| 432 | Fset_marker (end, make_number (charpos), buffer); | 422 | start = build_marker (b, m->charpos, m->bytepos); |
| 433 | XMARKER (end)->insertion_type | 423 | XMARKER (start)->insertion_type = m->insertion_type; |
| 434 | = XMARKER (OVERLAY_END (old_overlay))->insertion_type; | ||
| 435 | 424 | ||
| 436 | overlay = build_overlay | 425 | eassert (MARKERP (list->end)); |
| 437 | (start, end, Fcopy_sequence (OVERLAY_PLIST (old_overlay))); | 426 | m = XMARKER (list->end); |
| 427 | end = build_marker (b, m->charpos, m->bytepos); | ||
| 428 | XMARKER (end)->insertion_type = m->insertion_type; | ||
| 438 | 429 | ||
| 430 | overlay = build_overlay (start, end, Fcopy_sequence (list->plist)); | ||
| 439 | if (tail) | 431 | if (tail) |
| 440 | tail = tail->next = XOVERLAY (overlay); | 432 | tail = tail->next = XOVERLAY (overlay); |
| 441 | else | 433 | else |
diff --git a/src/lisp.h b/src/lisp.h index e34a66af0c8..7f6a2d72c89 100644 --- a/src/lisp.h +++ b/src/lisp.h | |||
| @@ -1286,6 +1286,17 @@ struct Lisp_Marker | |||
| 1286 | /* START and END are markers in the overlay's buffer, and | 1286 | /* START and END are markers in the overlay's buffer, and |
| 1287 | PLIST is the overlay's property list. */ | 1287 | PLIST is the overlay's property list. */ |
| 1288 | struct Lisp_Overlay | 1288 | struct Lisp_Overlay |
| 1289 | /* An overlay's real data content is: | ||
| 1290 | - plist | ||
| 1291 | - buffer (really there are two buffer pointers, one per marker, | ||
| 1292 | and both points to the same buffer) | ||
| 1293 | - insertion type of both ends (per-marker fields) | ||
| 1294 | - start & start byte (of start marker) | ||
| 1295 | - end & end byte (of end marker) | ||
| 1296 | - next (singly linked list of overlays) | ||
| 1297 | - next fields of start and end markers (singly linked list of markers). | ||
| 1298 | I.e. 9words plus 2 bits, 3words of which are for external linked lists. | ||
| 1299 | */ | ||
| 1289 | { | 1300 | { |
| 1290 | ENUM_BF (Lisp_Misc_Type) type : 16; /* = Lisp_Misc_Overlay */ | 1301 | ENUM_BF (Lisp_Misc_Type) type : 16; /* = Lisp_Misc_Overlay */ |
| 1291 | unsigned gcmarkbit : 1; | 1302 | unsigned gcmarkbit : 1; |