mirror of
https://git.savannah.gnu.org/git/emacs.git
synced 2024-12-17 10:06:13 +00:00
* 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.
This commit is contained in:
parent
ccd04887a3
commit
eefd727851
@ -1,3 +1,18 @@
|
||||
2013-01-09 Dmitry Antipov <dmantipov@yandex.ru>
|
||||
|
||||
* 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.
|
||||
|
||||
2013-01-08 Juri Linkov <juri@jurta.org>
|
||||
|
||||
* xfaces.c (tty_supports_face_attributes_p): Return 0 for the case
|
||||
|
18
src/buffer.c
18
src/buffer.c
@ -1682,17 +1682,13 @@ compact_buffer (struct buffer *buffer)
|
||||
if (!buffer->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, (buffer->text->z_byte / 10)));
|
||||
|
||||
if (buffer->text->gap_size > size)
|
||||
{
|
||||
struct buffer *save_current = current_buffer;
|
||||
current_buffer = buffer;
|
||||
make_gap (-(buffer->text->gap_size - size));
|
||||
current_buffer = save_current;
|
||||
}
|
||||
size, or larger than GAP_BYTES_DFL bytes, then shrink it
|
||||
accordingly. Keep a minimum size of GAP_BYTES_MIN bytes. */
|
||||
ptrdiff_t size = clip_to_bounds (GAP_BYTES_MIN,
|
||||
BUF_Z_BYTE (buffer) / 10,
|
||||
GAP_BYTES_DFL);
|
||||
if (BUF_GAP_SIZE (buffer) > size)
|
||||
make_gap_1 (buffer, -(BUF_GAP_SIZE (buffer) - size));
|
||||
}
|
||||
BUF_COMPACT (buffer) = BUF_MODIFF (buffer);
|
||||
}
|
||||
|
10
src/buffer.h
10
src/buffer.h
@ -320,6 +320,16 @@ while (0)
|
||||
#define BUF_BYTES_MAX \
|
||||
(ptrdiff_t) min (MOST_POSITIVE_FIXNUM - 1, min (SIZE_MAX, PTRDIFF_MAX))
|
||||
|
||||
/* Maximum gap size after compact_buffer, in bytes. Also
|
||||
used in make_gap_larger to get some extra reserved space. */
|
||||
|
||||
#define GAP_BYTES_DFL 2000
|
||||
|
||||
/* Minimum gap size after compact_buffer, in bytes. Also
|
||||
used in make_gap_smaller to avoid too small gap size. */
|
||||
|
||||
#define GAP_BYTES_MIN 20
|
||||
|
||||
/* Return the address of byte position N in current buffer. */
|
||||
|
||||
#define BYTE_POS_ADDR(n) \
|
||||
|
@ -1049,14 +1049,7 @@ coding_alloc_by_making_gap (struct coding_system *coding,
|
||||
GPT -= gap_head_used, GPT_BYTE -= gap_head_used;
|
||||
}
|
||||
else
|
||||
{
|
||||
Lisp_Object this_buffer;
|
||||
|
||||
this_buffer = Fcurrent_buffer ();
|
||||
set_buffer_internal (XBUFFER (coding->dst_object));
|
||||
make_gap (bytes);
|
||||
set_buffer_internal (XBUFFER (this_buffer));
|
||||
}
|
||||
make_gap_1 (XBUFFER (coding->dst_object), bytes);
|
||||
}
|
||||
|
||||
|
||||
|
@ -968,7 +968,7 @@ usage: (save-current-buffer &rest BODY) */)
|
||||
return unbind_to (count, Fprogn (args));
|
||||
}
|
||||
|
||||
DEFUN ("buffer-size", Fbufsize, Sbufsize, 0, 1, 0,
|
||||
DEFUN ("buffer-size", Fbuffer_size, Sbuffer_size, 0, 1, 0,
|
||||
doc: /* Return the number of characters in the current buffer.
|
||||
If BUFFER, return the number of characters in that buffer instead. */)
|
||||
(Lisp_Object buffer)
|
||||
@ -4883,12 +4883,10 @@ functions if all the text being accessed has this property. */);
|
||||
defsubr (&Sline_beginning_position);
|
||||
defsubr (&Sline_end_position);
|
||||
|
||||
/* defsubr (&Smark); */
|
||||
/* defsubr (&Sset_mark); */
|
||||
defsubr (&Ssave_excursion);
|
||||
defsubr (&Ssave_current_buffer);
|
||||
|
||||
defsubr (&Sbufsize);
|
||||
defsubr (&Sbuffer_size);
|
||||
defsubr (&Spoint_max);
|
||||
defsubr (&Spoint_min);
|
||||
defsubr (&Spoint_min_marker);
|
||||
|
24
src/insdel.c
24
src/insdel.c
@ -388,14 +388,13 @@ make_gap_larger (ptrdiff_t nbytes_added)
|
||||
ptrdiff_t real_gap_loc_byte;
|
||||
ptrdiff_t old_gap_size;
|
||||
ptrdiff_t current_size = Z_BYTE - BEG_BYTE + GAP_SIZE;
|
||||
enum { enough_for_a_while = 2000 };
|
||||
|
||||
if (BUF_BYTES_MAX - current_size < nbytes_added)
|
||||
buffer_overflow ();
|
||||
|
||||
/* If we have to get more space, get enough to last a while;
|
||||
but do not exceed the maximum buffer size. */
|
||||
nbytes_added = min (nbytes_added + enough_for_a_while,
|
||||
nbytes_added = min (nbytes_added + GAP_BYTES_DFL,
|
||||
BUF_BYTES_MAX - current_size);
|
||||
|
||||
enlarge_buffer_text (current_buffer, nbytes_added);
|
||||
@ -443,9 +442,9 @@ make_gap_smaller (ptrdiff_t nbytes_removed)
|
||||
ptrdiff_t real_beg_unchanged;
|
||||
ptrdiff_t new_gap_size;
|
||||
|
||||
/* Make sure the gap is at least 20 bytes. */
|
||||
if (GAP_SIZE - nbytes_removed < 20)
|
||||
nbytes_removed = GAP_SIZE - 20;
|
||||
/* Make sure the gap is at least GAP_BYTES_MIN bytes. */
|
||||
if (GAP_SIZE - nbytes_removed < GAP_BYTES_MIN)
|
||||
nbytes_removed = GAP_SIZE - GAP_BYTES_MIN;
|
||||
|
||||
/* Prevent quitting in move_gap. */
|
||||
tem = Vinhibit_quit;
|
||||
@ -500,7 +499,20 @@ make_gap (ptrdiff_t nbytes_added)
|
||||
make_gap_smaller (-nbytes_added);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/* Add NBYTES to B's gap. It's enough to temporarily
|
||||
fake current_buffer and avoid real switch to B. */
|
||||
|
||||
void
|
||||
make_gap_1 (struct buffer *b, ptrdiff_t nbytes)
|
||||
{
|
||||
struct buffer *oldb = current_buffer;
|
||||
|
||||
current_buffer = b;
|
||||
make_gap (nbytes);
|
||||
current_buffer = oldb;
|
||||
}
|
||||
|
||||
/* Copy NBYTES bytes of text from FROM_ADDR to TO_ADDR.
|
||||
FROM_MULTIBYTE says whether the incoming text is multibyte.
|
||||
TO_MULTIBYTE says whether to store the text as multibyte.
|
||||
|
@ -2778,6 +2778,7 @@ extern void move_gap (ptrdiff_t);
|
||||
extern void move_gap_both (ptrdiff_t, ptrdiff_t);
|
||||
extern _Noreturn void buffer_overflow (void);
|
||||
extern void make_gap (ptrdiff_t);
|
||||
extern void make_gap_1 (struct buffer *, ptrdiff_t);
|
||||
extern ptrdiff_t copy_text (const unsigned char *, unsigned char *,
|
||||
ptrdiff_t, bool, bool);
|
||||
extern int count_combining_before (const unsigned char *,
|
||||
|
Loading…
Reference in New Issue
Block a user