diff options
| author | Dmitry Antipov | 2013-01-09 17:50:22 +0400 |
|---|---|---|
| committer | Dmitry Antipov | 2013-01-09 17:50:22 +0400 |
| commit | eefd727851555237c7bc205b7ad255c50ba3fff9 (patch) | |
| tree | 5009d8d2c8773c64504252c8e8738f14b84d2547 /src/buffer.c | |
| parent | ccd04887a3f15ce0e52af801d8a70c91d695f78c (diff) | |
| download | emacs-eefd727851555237c7bc205b7ad255c50ba3fff9.tar.gz emacs-eefd727851555237c7bc205b7ad255c50ba3fff9.zip | |
* lisp.h (make_gap_1): New prototype.
* buffer.h (GAP_BYTES_DFL, GAP_BYTES_MIN): New macros for the special
gap size values.
* editfns.c (Fbuffer_size): Rename from Fbufsize to fit the common
naming convention.
(syms_of_editfns): Adjust defsubr. Drop commented-out obsolete code.
* insdel.c (make_gap_larger): Use GAP_BYTES_DFL.
(make_gap_smaller): Use GAP_BYTES_MIN. Adjust comment.
(make_gap_1): New function to adjust the gap of any buffer.
* coding.c (coding_alloc_by_making_gap): Use it.
* buffer.c (compact_buffer): Likewise. Use BUF_Z_BYTE, BUF_GAP_SIZE,
GAP_BYTES_DFL and GAP_BYTES_MIN. Adjust comment.
Diffstat (limited to 'src/buffer.c')
| -rw-r--r-- | src/buffer.c | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/src/buffer.c b/src/buffer.c index 5999fcb7e7d..51c4d9c71da 100644 --- a/src/buffer.c +++ b/src/buffer.c | |||
| @@ -1682,17 +1682,13 @@ compact_buffer (struct buffer *buffer) | |||
| 1682 | if (!buffer->text->inhibit_shrinking) | 1682 | if (!buffer->text->inhibit_shrinking) |
| 1683 | { | 1683 | { |
| 1684 | /* If a buffer's gap size is more than 10% of the buffer | 1684 | /* If a buffer's gap size is more than 10% of the buffer |
| 1685 | size, or larger than 2000 bytes, then shrink it | 1685 | size, or larger than GAP_BYTES_DFL bytes, then shrink it |
| 1686 | accordingly. Keep a minimum size of 20 bytes. */ | 1686 | accordingly. Keep a minimum size of GAP_BYTES_MIN bytes. */ |
| 1687 | int size = min (2000, max (20, (buffer->text->z_byte / 10))); | 1687 | ptrdiff_t size = clip_to_bounds (GAP_BYTES_MIN, |
| 1688 | 1688 | BUF_Z_BYTE (buffer) / 10, | |
| 1689 | if (buffer->text->gap_size > size) | 1689 | GAP_BYTES_DFL); |
| 1690 | { | 1690 | if (BUF_GAP_SIZE (buffer) > size) |
| 1691 | struct buffer *save_current = current_buffer; | 1691 | make_gap_1 (buffer, -(BUF_GAP_SIZE (buffer) - size)); |
| 1692 | current_buffer = buffer; | ||
| 1693 | make_gap (-(buffer->text->gap_size - size)); | ||
| 1694 | current_buffer = save_current; | ||
| 1695 | } | ||
| 1696 | } | 1692 | } |
| 1697 | BUF_COMPACT (buffer) = BUF_MODIFF (buffer); | 1693 | BUF_COMPACT (buffer) = BUF_MODIFF (buffer); |
| 1698 | } | 1694 | } |