aboutsummaryrefslogtreecommitdiffstats
path: root/src/buffer.c
diff options
context:
space:
mode:
authorKenichi Handa2004-04-16 12:51:06 +0000
committerKenichi Handa2004-04-16 12:51:06 +0000
commit6b61353c0a0320ee15bb6488149735381fed62ec (patch)
treee69adba60e504a5a37beb556ad70084de88a7aab /src/buffer.c
parentdc6a28319312fe81f7a1015e363174022313f0bd (diff)
downloademacs-6b61353c0a0320ee15bb6488149735381fed62ec.tar.gz
emacs-6b61353c0a0320ee15bb6488149735381fed62ec.zip
Sync to HEAD
Diffstat (limited to 'src/buffer.c')
-rw-r--r--src/buffer.c124
1 files changed, 84 insertions, 40 deletions
diff --git a/src/buffer.c b/src/buffer.c
index b7efdbe5504..4c7e709adb5 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -1,5 +1,5 @@
1/* Buffer manipulation primitives for GNU Emacs. 1/* Buffer manipulation primitives for GNU Emacs.
2 Copyright (C) 1985,86,87,88,89,93,94,95,97,98, 1999, 2000, 2001, 02, 2003 2 Copyright (C) 1985,86,87,88,89,93,94,95,97,98, 1999, 2000, 2001, 02, 03, 2004
3 Free Software Foundation, Inc. 3 Free Software Foundation, Inc.
4 4
5This file is part of GNU Emacs. 5This file is part of GNU Emacs.
@@ -67,7 +67,7 @@ struct buffer *all_buffers;
67 Setting the default value also goes through the alist of buffers 67 Setting the default value also goes through the alist of buffers
68 and stores into each buffer that does not say it has a local value. */ 68 and stores into each buffer that does not say it has a local value. */
69 69
70struct buffer buffer_defaults; 70DECL_ALIGN (struct buffer, buffer_defaults);
71 71
72/* A Lisp_Object pointer to the above, used for staticpro */ 72/* A Lisp_Object pointer to the above, used for staticpro */
73 73
@@ -89,10 +89,6 @@ static Lisp_Object Vbuffer_defaults;
89 If a slot is -2, then there is no DEFVAR_PER_BUFFER for it, 89 If a slot is -2, then there is no DEFVAR_PER_BUFFER for it,
90 but there is a default value which is copied into each buffer. 90 but there is a default value which is copied into each buffer.
91 91
92 If a slot in this structure is negative, then even though there may
93 be a DEFVAR_PER_BUFFER for the slot, there is no default value for it;
94 and the corresponding slot in buffer_defaults is not used.
95
96 If a slot in this structure corresponding to a DEFVAR_PER_BUFFER is 92 If a slot in this structure corresponding to a DEFVAR_PER_BUFFER is
97 zero, that is a bug */ 93 zero, that is a bug */
98 94
@@ -101,7 +97,8 @@ struct buffer buffer_local_flags;
101/* This structure holds the names of symbols whose values may be 97/* This structure holds the names of symbols whose values may be
102 buffer-local. It is indexed and accessed in the same way as the above. */ 98 buffer-local. It is indexed and accessed in the same way as the above. */
103 99
104struct buffer buffer_local_symbols; 100DECL_ALIGN (struct buffer, buffer_local_symbols);
101
105/* A Lisp_Object pointer to the above, used for staticpro */ 102/* A Lisp_Object pointer to the above, used for staticpro */
106static Lisp_Object Vbuffer_local_symbols; 103static Lisp_Object Vbuffer_local_symbols;
107 104
@@ -525,7 +522,7 @@ DEFUN ("make-indirect-buffer", Fmake_indirect_buffer, Smake_indirect_buffer,
525 2, 3, 522 2, 3,
526 "bMake indirect buffer (to buffer): \nBName of indirect buffer: ", 523 "bMake indirect buffer (to buffer): \nBName of indirect buffer: ",
527 doc: /* Create and return an indirect buffer for buffer BASE-BUFFER, named NAME. 524 doc: /* Create and return an indirect buffer for buffer BASE-BUFFER, named NAME.
528BASE-BUFFER should be an existing buffer (or buffer name). 525BASE-BUFFER should be a live buffer, or the name of an existing buffer.
529NAME should be a string which is not the name of an existing buffer. 526NAME should be a string which is not the name of an existing buffer.
530Optional argument CLONE non-nil means preserve BASE-BUFFER's state, 527Optional argument CLONE non-nil means preserve BASE-BUFFER's state,
531such as major and minor modes, in the indirect buffer. 528such as major and minor modes, in the indirect buffer.
@@ -533,16 +530,20 @@ CLONE nil means the indirect buffer's state is reset to default values. */)
533 (base_buffer, name, clone) 530 (base_buffer, name, clone)
534 Lisp_Object base_buffer, name, clone; 531 Lisp_Object base_buffer, name, clone;
535{ 532{
536 Lisp_Object buf; 533 Lisp_Object buf, tem;
537 struct buffer *b; 534 struct buffer *b;
538 535
536 CHECK_STRING (name);
539 buf = Fget_buffer (name); 537 buf = Fget_buffer (name);
540 if (!NILP (buf)) 538 if (!NILP (buf))
541 error ("Buffer name `%s' is in use", SDATA (name)); 539 error ("Buffer name `%s' is in use", SDATA (name));
542 540
541 tem = base_buffer;
543 base_buffer = Fget_buffer (base_buffer); 542 base_buffer = Fget_buffer (base_buffer);
544 if (NILP (base_buffer)) 543 if (NILP (base_buffer))
545 error ("No such buffer: `%s'", SDATA (name)); 544 error ("No such buffer: `%s'", SDATA (tem));
545 if (NILP (XBUFFER (base_buffer)->name))
546 error ("Base buffer has been killed");
546 547
547 if (SCHARS (name) == 0) 548 if (SCHARS (name) == 0)
548 error ("Empty string for buffer name is not allowed"); 549 error ("Empty string for buffer name is not allowed");
@@ -656,7 +657,7 @@ delete_all_overlays (b)
656} 657}
657 658
658/* Reinitialize everything about a buffer except its name and contents 659/* Reinitialize everything about a buffer except its name and contents
659 and local variables. 660 and local variables.
660 If called on an already-initialized buffer, the list of overlays 661 If called on an already-initialized buffer, the list of overlays
661 should be deleted before calling this function, otherwise we end up 662 should be deleted before calling this function, otherwise we end up
662 with overlays that claim to belong to the buffer but the buffer 663 with overlays that claim to belong to the buffer but the buffer
@@ -770,7 +771,7 @@ DEFUN ("generate-new-buffer-name", Fgenerate_new_buffer_name, Sgenerate_new_buff
770 doc: /* Return a string that is the name of no existing buffer based on NAME. 771 doc: /* Return a string that is the name of no existing buffer based on NAME.
771If there is no live buffer named NAME, then return NAME. 772If there is no live buffer named NAME, then return NAME.
772Otherwise modify name by appending `<NUMBER>', incrementing NUMBER 773Otherwise modify name by appending `<NUMBER>', incrementing NUMBER
773until an unused name is found, and then return that name. 774\(starting at 2) until an unused name is found, and then return that name.
774Optional second argument IGNORE specifies a name that is okay to use 775Optional second argument IGNORE specifies a name that is okay to use
775\(if it is in the sequence to be tried) 776\(if it is in the sequence to be tried)
776even if a buffer with that name exists. */) 777even if a buffer with that name exists. */)
@@ -783,6 +784,9 @@ even if a buffer with that name exists. */)
783 784
784 CHECK_STRING (name); 785 CHECK_STRING (name);
785 786
787 tem = Fstring_equal (name, ignore);
788 if (!NILP (tem))
789 return name;
786 tem = Fget_buffer (name); 790 tem = Fget_buffer (name);
787 if (NILP (tem)) 791 if (NILP (tem))
788 return name; 792 return name;
@@ -1203,6 +1207,10 @@ If BUFFER is omitted or nil, some interesting buffer is returned. */)
1203 buf = Fcdr (XCAR (tail)); 1207 buf = Fcdr (XCAR (tail));
1204 if (EQ (buf, buffer)) 1208 if (EQ (buf, buffer))
1205 continue; 1209 continue;
1210 if (NILP (buf))
1211 continue;
1212 if (NILP (XBUFFER (buf)->name))
1213 continue;
1206 if (SREF (XBUFFER (buf)->name, 0) == ' ') 1214 if (SREF (XBUFFER (buf)->name, 0) == ' ')
1207 continue; 1215 continue;
1208 /* If the selected frame has a buffer_predicate, 1216 /* If the selected frame has a buffer_predicate,
@@ -1430,7 +1438,8 @@ with SIGHUP. */)
1430 if (STRINGP (b->auto_save_file_name) 1438 if (STRINGP (b->auto_save_file_name)
1431 && b->auto_save_modified != 0 1439 && b->auto_save_modified != 0
1432 && BUF_SAVE_MODIFF (b) < b->auto_save_modified 1440 && BUF_SAVE_MODIFF (b) < b->auto_save_modified
1433 && BUF_SAVE_MODIFF (b) < BUF_MODIFF (b)) 1441 && BUF_SAVE_MODIFF (b) < BUF_MODIFF (b)
1442 && NILP (Fsymbol_value (intern ("auto-save-visited-file-name"))))
1434 { 1443 {
1435 Lisp_Object tem; 1444 Lisp_Object tem;
1436 tem = Fsymbol_value (intern ("delete-auto-save-files")); 1445 tem = Fsymbol_value (intern ("delete-auto-save-files"));
@@ -1674,8 +1683,9 @@ DEFUN ("pop-to-buffer", Fpop_to_buffer, Spop_to_buffer, 1, 3, 0,
1674 doc: /* Select buffer BUFFER in some window, preferably a different one. 1683 doc: /* Select buffer BUFFER in some window, preferably a different one.
1675If BUFFER is nil, then some other buffer is chosen. 1684If BUFFER is nil, then some other buffer is chosen.
1676If `pop-up-windows' is non-nil, windows can be split to do this. 1685If `pop-up-windows' is non-nil, windows can be split to do this.
1677If optional second arg OTHER-WINDOW is non-nil, insist on finding another 1686If optional second arg OTHER-WINDOW is nil, insist on finding another
1678window even if BUFFER is already visible in the selected window. 1687window even if BUFFER is already visible in the selected window,
1688and ignore `same-window-regexps' and `same-window-buffer-names'.
1679This uses the function `display-buffer' as a subroutine; see the documentation 1689This uses the function `display-buffer' as a subroutine; see the documentation
1680of `display-buffer' for additional customization information. 1690of `display-buffer' for additional customization information.
1681 1691
@@ -2082,7 +2092,9 @@ If FLAG is nil, this makes the buffer a single-byte buffer.
2082In these cases, the buffer contents remain unchanged as a sequence of 2092In these cases, the buffer contents remain unchanged as a sequence of
2083bytes but the contents viewed as characters do change. 2093bytes but the contents viewed as characters do change.
2084If FLAG is `to', this makes the buffer a multibyte buffer by changing 2094If FLAG is `to', this makes the buffer a multibyte buffer by changing
2085all eight-bit bytes to eight-bit characters. */) 2095all eight-bit bytes to eight-bit characters.
2096If the multibyte flag was really changed, undo information of the
2097current buffer is cleared. */)
2086 (flag) 2098 (flag)
2087 Lisp_Object flag; 2099 Lisp_Object flag;
2088{ 2100{
@@ -3301,10 +3313,9 @@ adjust_overlays_for_delete (pos, length)
3301 endpoint in this range will need to be unlinked from the overlay 3313 endpoint in this range will need to be unlinked from the overlay
3302 list and reinserted in its proper place. 3314 list and reinserted in its proper place.
3303 Such an overlay might even have negative size at this point. 3315 Such an overlay might even have negative size at this point.
3304 If so, we'll reverse the endpoints. Can you think of anything 3316 If so, we'll make the overlay empty. */
3305 better to do in this situation? */
3306void 3317void
3307fix_overlays_in_range (start, end) 3318fix_start_end_in_overlays (start, end)
3308 register int start, end; 3319 register int start, end;
3309{ 3320{
3310 Lisp_Object overlay; 3321 Lisp_Object overlay;
@@ -3329,23 +3340,24 @@ fix_overlays_in_range (start, end)
3329 for (parent = NULL, tail = current_buffer->overlays_before; tail;) 3340 for (parent = NULL, tail = current_buffer->overlays_before; tail;)
3330 { 3341 {
3331 XSETMISC (overlay, tail); 3342 XSETMISC (overlay, tail);
3343
3332 endpos = OVERLAY_POSITION (OVERLAY_END (overlay)); 3344 endpos = OVERLAY_POSITION (OVERLAY_END (overlay));
3345 startpos = OVERLAY_POSITION (OVERLAY_START (overlay));
3346
3347 /* If the overlay is backwards, make it empty. */
3348 if (endpos < startpos)
3349 {
3350 startpos = endpos;
3351 Fset_marker (OVERLAY_START (overlay), make_number (startpos),
3352 Qnil);
3353 }
3354
3333 if (endpos < start) 3355 if (endpos < start)
3334 break; 3356 break;
3335 startpos = OVERLAY_POSITION (OVERLAY_START (overlay)); 3357
3336 if (endpos < end 3358 if (endpos < end
3337 || (startpos >= start && startpos < end)) 3359 || (startpos >= start && startpos < end))
3338 { 3360 {
3339 /* If the overlay is backwards, fix that now. */
3340 if (startpos > endpos)
3341 {
3342 int tem;
3343 Fset_marker (OVERLAY_START (overlay), make_number (endpos),
3344 Qnil);
3345 Fset_marker (OVERLAY_END (overlay), make_number (startpos),
3346 Qnil);
3347 tem = startpos; startpos = endpos; endpos = tem;
3348 }
3349 /* Add it to the end of the wrong list. Later on, 3361 /* Add it to the end of the wrong list. Later on,
3350 recenter_overlay_lists will move it to the right place. */ 3362 recenter_overlay_lists will move it to the right place. */
3351 if (endpos < current_buffer->overlay_center) 3363 if (endpos < current_buffer->overlay_center)
@@ -3376,22 +3388,24 @@ fix_overlays_in_range (start, end)
3376 for (parent = NULL, tail = current_buffer->overlays_after; tail;) 3388 for (parent = NULL, tail = current_buffer->overlays_after; tail;)
3377 { 3389 {
3378 XSETMISC (overlay, tail); 3390 XSETMISC (overlay, tail);
3391
3379 startpos = OVERLAY_POSITION (OVERLAY_START (overlay)); 3392 startpos = OVERLAY_POSITION (OVERLAY_START (overlay));
3393 endpos = OVERLAY_POSITION (OVERLAY_END (overlay));
3394
3395 /* If the overlay is backwards, make it empty. */
3396 if (endpos < startpos)
3397 {
3398 startpos = endpos;
3399 Fset_marker (OVERLAY_START (overlay), make_number (startpos),
3400 Qnil);
3401 }
3402
3380 if (startpos >= end) 3403 if (startpos >= end)
3381 break; 3404 break;
3382 endpos = OVERLAY_POSITION (OVERLAY_END (overlay)); 3405
3383 if (startpos >= start 3406 if (startpos >= start
3384 || (endpos >= start && endpos < end)) 3407 || (endpos >= start && endpos < end))
3385 { 3408 {
3386 if (startpos > endpos)
3387 {
3388 int tem;
3389 Fset_marker (OVERLAY_START (overlay), make_number (endpos),
3390 Qnil);
3391 Fset_marker (OVERLAY_END (overlay), make_number (startpos),
3392 Qnil);
3393 tem = startpos; startpos = endpos; endpos = tem;
3394 }
3395 if (endpos < current_buffer->overlay_center) 3409 if (endpos < current_buffer->overlay_center)
3396 { 3410 {
3397 if (!afterp) 3411 if (!afterp)
@@ -4974,6 +4988,7 @@ init_buffer_once ()
4974 buffer_defaults.scroll_bar_width = Qnil; 4988 buffer_defaults.scroll_bar_width = Qnil;
4975 buffer_defaults.vertical_scroll_bar_type = Qt; 4989 buffer_defaults.vertical_scroll_bar_type = Qt;
4976 buffer_defaults.indicate_empty_lines = Qnil; 4990 buffer_defaults.indicate_empty_lines = Qnil;
4991 buffer_defaults.indicate_buffer_boundaries = Qnil;
4977 buffer_defaults.scroll_up_aggressively = Qnil; 4992 buffer_defaults.scroll_up_aggressively = Qnil;
4978 buffer_defaults.scroll_down_aggressively = Qnil; 4993 buffer_defaults.scroll_down_aggressively = Qnil;
4979 buffer_defaults.display_time = Qnil; 4994 buffer_defaults.display_time = Qnil;
@@ -5043,6 +5058,7 @@ init_buffer_once ()
5043 XSETFASTINT (buffer_local_flags.scroll_bar_width, idx); ++idx; 5058 XSETFASTINT (buffer_local_flags.scroll_bar_width, idx); ++idx;
5044 XSETFASTINT (buffer_local_flags.vertical_scroll_bar_type, idx); ++idx; 5059 XSETFASTINT (buffer_local_flags.vertical_scroll_bar_type, idx); ++idx;
5045 XSETFASTINT (buffer_local_flags.indicate_empty_lines, idx); ++idx; 5060 XSETFASTINT (buffer_local_flags.indicate_empty_lines, idx); ++idx;
5061 XSETFASTINT (buffer_local_flags.indicate_buffer_boundaries, idx); ++idx;
5046 XSETFASTINT (buffer_local_flags.scroll_up_aggressively, idx); ++idx; 5062 XSETFASTINT (buffer_local_flags.scroll_up_aggressively, idx); ++idx;
5047 XSETFASTINT (buffer_local_flags.scroll_down_aggressively, idx); ++idx; 5063 XSETFASTINT (buffer_local_flags.scroll_down_aggressively, idx); ++idx;
5048 XSETFASTINT (buffer_local_flags.header_line_format, idx); ++idx; 5064 XSETFASTINT (buffer_local_flags.header_line_format, idx); ++idx;
@@ -5331,6 +5347,11 @@ This is the same as (default-value 'vertical-scroll-bar). */);
5331 doc: /* Default value of `indicate-empty-lines' for buffers that don't override it. 5347 doc: /* Default value of `indicate-empty-lines' for buffers that don't override it.
5332This is the same as (default-value 'indicate-empty-lines). */); 5348This is the same as (default-value 'indicate-empty-lines). */);
5333 5349
5350 DEFVAR_LISP_NOPRO ("default-indicate-buffer-boundaries",
5351 &buffer_defaults.indicate_buffer_boundaries,
5352 doc: /* Default value of `indicate-buffer-boundaries' for buffers that don't override it.
5353This is the same as (default-value 'indicate-buffer-boundaries). */);
5354
5334 DEFVAR_LISP_NOPRO ("default-scroll-up-aggressively", 5355 DEFVAR_LISP_NOPRO ("default-scroll-up-aggressively",
5335 &buffer_defaults.scroll_up_aggressively, 5356 &buffer_defaults.scroll_up_aggressively,
5336 doc: /* Default value of `scroll-up-aggressively'. 5357 doc: /* Default value of `scroll-up-aggressively'.
@@ -5388,6 +5409,8 @@ A string is printed verbatim in the mode line except for %-constructs:
5388 %c -- print the current column number (this makes editing slower). 5409 %c -- print the current column number (this makes editing slower).
5389 To make the column number update correctly in all cases, 5410 To make the column number update correctly in all cases,
5390 `column-number-mode' must be non-nil. 5411 `column-number-mode' must be non-nil.
5412 %i -- print the size of the buffer.
5413 %I -- like %i, but use k, M, G, etc., to abbreviate.
5391 %p -- print percent of buffer above top of window, or Top, Bot or All. 5414 %p -- print percent of buffer above top of window, or Top, Bot or All.
5392 %P -- print percent of buffer above bottom of window, perhaps plus Top, 5415 %P -- print percent of buffer above bottom of window, perhaps plus Top,
5393 or print Bottom or All. 5416 or print Bottom or All.
@@ -5639,6 +5662,24 @@ A value of t means to use the vertical scroll bar type from the window's frame.
5639If non-nil, a bitmap is displayed in the left fringe of a window on 5662If non-nil, a bitmap is displayed in the left fringe of a window on
5640window-systems. */); 5663window-systems. */);
5641 5664
5665 DEFVAR_PER_BUFFER ("indicate-buffer-boundaries",
5666 &current_buffer->indicate_buffer_boundaries, Qnil,
5667 doc: /* *Visually indicate buffer boundaries and scrolling.
5668If non-nil, the first and last line of the buffer are marked in the fringe
5669of a window on window-systems with angle bitmaps, or if the window can be
5670scrolled, the top and bottom line of the window are marked with up and down
5671arrow bitmaps.
5672If value is `left' or `right', both angle and arrow bitmaps are displayed in
5673the left or right fringe, resp. Any other non-nil value causes the
5674bitmap on the top line to be displayed in the left fringe, and the
5675bitmap on the bottom line in the right fringe.
5676If value is a cons (ANGLES . ARROWS), the car specifies the position
5677of the angle bitmaps, and the cdr specifies the position of the arrow
5678bitmaps. For example, (t . right) places the top angle bitmap in left
5679fringe, the bottom angle bitmap in right fringe, and both arrow
5680bitmaps in right fringe. To show just the angle bitmaps in the left
5681fringe, but no arrow bitmaps, use (left . nil). */);
5682
5642 DEFVAR_PER_BUFFER ("scroll-up-aggressively", 5683 DEFVAR_PER_BUFFER ("scroll-up-aggressively",
5643 &current_buffer->scroll_up_aggressively, Qnil, 5684 &current_buffer->scroll_up_aggressively, Qnil,
5644 doc: /* How far to scroll windows upward. 5685 doc: /* How far to scroll windows upward.
@@ -5907,3 +5948,6 @@ keys_of_buffer ()
5907 initialized when that function gets called. */ 5948 initialized when that function gets called. */
5908 Fput (intern ("erase-buffer"), Qdisabled, Qt); 5949 Fput (intern ("erase-buffer"), Qdisabled, Qt);
5909} 5950}
5951
5952/* arch-tag: e48569bf-69a9-4b65-a23b-8e68769436e1
5953 (do not change this comment) */