aboutsummaryrefslogtreecommitdiffstats
path: root/src/buffer.c
diff options
context:
space:
mode:
authorTom Tromey2013-01-16 11:48:32 -0700
committerTom Tromey2013-01-16 11:48:32 -0700
commit6f4de085f065e11f4df3195d47479f28f5ef08ba (patch)
tree1211a00f1afc86c2b73624897993db02a4852943 /src/buffer.c
parente078a23febca14bc919c5806670479c395e3253e (diff)
parentffe04adc88e546c406f9b050238fb98a7243c7a0 (diff)
downloademacs-6f4de085f065e11f4df3195d47479f28f5ef08ba.tar.gz
emacs-6f4de085f065e11f4df3195d47479f28f5ef08ba.zip
merge from trunk
Diffstat (limited to 'src/buffer.c')
-rw-r--r--src/buffer.c104
1 files changed, 39 insertions, 65 deletions
diff --git a/src/buffer.c b/src/buffer.c
index 61b457e4558..a06868ec6c3 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -1680,17 +1680,13 @@ compact_buffer (struct buffer *buffer)
1680 if (!buffer->text->inhibit_shrinking) 1680 if (!buffer->text->inhibit_shrinking)
1681 { 1681 {
1682 /* If a buffer's gap size is more than 10% of the buffer 1682 /* If a buffer's gap size is more than 10% of the buffer
1683 size, or larger than 2000 bytes, then shrink it 1683 size, or larger than GAP_BYTES_DFL bytes, then shrink it
1684 accordingly. Keep a minimum size of 20 bytes. */ 1684 accordingly. Keep a minimum size of GAP_BYTES_MIN bytes. */
1685 int size = min (2000, max (20, (buffer->text->z_byte / 10))); 1685 ptrdiff_t size = clip_to_bounds (GAP_BYTES_MIN,
1686 1686 BUF_Z_BYTE (buffer) / 10,
1687 if (buffer->text->gap_size > size) 1687 GAP_BYTES_DFL);
1688 { 1688 if (BUF_GAP_SIZE (buffer) > size)
1689 struct buffer *save_current = current_buffer; 1689 make_gap_1 (buffer, -(BUF_GAP_SIZE (buffer) - size));
1690 current_buffer = buffer;
1691 make_gap (-(buffer->text->gap_size - size));
1692 current_buffer = save_current;
1693 }
1694 } 1690 }
1695 BUF_COMPACT (buffer) = BUF_MODIFF (buffer); 1691 BUF_COMPACT (buffer) = BUF_MODIFF (buffer);
1696 } 1692 }
@@ -4578,27 +4574,7 @@ evaporate_overlays (ptrdiff_t pos)
4578 for (; CONSP (hit_list); hit_list = XCDR (hit_list)) 4574 for (; CONSP (hit_list); hit_list = XCDR (hit_list))
4579 Fdelete_overlay (XCAR (hit_list)); 4575 Fdelete_overlay (XCAR (hit_list));
4580} 4576}
4581
4582/* Somebody has tried to store a value with an unacceptable type
4583 in the slot with offset OFFSET. */
4584
4585void
4586buffer_slot_type_mismatch (Lisp_Object newval, int type)
4587{
4588 Lisp_Object predicate;
4589
4590 switch (type)
4591 {
4592 case_Lisp_Int: predicate = Qintegerp; break;
4593 case Lisp_String: predicate = Qstringp; break;
4594 case Lisp_Symbol: predicate = Qsymbolp; break;
4595 default: emacs_abort ();
4596 }
4597
4598 wrong_type_argument (predicate, newval);
4599}
4600 4577
4601
4602/*********************************************************************** 4578/***********************************************************************
4603 Allocation with mmap 4579 Allocation with mmap
4604 ***********************************************************************/ 4580 ***********************************************************************/
@@ -5372,25 +5348,23 @@ init_buffer (void)
5372 free (pwd); 5348 free (pwd);
5373} 5349}
5374 5350
5375/* Similar to defvar_lisp but define a variable whose value is the Lisp 5351/* Similar to defvar_lisp but define a variable whose value is the
5376 Object stored in the current buffer. address is the address of the slot 5352 Lisp_Object stored in the current buffer. LNAME is the Lisp-level
5377 in the buffer that is current now. */ 5353 variable name. VNAME is the name of the buffer slot. PREDICATE
5378 5354 is nil for a general Lisp variable. If PREDICATE is non-nil, then
5379/* TYPE is nil for a general Lisp variable. 5355 only Lisp values that satisfies the PREDICATE are allowed (except
5380 An integer specifies a type; then only Lisp values 5356 that nil is allowed too). DOC is a dummy where you write the doc
5381 with that type code are allowed (except that nil is allowed too). 5357 string as a comment. */
5382 LNAME is the Lisp-level variable name. 5358
5383 VNAME is the name of the buffer slot. 5359#define DEFVAR_PER_BUFFER(lname, vname, predicate, doc) \
5384 DOC is a dummy where you write the doc string as a comment. */ 5360 do { \
5385#define DEFVAR_PER_BUFFER(lname, vname, type, doc) \ 5361 static struct Lisp_Buffer_Objfwd bo_fwd; \
5386 do { \ 5362 defvar_per_buffer (&bo_fwd, lname, vname, predicate); \
5387 static struct Lisp_Buffer_Objfwd bo_fwd; \
5388 defvar_per_buffer (&bo_fwd, lname, vname, type); \
5389 } while (0) 5363 } while (0)
5390 5364
5391static void 5365static void
5392defvar_per_buffer (struct Lisp_Buffer_Objfwd *bo_fwd, const char *namestring, 5366defvar_per_buffer (struct Lisp_Buffer_Objfwd *bo_fwd, const char *namestring,
5393 Lisp_Object *address, Lisp_Object type) 5367 Lisp_Object *address, Lisp_Object predicate)
5394{ 5368{
5395 struct Lisp_Symbol *sym; 5369 struct Lisp_Symbol *sym;
5396 int offset; 5370 int offset;
@@ -5400,7 +5374,7 @@ defvar_per_buffer (struct Lisp_Buffer_Objfwd *bo_fwd, const char *namestring,
5400 5374
5401 bo_fwd->type = Lisp_Fwd_Buffer_Obj; 5375 bo_fwd->type = Lisp_Fwd_Buffer_Obj;
5402 bo_fwd->offset = offset; 5376 bo_fwd->offset = offset;
5403 bo_fwd->slottype = type; 5377 bo_fwd->predicate = predicate;
5404 sym->declared_special = 1; 5378 sym->declared_special = 1;
5405 sym->redirect = SYMBOL_FORWARDED; 5379 sym->redirect = SYMBOL_FORWARDED;
5406 { 5380 {
@@ -5663,7 +5637,7 @@ Decimal digits after the % specify field width to which to pad. */);
5663 doc: /* Value of `major-mode' for new buffers. */); 5637 doc: /* Value of `major-mode' for new buffers. */);
5664 5638
5665 DEFVAR_PER_BUFFER ("major-mode", &BVAR (current_buffer, major_mode), 5639 DEFVAR_PER_BUFFER ("major-mode", &BVAR (current_buffer, major_mode),
5666 make_number (Lisp_Symbol), 5640 Qsymbolp,
5667 doc: /* Symbol for current buffer's major mode. 5641 doc: /* Symbol for current buffer's major mode.
5668The default value (normally `fundamental-mode') affects new buffers. 5642The default value (normally `fundamental-mode') affects new buffers.
5669A value of nil means to use the current buffer's major mode, provided 5643A value of nil means to use the current buffer's major mode, provided
@@ -5694,17 +5668,17 @@ Use the command `abbrev-mode' to change this variable. */);
5694 doc: /* Non-nil if searches and matches should ignore case. */); 5668 doc: /* Non-nil if searches and matches should ignore case. */);
5695 5669
5696 DEFVAR_PER_BUFFER ("fill-column", &BVAR (current_buffer, fill_column), 5670 DEFVAR_PER_BUFFER ("fill-column", &BVAR (current_buffer, fill_column),
5697 make_number (Lisp_Int0), 5671 Qintegerp,
5698 doc: /* Column beyond which automatic line-wrapping should happen. 5672 doc: /* Column beyond which automatic line-wrapping should happen.
5699Interactively, you can set the buffer local value using \\[set-fill-column]. */); 5673Interactively, you can set the buffer local value using \\[set-fill-column]. */);
5700 5674
5701 DEFVAR_PER_BUFFER ("left-margin", &BVAR (current_buffer, left_margin), 5675 DEFVAR_PER_BUFFER ("left-margin", &BVAR (current_buffer, left_margin),
5702 make_number (Lisp_Int0), 5676 Qintegerp,
5703 doc: /* Column for the default `indent-line-function' to indent to. 5677 doc: /* Column for the default `indent-line-function' to indent to.
5704Linefeed indents to this column in Fundamental mode. */); 5678Linefeed indents to this column in Fundamental mode. */);
5705 5679
5706 DEFVAR_PER_BUFFER ("tab-width", &BVAR (current_buffer, tab_width), 5680 DEFVAR_PER_BUFFER ("tab-width", &BVAR (current_buffer, tab_width),
5707 make_number (Lisp_Int0), 5681 Qintegerp,
5708 doc: /* Distance between tab stops (for display of tab characters), in columns. 5682 doc: /* Distance between tab stops (for display of tab characters), in columns.
5709This should be an integer greater than zero. */); 5683This should be an integer greater than zero. */);
5710 5684
@@ -5789,7 +5763,7 @@ visual lines rather than logical lines. See the documentation of
5789`visual-line-mode'. */); 5763`visual-line-mode'. */);
5790 5764
5791 DEFVAR_PER_BUFFER ("default-directory", &BVAR (current_buffer, directory), 5765 DEFVAR_PER_BUFFER ("default-directory", &BVAR (current_buffer, directory),
5792 make_number (Lisp_String), 5766 Qstringp,
5793 doc: /* Name of default directory of current buffer. Should end with slash. 5767 doc: /* Name of default directory of current buffer. Should end with slash.
5794To interactively change the default directory, use command `cd'. */); 5768To interactively change the default directory, use command `cd'. */);
5795 5769
@@ -5802,18 +5776,18 @@ NOTE: This variable is not a hook;
5802its value may not be a list of functions. */); 5776its value may not be a list of functions. */);
5803 5777
5804 DEFVAR_PER_BUFFER ("buffer-file-name", &BVAR (current_buffer, filename), 5778 DEFVAR_PER_BUFFER ("buffer-file-name", &BVAR (current_buffer, filename),
5805 make_number (Lisp_String), 5779 Qstringp,
5806 doc: /* Name of file visited in current buffer, or nil if not visiting a file. */); 5780 doc: /* Name of file visited in current buffer, or nil if not visiting a file. */);
5807 5781
5808 DEFVAR_PER_BUFFER ("buffer-file-truename", &BVAR (current_buffer, file_truename), 5782 DEFVAR_PER_BUFFER ("buffer-file-truename", &BVAR (current_buffer, file_truename),
5809 make_number (Lisp_String), 5783 Qstringp,
5810 doc: /* Abbreviated truename of file visited in current buffer, or nil if none. 5784 doc: /* Abbreviated truename of file visited in current buffer, or nil if none.
5811The truename of a file is calculated by `file-truename' 5785The truename of a file is calculated by `file-truename'
5812and then abbreviated with `abbreviate-file-name'. */); 5786and then abbreviated with `abbreviate-file-name'. */);
5813 5787
5814 DEFVAR_PER_BUFFER ("buffer-auto-save-file-name", 5788 DEFVAR_PER_BUFFER ("buffer-auto-save-file-name",
5815 &BVAR (current_buffer, auto_save_file_name), 5789 &BVAR (current_buffer, auto_save_file_name),
5816 make_number (Lisp_String), 5790 Qstringp,
5817 doc: /* Name of file for auto-saving current buffer. 5791 doc: /* Name of file for auto-saving current buffer.
5818If it is nil, that means don't auto-save this buffer. */); 5792If it is nil, that means don't auto-save this buffer. */);
5819 5793
@@ -5825,7 +5799,7 @@ If it is nil, that means don't auto-save this buffer. */);
5825Backing up is done before the first time the file is saved. */); 5799Backing up is done before the first time the file is saved. */);
5826 5800
5827 DEFVAR_PER_BUFFER ("buffer-saved-size", &BVAR (current_buffer, save_length), 5801 DEFVAR_PER_BUFFER ("buffer-saved-size", &BVAR (current_buffer, save_length),
5828 make_number (Lisp_Int0), 5802 Qintegerp,
5829 doc: /* Length of current buffer when last read in, saved or auto-saved. 5803 doc: /* Length of current buffer when last read in, saved or auto-saved.
58300 initially. 58040 initially.
5831-1 means auto-saving turned off until next real save. 5805-1 means auto-saving turned off until next real save.
@@ -5895,23 +5869,23 @@ In addition, a char-table has six extra slots to control the display of:
5895See also the functions `display-table-slot' and `set-display-table-slot'. */); 5869See also the functions `display-table-slot' and `set-display-table-slot'. */);
5896 5870
5897 DEFVAR_PER_BUFFER ("left-margin-width", &BVAR (current_buffer, left_margin_cols), 5871 DEFVAR_PER_BUFFER ("left-margin-width", &BVAR (current_buffer, left_margin_cols),
5898 Qnil, 5872 Qintegerp,
5899 doc: /* Width of left marginal area for display of a buffer. 5873 doc: /* Width of left marginal area for display of a buffer.
5900A value of nil means no marginal area. */); 5874A value of nil means no marginal area. */);
5901 5875
5902 DEFVAR_PER_BUFFER ("right-margin-width", &BVAR (current_buffer, right_margin_cols), 5876 DEFVAR_PER_BUFFER ("right-margin-width", &BVAR (current_buffer, right_margin_cols),
5903 Qnil, 5877 Qintegerp,
5904 doc: /* Width of right marginal area for display of a buffer. 5878 doc: /* Width of right marginal area for display of a buffer.
5905A value of nil means no marginal area. */); 5879A value of nil means no marginal area. */);
5906 5880
5907 DEFVAR_PER_BUFFER ("left-fringe-width", &BVAR (current_buffer, left_fringe_width), 5881 DEFVAR_PER_BUFFER ("left-fringe-width", &BVAR (current_buffer, left_fringe_width),
5908 Qnil, 5882 Qintegerp,
5909 doc: /* Width of this buffer's left fringe (in pixels). 5883 doc: /* Width of this buffer's left fringe (in pixels).
5910A value of 0 means no left fringe is shown in this buffer's window. 5884A value of 0 means no left fringe is shown in this buffer's window.
5911A value of nil means to use the left fringe width from the window's frame. */); 5885A value of nil means to use the left fringe width from the window's frame. */);
5912 5886
5913 DEFVAR_PER_BUFFER ("right-fringe-width", &BVAR (current_buffer, right_fringe_width), 5887 DEFVAR_PER_BUFFER ("right-fringe-width", &BVAR (current_buffer, right_fringe_width),
5914 Qnil, 5888 Qintegerp,
5915 doc: /* Width of this buffer's right fringe (in pixels). 5889 doc: /* Width of this buffer's right fringe (in pixels).
5916A value of 0 means no right fringe is shown in this buffer's window. 5890A value of 0 means no right fringe is shown in this buffer's window.
5917A value of nil means to use the right fringe width from the window's frame. */); 5891A value of nil means to use the right fringe width from the window's frame. */);
@@ -5922,7 +5896,7 @@ A value of nil means to use the right fringe width from the window's frame. */)
5922A value of nil means to display fringes between margins and buffer text. */); 5896A value of nil means to display fringes between margins and buffer text. */);
5923 5897
5924 DEFVAR_PER_BUFFER ("scroll-bar-width", &BVAR (current_buffer, scroll_bar_width), 5898 DEFVAR_PER_BUFFER ("scroll-bar-width", &BVAR (current_buffer, scroll_bar_width),
5925 Qnil, 5899 Qintegerp,
5926 doc: /* Width of this buffer's scroll bars in pixels. 5900 doc: /* Width of this buffer's scroll bars in pixels.
5927A value of nil means to use the scroll bar width from the window's frame. */); 5901A value of nil means to use the scroll bar width from the window's frame. */);
5928 5902
@@ -6002,7 +5976,7 @@ BITMAP is the corresponding fringe bitmap shown for the logical
6002cursor type. */); 5976cursor type. */);
6003 5977
6004 DEFVAR_PER_BUFFER ("scroll-up-aggressively", 5978 DEFVAR_PER_BUFFER ("scroll-up-aggressively",
6005 &BVAR (current_buffer, scroll_up_aggressively), Qnil, 5979 &BVAR (current_buffer, scroll_up_aggressively), Qfloatp,
6006 doc: /* How far to scroll windows upward. 5980 doc: /* How far to scroll windows upward.
6007If you move point off the bottom, the window scrolls automatically. 5981If you move point off the bottom, the window scrolls automatically.
6008This variable controls how far it scrolls. The value nil, the default, 5982This variable controls how far it scrolls. The value nil, the default,
@@ -6015,7 +5989,7 @@ window scrolls by a full window height. Meaningful values are
6015between 0.0 and 1.0, inclusive. */); 5989between 0.0 and 1.0, inclusive. */);
6016 5990
6017 DEFVAR_PER_BUFFER ("scroll-down-aggressively", 5991 DEFVAR_PER_BUFFER ("scroll-down-aggressively",
6018 &BVAR (current_buffer, scroll_down_aggressively), Qnil, 5992 &BVAR (current_buffer, scroll_down_aggressively), Qfloatp,
6019 doc: /* How far to scroll windows downward. 5993 doc: /* How far to scroll windows downward.
6020If you move point off the top, the window scrolls automatically. 5994If you move point off the top, the window scrolls automatically.
6021This variable controls how far it scrolls. The value nil, the default, 5995This variable controls how far it scrolls. The value nil, the default,
@@ -6169,7 +6143,7 @@ then characters with property value PROP are invisible,
6169and they have an ellipsis as well if ELLIPSIS is non-nil. */); 6143and they have an ellipsis as well if ELLIPSIS is non-nil. */);
6170 6144
6171 DEFVAR_PER_BUFFER ("buffer-display-count", 6145 DEFVAR_PER_BUFFER ("buffer-display-count",
6172 &BVAR (current_buffer, display_count), Qnil, 6146 &BVAR (current_buffer, display_count), Qintegerp,
6173 doc: /* A number incremented each time this buffer is displayed in a window. 6147 doc: /* A number incremented each time this buffer is displayed in a window.
6174The function `set-window-buffer' increments it. */); 6148The function `set-window-buffer' increments it. */);
6175 6149
@@ -6228,7 +6202,7 @@ cursor's appearance is instead controlled by the variable
6228`cursor-in-non-selected-windows'. */); 6202`cursor-in-non-selected-windows'. */);
6229 6203
6230 DEFVAR_PER_BUFFER ("line-spacing", 6204 DEFVAR_PER_BUFFER ("line-spacing",
6231 &BVAR (current_buffer, extra_line_spacing), Qnil, 6205 &BVAR (current_buffer, extra_line_spacing), Qnumberp,
6232 doc: /* Additional space to put between lines when displaying a buffer. 6206 doc: /* Additional space to put between lines when displaying a buffer.
6233The space is measured in pixels, and put below lines on graphic displays, 6207The space is measured in pixels, and put below lines on graphic displays,
6234see `display-graphic-p'. 6208see `display-graphic-p'.