aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKarl Heuer1997-02-20 06:44:32 +0000
committerKarl Heuer1997-02-20 06:44:32 +0000
commit3b06f8809cce0dcd6e8ae9a05a2fbeb3712c4bcc (patch)
tree3b6e41c2144167e596021a1b2ed3ca5f0ab4c6fa
parent38a1965a3fb0a972e0f70a19ba61acdb9777d233 (diff)
downloademacs-3b06f8809cce0dcd6e8ae9a05a2fbeb3712c4bcc.tar.gz
emacs-3b06f8809cce0dcd6e8ae9a05a2fbeb3712c4bcc.zip
Include charset.h.
(Fget_buffer_create): Allocate an extra byte for a buffer, and make it always 0 for anchoring. (reset_buffer): Handle a new member `enable_multibyte_characters' in the struct buffer. (fix_overlay_before): New function. (init_buffer_once): Handle new members in the struct buffer. (syms_of_buffer): Declare new buffer local variables `enable-multibyte-characters' and `direction-reserved'.
-rw-r--r--src/buffer.c101
1 files changed, 100 insertions, 1 deletions
diff --git a/src/buffer.c b/src/buffer.c
index 2c3ffdce136..7d1f28ad2c1 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -35,6 +35,7 @@ Boston, MA 02111-1307, USA. */
35#include "window.h" 35#include "window.h"
36#include "commands.h" 36#include "commands.h"
37#include "buffer.h" 37#include "buffer.h"
38#include "charset.h"
38#include "region-cache.h" 39#include "region-cache.h"
39#include "indent.h" 40#include "indent.h"
40#include "blockinput.h" 41#include "blockinput.h"
@@ -302,7 +303,9 @@ The value is never nil.")
302 303
303 BUF_GAP_SIZE (b) = 20; 304 BUF_GAP_SIZE (b) = 20;
304 BLOCK_INPUT; 305 BLOCK_INPUT;
305 BUFFER_ALLOC (BUF_BEG_ADDR (b), BUF_GAP_SIZE (b)); 306 /* We allocate extra 1-byte at the tail and keep it always '\0' for
307 anchoring a search. */
308 BUFFER_ALLOC (BUF_BEG_ADDR (b), (BUF_GAP_SIZE (b) + 1));
306 UNBLOCK_INPUT; 309 UNBLOCK_INPUT;
307 if (! BUF_BEG_ADDR (b)) 310 if (! BUF_BEG_ADDR (b))
308 buffer_memory_full (); 311 buffer_memory_full ();
@@ -316,6 +319,7 @@ The value is never nil.")
316 BUF_OVERLAY_MODIFF (b) = 1; 319 BUF_OVERLAY_MODIFF (b) = 1;
317 BUF_SAVE_MODIFF (b) = 1; 320 BUF_SAVE_MODIFF (b) = 1;
318 BUF_INTERVALS (b) = 0; 321 BUF_INTERVALS (b) = 0;
322 *(BUF_GPT_ADDR (b)) = *(BUF_Z_ADDR (b)) = 0; /* Put an anchor '\0'. */
319 323
320 b->newline_cache = 0; 324 b->newline_cache = 0;
321 b->width_run_cache = 0; 325 b->width_run_cache = 0;
@@ -472,6 +476,7 @@ reset_buffer (b)
472 b->mark_active = Qnil; 476 b->mark_active = Qnil;
473 b->point_before_scroll = Qnil; 477 b->point_before_scroll = Qnil;
474 b->file_format = Qnil; 478 b->file_format = Qnil;
479 b->enable_multibyte_characters = Qt;
475 b->last_selected_window = Qnil; 480 b->last_selected_window = Qnil;
476 b->extra2 = Qnil; 481 b->extra2 = Qnil;
477 b->extra3 = Qnil; 482 b->extra3 = Qnil;
@@ -2514,6 +2519,81 @@ fix_overlays_in_range (start, end)
2514 recenter_overlay_lists (current_buffer, 2519 recenter_overlay_lists (current_buffer,
2515 XINT (current_buffer->overlay_center)); 2520 XINT (current_buffer->overlay_center));
2516} 2521}
2522
2523/* We have two types of overlay: the one whose ending marker is
2524 after-insertion-marker (this is the usual case) and the one whose
2525 ending marker is before-insertion-marker. When `overlays_before'
2526 contains overlays of the latter type and the former type in this
2527 order and both overlays end at inserting position, inserting a text
2528 increases only the ending marker of the latter type, which results
2529 in incorrect ordering of `overlays_before'.
2530
2531 This function fixes ordering of overlays in the slot
2532 `overlays_before' of the buffer *BP. Before the insertion, `point'
2533 was at PREV, and now is at POS. */
2534
2535fix_overlays_before (bp, prev, pos)
2536 struct buffer *bp;
2537 int prev, pos;
2538{
2539 Lisp_Object *tailp = &bp->overlays_before;
2540 Lisp_Object *right_place;
2541 int end;
2542
2543 /* After the insertion, the several overlays may be in incorrect
2544 order. The possibility is that, in the list `overlays_before',
2545 an overlay which ends at POS appears after an overlay which ends
2546 at PREV. Since POS is greater than PREV, we must fix the
2547 ordering of these overlays, by moving overlays ends at POS before
2548 the overlays ends at PREV. */
2549
2550 /* At first, find a place where disordered overlays should be linked
2551 in. It is where an overlay which end before POS exists. (i.e. an
2552 overlay whose ending marker is after-insertion-marker if disorder
2553 exists). */
2554 while (!NILP (*tailp)
2555 && ((end = OVERLAY_POSITION (OVERLAY_END (XCONS (*tailp)->car)))
2556 >= pos))
2557 tailp = &XCONS (*tailp)->cdr;
2558
2559 /* If we don't find such an overlay,
2560 or the found one ends before PREV,
2561 or the found one is the last one in the list,
2562 we don't have to fix anything. */
2563 if (NILP (*tailp)
2564 || end < prev
2565 || NILP (XCONS (*tailp)->cdr))
2566 return;
2567
2568 right_place = tailp;
2569 tailp = &XCONS (*tailp)->cdr;
2570
2571 /* Now, end position of overlays in the list *TAILP should be before
2572 or equal to PREV. In the loop, an overlay which ends at POS is
2573 moved ahead to the place pointed by RIGHT_PLACE. If we found an
2574 overlay which ends before PREV, the remaining overlays are in
2575 correct order. */
2576 while (!NILP (*tailp))
2577 {
2578 end = OVERLAY_POSITION (OVERLAY_END (XCONS (*tailp)->car));
2579
2580 if (end == pos)
2581 { /* This overlay is disordered. */
2582 Lisp_Object found = *tailp;
2583
2584 /* Unlink the found overlay. */
2585 *tailp = XCONS (found)->cdr;
2586 /* Move an overlay at RIGHT_PLACE to the next of the found one. */
2587 XCONS (found)->cdr = *right_place;
2588 /* Link it into the right place. */
2589 *right_place = found;
2590 }
2591 else if (end == prev)
2592 tailp = &XCONS (*tailp)->cdr;
2593 else /* No more disordered overlay. */
2594 break;
2595 }
2596}
2517 2597
2518DEFUN ("overlayp", Foverlayp, Soverlayp, 1, 1, 0, 2598DEFUN ("overlayp", Foverlayp, Soverlayp, 1, 1, 0,
2519 "Return t if OBJECT is an overlay.") 2599 "Return t if OBJECT is an overlay.")
@@ -3432,6 +3512,7 @@ init_buffer_once ()
3432 XSETFASTINT (buffer_defaults.tab_width, 8); 3512 XSETFASTINT (buffer_defaults.tab_width, 8);
3433 buffer_defaults.truncate_lines = Qnil; 3513 buffer_defaults.truncate_lines = Qnil;
3434 buffer_defaults.ctl_arrow = Qt; 3514 buffer_defaults.ctl_arrow = Qt;
3515 buffer_defaults.direction_reversed = Qnil;
3435 3516
3436#ifdef DOS_NT 3517#ifdef DOS_NT
3437 buffer_defaults.buffer_file_type = Qnil; /* TEXT */ 3518 buffer_defaults.buffer_file_type = Qnil; /* TEXT */
@@ -3465,6 +3546,7 @@ init_buffer_once ()
3465 XSETINT (buffer_local_flags.file_truename, -1); 3546 XSETINT (buffer_local_flags.file_truename, -1);
3466 XSETINT (buffer_local_flags.invisibility_spec, -1); 3547 XSETINT (buffer_local_flags.invisibility_spec, -1);
3467 XSETINT (buffer_local_flags.file_format, -1); 3548 XSETINT (buffer_local_flags.file_format, -1);
3549 XSETINT (buffer_local_flags.enable_multibyte_characters, -1);
3468 3550
3469 XSETFASTINT (buffer_local_flags.mode_line_format, 1); 3551 XSETFASTINT (buffer_local_flags.mode_line_format, 1);
3470 XSETFASTINT (buffer_local_flags.abbrev_mode, 2); 3552 XSETFASTINT (buffer_local_flags.abbrev_mode, 2);
@@ -3489,6 +3571,8 @@ init_buffer_once ()
3489#endif 3571#endif
3490 XSETFASTINT (buffer_local_flags.syntax_table, 0x8000); 3572 XSETFASTINT (buffer_local_flags.syntax_table, 0x8000);
3491 XSETFASTINT (buffer_local_flags.cache_long_line_scans, 0x10000); 3573 XSETFASTINT (buffer_local_flags.cache_long_line_scans, 0x10000);
3574 XSETFASTINT (buffer_local_flags.category_table, 0x20000);
3575 XSETFASTINT (buffer_local_flags.direction_reversed, 0x40000);
3492 3576
3493 Vbuffer_alist = Qnil; 3577 Vbuffer_alist = Qnil;
3494 current_buffer = 0; 3578 current_buffer = 0;
@@ -3629,6 +3713,11 @@ This is the same as (default-value 'abbrev-mode).");
3629 "Default value of `ctl-arrow' for buffers that do not override it.\n\ 3713 "Default value of `ctl-arrow' for buffers that do not override it.\n\
3630This is the same as (default-value 'ctl-arrow)."); 3714This is the same as (default-value 'ctl-arrow).");
3631 3715
3716 DEFVAR_LISP_NOPRO ("default-direction-reversed",
3717 &buffer_defaults.direction_reversed,
3718 "Default value of `direction_reversed' for buffers that do not override it.\n\
3719 This is the same as (default-value 'direction-reversed).");
3720
3632 DEFVAR_LISP_NOPRO ("default-truncate-lines", 3721 DEFVAR_LISP_NOPRO ("default-truncate-lines",
3633 &buffer_defaults.truncate_lines, 3722 &buffer_defaults.truncate_lines,
3634 "Default value of `truncate-lines' for buffers that do not override it.\n\ 3723 "Default value of `truncate-lines' for buffers that do not override it.\n\
@@ -3746,6 +3835,16 @@ Automatically becomes buffer-local when set in any fashion.\n\
3746This variable does not apply to characters whose display is specified\n\ 3835This variable does not apply to characters whose display is specified\n\
3747in the current display table (if there is one)."); 3836in the current display table (if there is one).");
3748 3837
3838 DEFVAR_PER_BUFFER ("enable-multibyte-characters",
3839 &current_buffer->enable_multibyte_characters, Qnil,
3840 "Non-nil means the buffer contents are regarded as multi-byte form\n\
3841of characters, not a binary code. This affects the display, file I/O,\n\
3842and behaviors of various editing commands.");
3843
3844 DEFVAR_PER_BUFFER ("direction-reversed", &current_buffer->direction_reversed,
3845 Qnil,
3846 "*Non-nil means lines in the buffer are displayed right to left.");
3847
3749 DEFVAR_PER_BUFFER ("truncate-lines", &current_buffer->truncate_lines, Qnil, 3848 DEFVAR_PER_BUFFER ("truncate-lines", &current_buffer->truncate_lines, Qnil,
3750 "*Non-nil means do not display continuation lines;\n\ 3849 "*Non-nil means do not display continuation lines;\n\
3751give each line of text one screen line.\n\ 3850give each line of text one screen line.\n\