summaryrefslogtreecommitdiff
path: root/src/alloc.c
diff options
context:
space:
mode:
authorDmitry Antipov <dmantipov@yandex.ru>2012-07-19 12:56:53 +0400
committerDmitry Antipov <dmantipov@yandex.ru>2012-07-19 12:56:53 +0400
commit9cd47b72e021f76a6e2481d986ce4b0cb0b859d3 (patch)
tree73912e8be2147fe90acf8f5dd20bb1c238d354df /src/alloc.c
parent1d6fc0df363db43f2c1db696fad40f068287500b (diff)
downloademacs-9cd47b72e021f76a6e2481d986ce4b0cb0b859d3.tar.gz
Compact buffers when idle.
* lisp/compact.el: New file. * src/buffer.c (compact_buffer, Fcompact_buffer): New function. (syms_of_buffer): Register Fcompact_buffer. * src/alloc.c (Fgarbage_collect): Use compact_buffer. * src/buffer.h (compact_buffer): New prototype. (struct buffer_text): New member.
Diffstat (limited to 'src/alloc.c')
-rw-r--r--src/alloc.c28
1 files changed, 1 insertions, 27 deletions
diff --git a/src/alloc.c b/src/alloc.c
index 166f5b72449..233137e368e 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -5413,33 +5413,7 @@ See Info node `(elisp)Garbage Collection'. */)
/* Don't keep undo information around forever.
Do this early on, so it is no problem if the user quits. */
for_each_buffer (nextb)
- {
- /* If a buffer's undo list is Qt, that means that undo is
- turned off in that buffer. Calling truncate_undo_list on
- Qt tends to return NULL, which effectively turns undo back on.
- So don't call truncate_undo_list if undo_list is Qt. */
- if (! NILP (nextb->BUFFER_INTERNAL_FIELD (name))
- && ! EQ (nextb->BUFFER_INTERNAL_FIELD (undo_list), Qt))
- truncate_undo_list (nextb);
-
- /* Shrink buffer gaps, but skip indirect and dead buffers. */
- if (nextb->base_buffer == 0 && !NILP (nextb->BUFFER_INTERNAL_FIELD (name))
- && ! nextb->text->inhibit_shrinking)
- {
- /* If a buffer's gap size is more than 10% of the buffer
- size, or larger than 2000 bytes, then shrink it
- accordingly. Keep a minimum size of 20 bytes. */
- int size = min (2000, max (20, (nextb->text->z_byte / 10)));
-
- if (nextb->text->gap_size > size)
- {
- struct buffer *save_current = current_buffer;
- current_buffer = nextb;
- make_gap (-(nextb->text->gap_size - size));
- current_buffer = save_current;
- }
- }
- }
+ compact_buffer (nextb);
t1 = current_emacs_time ();