comparison src/buffer.c @ 9403:9f797989b817

* buffer.c: #include region-cache.h. (Fget_buffer_create): Initialize new members of struct buffer. (Fkill_buffer): Free memory occupied by caches. (init_buffer_once): Set default value for cache_long_line_scans in buffer_defaults, and give it a bit in buffer_local_flags. (syms_of_buffer): Add DEFVAR_PER_BUFFER for cache_long_line_scans.
author Jim Blandy <jimb@redhat.com>
date Sat, 08 Oct 1994 22:12:12 +0000
parents f6dc29e7e986
children b429144f6ace
comparison
equal deleted inserted replaced
9402:87337d65aa17 9403:9f797989b817
32 #include "lisp.h" 32 #include "lisp.h"
33 #include "intervals.h" 33 #include "intervals.h"
34 #include "window.h" 34 #include "window.h"
35 #include "commands.h" 35 #include "commands.h"
36 #include "buffer.h" 36 #include "buffer.h"
37 #include "region-cache.h"
37 #include "indent.h" 38 #include "indent.h"
38 #include "blockinput.h" 39 #include "blockinput.h"
39 40
40 struct buffer *current_buffer; /* the current buffer */ 41 struct buffer *current_buffer; /* the current buffer */
41 42
245 BUF_GPT (b) = 1; 246 BUF_GPT (b) = 1;
246 BUF_BEGV (b) = 1; 247 BUF_BEGV (b) = 1;
247 BUF_ZV (b) = 1; 248 BUF_ZV (b) = 1;
248 BUF_Z (b) = 1; 249 BUF_Z (b) = 1;
249 BUF_MODIFF (b) = 1; 250 BUF_MODIFF (b) = 1;
251
252 b->newline_cache = 0;
253 b->width_run_cache = 0;
254 b->width_table = Qnil;
250 255
251 /* Put this on the chain of all buffers including killed ones. */ 256 /* Put this on the chain of all buffers including killed ones. */
252 b->next = all_buffers; 257 b->next = all_buffers;
253 all_buffers = b; 258 all_buffers = b;
254 259
838 /* Perhaps we should explicitly free the interval tree here... */ 843 /* Perhaps we should explicitly free the interval tree here... */
839 844
840 b->name = Qnil; 845 b->name = Qnil;
841 BLOCK_INPUT; 846 BLOCK_INPUT;
842 BUFFER_FREE (BUF_BEG_ADDR (b)); 847 BUFFER_FREE (BUF_BEG_ADDR (b));
848 if (b->newline_cache)
849 {
850 free_region_cache (b->newline_cache);
851 b->newline_cache = 0;
852 }
853 if (b->width_run_cache)
854 {
855 free_region_cache (b->width_run_cache);
856 b->width_run_cache = 0;
857 }
858 b->width_table = Qnil;
843 UNBLOCK_INPUT; 859 UNBLOCK_INPUT;
844 b->undo_list = Qnil; 860 b->undo_list = Qnil;
845 861
846 return Qt; 862 return Qt;
847 } 863 }
2477 #ifdef MSDOS 2493 #ifdef MSDOS
2478 buffer_defaults.buffer_file_type = Qnil; /* TEXT */ 2494 buffer_defaults.buffer_file_type = Qnil; /* TEXT */
2479 #endif 2495 #endif
2480 XSETFASTINT (buffer_defaults.fill_column, 70); 2496 XSETFASTINT (buffer_defaults.fill_column, 70);
2481 XSETFASTINT (buffer_defaults.left_margin, 0); 2497 XSETFASTINT (buffer_defaults.left_margin, 0);
2498 buffer_defaults.cache_long_line_scans = Qnil;
2482 2499
2483 /* Assign the local-flags to the slots that have default values. 2500 /* Assign the local-flags to the slots that have default values.
2484 The local flag is a bit that is used in the buffer 2501 The local flag is a bit that is used in the buffer
2485 to say that it has its own local value for the slot. 2502 to say that it has its own local value for the slot.
2486 The local flag bits are in the local_var_flags slot of the buffer. */ 2503 The local flag bits are in the local_var_flags slot of the buffer. */
2516 XSETFASTINT (buffer_local_flags.fill_column, 0x400); 2533 XSETFASTINT (buffer_local_flags.fill_column, 0x400);
2517 XSETFASTINT (buffer_local_flags.left_margin, 0x800); 2534 XSETFASTINT (buffer_local_flags.left_margin, 0x800);
2518 XSETFASTINT (buffer_local_flags.abbrev_table, 0x1000); 2535 XSETFASTINT (buffer_local_flags.abbrev_table, 0x1000);
2519 XSETFASTINT (buffer_local_flags.display_table, 0x2000); 2536 XSETFASTINT (buffer_local_flags.display_table, 0x2000);
2520 XSETFASTINT (buffer_local_flags.syntax_table, 0x8000); 2537 XSETFASTINT (buffer_local_flags.syntax_table, 0x8000);
2538 XSETFASTINT (buffer_local_flags.cache_long_line_scans, 0x10000);
2521 #ifdef MSDOS 2539 #ifdef MSDOS
2522 XSETFASTINT (buffer_local_flags.buffer_file_type, 0x4000); 2540 XSETFASTINT (buffer_local_flags.buffer_file_type, 0x4000);
2523 #endif 2541 #endif
2524 2542
2525 Vbuffer_alist = Qnil; 2543 Vbuffer_alist = Qnil;
2969 2987
2970 DEFVAR_PER_BUFFER ("mark-active", &current_buffer->mark_active, Qnil, 2988 DEFVAR_PER_BUFFER ("mark-active", &current_buffer->mark_active, Qnil,
2971 "Non-nil means the mark and region are currently active in this buffer.\n\ 2989 "Non-nil means the mark and region are currently active in this buffer.\n\
2972 Automatically local in all buffers."); 2990 Automatically local in all buffers.");
2973 2991
2992 DEFVAR_PER_BUFFER ("cache-long-line-scans", &current_buffer->cache_long_line_scans, Qnil,
2993 "Non-nil means that Emacs should use caches to handle long lines faster.\n\
2994 \n\
2995 Emacs moves from one line to the next by scanning the buffer for\n\
2996 newlines, and it implements columnar operations like move-to-column by\n\
2997 scanning the buffer, adding character widths as it goes. If the\n\
2998 buffer's lines are very long (say, more than 500 characters), these\n\
2999 scans can slow Emacs down a great deal.\n\
3000 \n\
3001 If this variable is non-nil, Emacs caches the results of its scans,\n\
3002 and avoids rescanning regions of the buffer until they are modified.\n\
3003 \n\
3004 If this variable is non-nil, short scans will become slightly slower,\n\
3005 and the caches will use memory roughly proportional to the number of\n\
3006 newlines and characters whose visual representation can occupy more than\n\
3007 one column.");
3008
2974 DEFVAR_LISP ("transient-mark-mode", &Vtransient_mark_mode, 3009 DEFVAR_LISP ("transient-mark-mode", &Vtransient_mark_mode,
2975 "*Non-nil means deactivate the mark when the buffer contents change."); 3010 "*Non-nil means deactivate the mark when the buffer contents change.");
2976 Vtransient_mark_mode = Qnil; 3011 Vtransient_mark_mode = Qnil;
2977 3012
2978 DEFVAR_LISP ("inhibit-read-only", &Vinhibit_read_only, 3013 DEFVAR_LISP ("inhibit-read-only", &Vinhibit_read_only,