From d35af63cd671563fd188c3b0a1ef30067027c7aa Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Fri, 22 Jun 2012 14:17:42 -0700 Subject: Support higher-resolution time stamps. Fixes: debbugs:9000 --- src/buffer.h | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'src/buffer.h') diff --git a/src/buffer.h b/src/buffer.h index 8e0604e90c2..97b45e15387 100644 --- a/src/buffer.h +++ b/src/buffer.h @@ -19,6 +19,7 @@ You should have received a copy of the GNU General Public License along with GNU Emacs. If not, see . */ #include /* for off_t, time_t */ +#include "systime.h" /* for EMACS_TIME */ /* Accessing the parameters of the current buffer. */ @@ -529,10 +530,13 @@ struct buffer char local_flags[MAX_PER_BUFFER_VARS]; /* Set to the modtime of the visited file when read or written. - -1 means visited file was nonexistent. - 0 means visited file modtime unknown; in no case complain - about any mismatch on next save attempt. */ - time_t modtime; + EMACS_NSECS (modtime) == NONEXISTENT_MODTIME_NSECS means + visited file was nonexistent. EMACS_NSECS (modtime) == + UNKNOWN_MODTIME_NSECS means visited file modtime unknown; + in no case complain about any mismatch on next save attempt. */ +#define NONEXISTENT_MODTIME_NSECS (-1) +#define UNKNOWN_MODTIME_NSECS (-2) + EMACS_TIME modtime; /* Size of the file when modtime was set. This is used to detect the case where the file grew while we were reading it, so the modtime is still the same (since it's rounded up to seconds) but we're actually -- cgit v1.2.1 From 845ca893904e4664063cb5c121b34925386849f7 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Sun, 24 Jun 2012 10:39:14 -0700 Subject: Switch from NO_RETURN to C11's _Noreturn. Fixes: debbugs:11750 --- src/buffer.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/buffer.h') diff --git a/src/buffer.h b/src/buffer.h index 97b45e15387..b1ace4663cf 100644 --- a/src/buffer.h +++ b/src/buffer.h @@ -886,7 +886,7 @@ extern void set_buffer_internal_1 (struct buffer *); extern void set_buffer_temp (struct buffer *); extern Lisp_Object buffer_local_value_1 (Lisp_Object, Lisp_Object); extern void record_buffer (Lisp_Object); -extern void buffer_slot_type_mismatch (Lisp_Object, int) NO_RETURN; +extern _Noreturn void buffer_slot_type_mismatch (Lisp_Object, int); extern void fix_overlays_before (struct buffer *, ptrdiff_t, ptrdiff_t); extern void mmap_set_vars (int); -- cgit v1.2.1 From 36429c89cbd7282a7614a358e5edb4d37f4a3f47 Mon Sep 17 00:00:00 2001 From: Dmitry Antipov Date: Tue, 3 Jul 2012 07:57:52 +0400 Subject: Cleanup basic buffer management. * buffer.h (struct buffer): Change layout to use generic vector marking code. Fix some comments. Change type of 'clip_changed' to bitfield. Remove unused #ifndef old. (FIRST_FIELD_PER_BUFFER, LAST_FIELD_PER_BUFFER): Remove. (GET_OVERLAYS_AT): Fix indentation. (for_each_per_buffer_object_at): New macro. * buffer.c (clone_per_buffer_values, reset_buffer_local_variables) (Fbuffer_local_variables): Use it. (init_buffer_once, syms_of_buffer): Remove unused #ifndef old. * alloc.c (allocate_buffer): Adjust to match new layout of struct buffer. Fix comment. (mark_overlay): New function. (mark_buffer): Use it. Use mark_vectorlike to mark normal Lisp area of struct buffer. (mark_object): Use it. Adjust marking of misc objects and related comments. --- src/buffer.h | 310 ++++++++++++++++++++++++++++++++--------------------------- 1 file changed, 170 insertions(+), 140 deletions(-) (limited to 'src/buffer.h') diff --git a/src/buffer.h b/src/buffer.h index b1ace4663cf..b48791f306f 100644 --- a/src/buffer.h +++ b/src/buffer.h @@ -482,142 +482,26 @@ struct buffer_text struct buffer { - /* Everything before the `name' slot must be of a non-Lisp_Object type, - and every slot after `name' must be a Lisp_Object. - - Check out mark_buffer (alloc.c) to see why. */ - - /* HEADER.NEXT is the next buffer, in chain of all buffers, - including killed buffers. - This chain is used only for garbage collection, in order to - collect killed buffers properly. - Note that vectors and most pseudovectors are all on one chain, - but buffers are on a separate chain of their own. */ + /* HEADER.NEXT is the next buffer, in chain of all buffers, including killed + buffers. This chain, starting from all_buffers, is used only for garbage + collection, in order to collect killed buffers properly. Note that large + vectors and large pseudo-vector objects are all on another chain starting + from large_vectors. */ struct vectorlike_header header; - /* This structure holds the coordinates of the buffer contents - in ordinary buffers. In indirect buffers, this is not used. */ - struct buffer_text own_text; - - /* This points to the `struct buffer_text' that used for this buffer. - In an ordinary buffer, this is the own_text field above. - In an indirect buffer, this is the own_text field of another buffer. */ - struct buffer_text *text; - - /* Char position of point in buffer. */ - ptrdiff_t pt; - /* Byte position of point in buffer. */ - ptrdiff_t pt_byte; - /* Char position of beginning of accessible range. */ - ptrdiff_t begv; - /* Byte position of beginning of accessible range. */ - ptrdiff_t begv_byte; - /* Char position of end of accessible range. */ - ptrdiff_t zv; - /* Byte position of end of accessible range. */ - ptrdiff_t zv_byte; - - /* In an indirect buffer, this points to the base buffer. - In an ordinary buffer, it is 0. */ - struct buffer *base_buffer; - - /* A non-zero value in slot IDX means that per-buffer variable - with index IDX has a local value in this buffer. The index IDX - for a buffer-local variable is stored in that variable's slot - in buffer_local_flags as a Lisp integer. If the index is -1, - this means the variable is always local in all buffers. */ -#define MAX_PER_BUFFER_VARS 50 - char local_flags[MAX_PER_BUFFER_VARS]; - - /* Set to the modtime of the visited file when read or written. - EMACS_NSECS (modtime) == NONEXISTENT_MODTIME_NSECS means - visited file was nonexistent. EMACS_NSECS (modtime) == - UNKNOWN_MODTIME_NSECS means visited file modtime unknown; - in no case complain about any mismatch on next save attempt. */ -#define NONEXISTENT_MODTIME_NSECS (-1) -#define UNKNOWN_MODTIME_NSECS (-2) - EMACS_TIME modtime; - /* Size of the file when modtime was set. This is used to detect the - case where the file grew while we were reading it, so the modtime - is still the same (since it's rounded up to seconds) but we're actually - not up-to-date. -1 means the size is unknown. Only meaningful if - modtime is actually set. */ - off_t modtime_size; - /* The value of text->modiff at the last auto-save. */ - EMACS_INT auto_save_modified; - /* The value of text->modiff at the last display error. - Redisplay of this buffer is inhibited until it changes again. */ - EMACS_INT display_error_modiff; - /* The time at which we detected a failure to auto-save, - Or 0 if we didn't have a failure. */ - time_t auto_save_failure_time; - /* Position in buffer at which display started - the last time this buffer was displayed. */ - ptrdiff_t last_window_start; - - /* Set nonzero whenever the narrowing is changed in this buffer. */ - int clip_changed; - - /* If the long line scan cache is enabled (i.e. the buffer-local - variable cache-long-line-scans is non-nil), newline_cache - points to the newline cache, and width_run_cache points to the - width run cache. - - The newline cache records which stretches of the buffer are - known *not* to contain newlines, so that they can be skipped - quickly when we search for newlines. - - The width run cache records which stretches of the buffer are - known to contain characters whose widths are all the same. If - the width run cache maps a character to a value > 0, that value is - the character's width; if it maps a character to zero, we don't - know what its width is. This allows compute_motion to process - such regions very quickly, using algebra instead of inspecting - each character. See also width_table, below. */ - struct region_cache *newline_cache; - struct region_cache *width_run_cache; - - /* Non-zero means don't use redisplay optimizations for - displaying this buffer. */ - unsigned prevent_redisplay_optimizations_p : 1; - - /* List of overlays that end at or before the current center, - in order of end-position. */ - struct Lisp_Overlay *overlays_before; - - /* List of overlays that end after the current center, - in order of start-position. */ - struct Lisp_Overlay *overlays_after; - - /* Position where the overlay lists are centered. */ - ptrdiff_t overlay_center; - - /* Everything from here down must be a Lisp_Object. */ - /* buffer-local Lisp variables start at `undo_list', - tho only the ones from `name' on are GC'd normally. */ - #define FIRST_FIELD_PER_BUFFER undo_list - - /* Changes in the buffer are recorded here for undo. - t means don't record anything. - This information belongs to the base buffer of an indirect buffer, - But we can't store it in the struct buffer_text - because local variables have to be right in the struct buffer. - So we copy it around in set_buffer_internal. - This comes before `name' because it is marked in a special way. */ - Lisp_Object BUFFER_INTERNAL_FIELD (undo_list); - /* The name of this buffer. */ Lisp_Object BUFFER_INTERNAL_FIELD (name); /* The name of the file visited in this buffer, or nil. */ Lisp_Object BUFFER_INTERNAL_FIELD (filename); - /* Dir for expanding relative file names. */ + + /* Directory for expanding relative file names. */ Lisp_Object BUFFER_INTERNAL_FIELD (directory); - /* True if this buffer has been backed up (if you write to the - visited file and it hasn't been backed up, then a backup will - be made). */ - /* This isn't really used by the C code, so could be deleted. */ + + /* True if this buffer has been backed up (if you write to the visited + file and it hasn't been backed up, then a backup will be made). */ Lisp_Object BUFFER_INTERNAL_FIELD (backed_up); + /* Length of file when last read or saved. -1 means auto saving turned off because buffer shrank a lot. -2 means don't turn off auto saving if buffer shrinks. @@ -625,6 +509,7 @@ struct buffer This is not in the struct buffer_text because it's not used in indirect buffers at all. */ Lisp_Object BUFFER_INTERNAL_FIELD (save_length); + /* File name used for auto-saving this buffer. This is not in the struct buffer_text because it's not used in indirect buffers at all. */ @@ -632,6 +517,7 @@ struct buffer /* Non-nil if buffer read-only. */ Lisp_Object BUFFER_INTERNAL_FIELD (read_only); + /* "The mark". This is a marker which may point into this buffer or may point nowhere. */ Lisp_Object BUFFER_INTERNAL_FIELD (mark); @@ -641,10 +527,12 @@ struct buffer symbols, just the symbol appears as the element. */ Lisp_Object BUFFER_INTERNAL_FIELD (local_var_alist); - /* Symbol naming major mode (eg, lisp-mode). */ + /* Symbol naming major mode (e.g., lisp-mode). */ Lisp_Object BUFFER_INTERNAL_FIELD (major_mode); - /* Pretty name of major mode (eg, "Lisp"). */ + + /* Pretty name of major mode (e.g., "Lisp"). */ Lisp_Object BUFFER_INTERNAL_FIELD (mode_name); + /* Mode line element that controls format of mode line. */ Lisp_Object BUFFER_INTERNAL_FIELD (mode_line_format); @@ -654,10 +542,13 @@ struct buffer /* Keys that are bound local to this buffer. */ Lisp_Object BUFFER_INTERNAL_FIELD (keymap); + /* This buffer's local abbrev table. */ Lisp_Object BUFFER_INTERNAL_FIELD (abbrev_table); + /* This buffer's syntax table. */ Lisp_Object BUFFER_INTERNAL_FIELD (syntax_table); + /* This buffer's category table. */ Lisp_Object BUFFER_INTERNAL_FIELD (category_table); @@ -668,48 +559,61 @@ struct buffer Lisp_Object BUFFER_INTERNAL_FIELD (tab_width); Lisp_Object BUFFER_INTERNAL_FIELD (fill_column); Lisp_Object BUFFER_INTERNAL_FIELD (left_margin); + /* Function to call when insert space past fill column. */ Lisp_Object BUFFER_INTERNAL_FIELD (auto_fill_function); /* Case table for case-conversion in this buffer. This char-table maps each char into its lower-case version. */ Lisp_Object BUFFER_INTERNAL_FIELD (downcase_table); + /* Char-table mapping each char to its upper-case version. */ Lisp_Object BUFFER_INTERNAL_FIELD (upcase_table); + /* Char-table for conversion for case-folding search. */ Lisp_Object BUFFER_INTERNAL_FIELD (case_canon_table); + /* Char-table of equivalences for case-folding search. */ Lisp_Object BUFFER_INTERNAL_FIELD (case_eqv_table); /* Non-nil means do not display continuation lines. */ Lisp_Object BUFFER_INTERNAL_FIELD (truncate_lines); + /* Non-nil means to use word wrapping when displaying continuation lines. */ Lisp_Object BUFFER_INTERNAL_FIELD (word_wrap); + /* Non-nil means display ctl chars with uparrow. */ Lisp_Object BUFFER_INTERNAL_FIELD (ctl_arrow); + /* Non-nil means reorder bidirectional text for display in the visual order. */ Lisp_Object BUFFER_INTERNAL_FIELD (bidi_display_reordering); + /* If non-nil, specifies which direction of text to force in all the paragraphs of the buffer. Nil means determine paragraph direction dynamically for each paragraph. */ Lisp_Object BUFFER_INTERNAL_FIELD (bidi_paragraph_direction); + /* Non-nil means do selective display; see doc string in syms_of_buffer (buffer.c) for details. */ Lisp_Object BUFFER_INTERNAL_FIELD (selective_display); -#ifndef old + /* Non-nil means show ... at end of line followed by invisible lines. */ Lisp_Object BUFFER_INTERNAL_FIELD (selective_display_ellipses); -#endif + /* Alist of (FUNCTION . STRING) for each minor mode enabled in buffer. */ Lisp_Object BUFFER_INTERNAL_FIELD (minor_modes); + /* t if "self-insertion" should overwrite; `binary' if it should also overwrite newlines and tabs - for editing executables and the like. */ Lisp_Object BUFFER_INTERNAL_FIELD (overwrite_mode); - /* non-nil means abbrev mode is on. Expand abbrevs automatically. */ + + /* Non-nil means abbrev mode is on. Expand abbrevs automatically. */ Lisp_Object BUFFER_INTERNAL_FIELD (abbrev_mode); + /* Display table to use for text in this buffer. */ Lisp_Object BUFFER_INTERNAL_FIELD (display_table); + /* t means the mark and region are currently active. */ Lisp_Object BUFFER_INTERNAL_FIELD (mark_active); @@ -776,11 +680,13 @@ struct buffer /* Widths of left and right marginal areas for windows displaying this buffer. */ - Lisp_Object BUFFER_INTERNAL_FIELD (left_margin_cols), BUFFER_INTERNAL_FIELD (right_margin_cols); + Lisp_Object BUFFER_INTERNAL_FIELD (left_margin_cols); + Lisp_Object BUFFER_INTERNAL_FIELD (right_margin_cols); /* Widths of left and right fringe areas for windows displaying this buffer. */ - Lisp_Object BUFFER_INTERNAL_FIELD (left_fringe_width), BUFFER_INTERNAL_FIELD (right_fringe_width); + Lisp_Object BUFFER_INTERNAL_FIELD (left_fringe_width); + Lisp_Object BUFFER_INTERNAL_FIELD (right_fringe_width); /* Non-nil means fringes are drawn outside display margins; othersize draw them between margin areas and text. */ @@ -788,7 +694,8 @@ struct buffer /* Width and type of scroll bar areas for windows displaying this buffer. */ - Lisp_Object BUFFER_INTERNAL_FIELD (scroll_bar_width), BUFFER_INTERNAL_FIELD (vertical_scroll_bar_type); + Lisp_Object BUFFER_INTERNAL_FIELD (scroll_bar_width); + Lisp_Object BUFFER_INTERNAL_FIELD (vertical_scroll_bar_type); /* Non-nil means indicate lines not displaying text (in a style like vi). */ @@ -826,13 +733,127 @@ struct buffer in the display of this buffer. */ Lisp_Object BUFFER_INTERNAL_FIELD (extra_line_spacing); - /* *Cursor type to display in non-selected windows. + /* Cursor type to display in non-selected windows. t means to use hollow box cursor. See `cursor-type' for other values. */ Lisp_Object BUFFER_INTERNAL_FIELD (cursor_in_non_selected_windows); - /* This must be the last field in the above list. */ - #define LAST_FIELD_PER_BUFFER cursor_in_non_selected_windows + /* No more Lisp_Object beyond this point. Except undo_list, + which is handled specially in Fgarbage_collect . */ + + /* This structure holds the coordinates of the buffer contents + in ordinary buffers. In indirect buffers, this is not used. */ + struct buffer_text own_text; + + /* This points to the `struct buffer_text' that used for this buffer. + In an ordinary buffer, this is the own_text field above. + In an indirect buffer, this is the own_text field of another buffer. */ + struct buffer_text *text; + + /* Char position of point in buffer. */ + ptrdiff_t pt; + + /* Byte position of point in buffer. */ + ptrdiff_t pt_byte; + + /* Char position of beginning of accessible range. */ + ptrdiff_t begv; + + /* Byte position of beginning of accessible range. */ + ptrdiff_t begv_byte; + + /* Char position of end of accessible range. */ + ptrdiff_t zv; + + /* Byte position of end of accessible range. */ + ptrdiff_t zv_byte; + + /* In an indirect buffer, this points to the base buffer. + In an ordinary buffer, it is 0. */ + struct buffer *base_buffer; + + /* A non-zero value in slot IDX means that per-buffer variable + with index IDX has a local value in this buffer. The index IDX + for a buffer-local variable is stored in that variable's slot + in buffer_local_flags as a Lisp integer. If the index is -1, + this means the variable is always local in all buffers. */ +#define MAX_PER_BUFFER_VARS 50 + char local_flags[MAX_PER_BUFFER_VARS]; + + /* Set to the modtime of the visited file when read or written. + EMACS_NSECS (modtime) == NONEXISTENT_MODTIME_NSECS means + visited file was nonexistent. EMACS_NSECS (modtime) == + UNKNOWN_MODTIME_NSECS means visited file modtime unknown; + in no case complain about any mismatch on next save attempt. */ +#define NONEXISTENT_MODTIME_NSECS (-1) +#define UNKNOWN_MODTIME_NSECS (-2) + EMACS_TIME modtime; + + /* Size of the file when modtime was set. This is used to detect the + case where the file grew while we were reading it, so the modtime + is still the same (since it's rounded up to seconds) but we're actually + not up-to-date. -1 means the size is unknown. Only meaningful if + modtime is actually set. */ + off_t modtime_size; + + /* The value of text->modiff at the last auto-save. */ + EMACS_INT auto_save_modified; + + /* The value of text->modiff at the last display error. + Redisplay of this buffer is inhibited until it changes again. */ + EMACS_INT display_error_modiff; + + /* The time at which we detected a failure to auto-save, + Or 0 if we didn't have a failure. */ + time_t auto_save_failure_time; + + /* Position in buffer at which display started + the last time this buffer was displayed. */ + ptrdiff_t last_window_start; + + /* If the long line scan cache is enabled (i.e. the buffer-local + variable cache-long-line-scans is non-nil), newline_cache + points to the newline cache, and width_run_cache points to the + width run cache. + + The newline cache records which stretches of the buffer are + known *not* to contain newlines, so that they can be skipped + quickly when we search for newlines. + + The width run cache records which stretches of the buffer are + known to contain characters whose widths are all the same. If + the width run cache maps a character to a value > 0, that value is + the character's width; if it maps a character to zero, we don't + know what its width is. This allows compute_motion to process + such regions very quickly, using algebra instead of inspecting + each character. See also width_table, below. */ + struct region_cache *newline_cache; + struct region_cache *width_run_cache; + + /* Non-zero means don't use redisplay optimizations for + displaying this buffer. */ + unsigned prevent_redisplay_optimizations_p : 1; + + /* Non-zero whenever the narrowing is changed in this buffer. */ + unsigned clip_changed : 1; + + /* List of overlays that end at or before the current center, + in order of end-position. */ + struct Lisp_Overlay *overlays_before; + + /* List of overlays that end after the current center, + in order of start-position. */ + struct Lisp_Overlay *overlays_after; + + /* Position where the overlay lists are centered. */ + ptrdiff_t overlay_center; + + /* Changes in the buffer are recorded here for undo, and t means + don't record anything. This information belongs to the base + buffer of an indirect buffer. But we can't store it in the + struct buffer_text because local variables have to be right in + the struct buffer. So we copy it around in set_buffer_internal. */ + Lisp_Object BUFFER_INTERNAL_FIELD (undo_list); }; @@ -896,10 +917,10 @@ extern void mmap_set_vars (int); #define GET_OVERLAYS_AT(posn, overlays, noverlays, nextp, chrq) \ do { \ - ptrdiff_t maxlen = 40; \ + ptrdiff_t maxlen = 40; \ overlays = (Lisp_Object *) alloca (maxlen * sizeof (Lisp_Object)); \ noverlays = overlays_at (posn, 0, &overlays, &maxlen, \ - nextp, NULL, chrq); \ + nextp, NULL, chrq); \ if (noverlays > maxlen) \ { \ maxlen = noverlays; \ @@ -992,6 +1013,15 @@ extern int last_per_buffer_idx; #define PER_BUFFER_VAR_OFFSET(VAR) \ offsetof (struct buffer, BUFFER_INTERNAL_FIELD (VAR)) +/* Used to iterate over normal Lisp_Object fields of struct buffer (all + Lisp_Objects except undo_list). If you add, remove, or reorder + Lisp_Objects in a struct buffer, make sure that this is still correct. */ + +#define for_each_per_buffer_object_at(offset) \ + for (offset = PER_BUFFER_VAR_OFFSET (name); \ + offset <= PER_BUFFER_VAR_OFFSET (cursor_in_non_selected_windows); \ + offset += sizeof (Lisp_Object)) + /* Return the index of buffer-local variable VAR. Each per-buffer variable has an index > 0 associated with it, except when it always has buffer-local values, in which case the index is -1. If this is -- cgit v1.2.1 From 404dbd373a91c0b994005e88fe703d9144873b27 Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Tue, 3 Jul 2012 12:24:42 -0600 Subject: Auto-generate EXFUN using make-docfile src * window.c (Fset_window_margins, Fset_window_fringes) (Fset_window_scroll_bars, Fset_window_vscroll): No longer static. * textprop.c (Fprevious_property_change): No longer static. * syntax.c (Fsyntax_table_p): No longer static. * process.c (Fget_process, Fprocess_datagram_address): No longer static. * keymap.c (Flookup_key, Fcopy_keymap): No longer static. * keyboard.c (Fcommand_execute): No longer static. Remove EXFUN. * insdel.c (Fcombine_after_change_execute): No longer static. * image.c (Finit_image_library): No longer static. * fileio.c (Fmake_symbolic_link): No longer static. * eval.c (Ffetch_bytecode): No longer static. * editfns.c (Fuser_full_name): No longer static. * doc.c: (Fdocumentation_property, Fsnarf_documentation): No longer static. * buffer.c (Fset_buffer_major_mode, Fdelete_overlay): No longer static. * dired.c (Ffile_attributes): No longer static. * composite.c (Fcomposition_get_gstring): No longer static. * callproc.c (Fgetenv_internal): No longer static. * ccl.h: Remove EXFUNs. * buffer.h: Remove EXFUNs. * dispextern.h: Remove EXFUNs. * intervals.h: Remove EXFUNs. * fontset.h: Remove EXFUN. * font.h: Remove EXFUNs. * dosfns.c (system_process_attributes): Remove EXFUN. * keymap.h: Remove EXFUNs. * lisp.h: Remove EXFUNs. * w32term.h: Remove EXFUNs. * window.h: Remove EXFUNs. * xsettings.h: Remove EXFUN. * xterm.h: Remove EXFUN. lib-src * make-docfile.c (enum global_type) : New constant. (struct global) : New field. (add_global): Add 'value' argument. (compare_globals): Sort functions at the end. (close_emacs_globals): New function. (write_globals): Handle functions. (scan_c_file): Call add_global for DEFUN. --- src/buffer.h | 5 ----- 1 file changed, 5 deletions(-) (limited to 'src/buffer.h') diff --git a/src/buffer.h b/src/buffer.h index b48791f306f..b58c5c165e1 100644 --- a/src/buffer.h +++ b/src/buffer.h @@ -930,11 +930,6 @@ extern void mmap_set_vars (int); } \ } while (0) -EXFUN (Fbuffer_live_p, 1); -EXFUN (Fbuffer_name, 1); -EXFUN (Fnext_overlay_change, 1); -EXFUN (Fbuffer_local_value, 2); - extern Lisp_Object Qbefore_change_functions; extern Lisp_Object Qafter_change_functions; extern Lisp_Object Qfirst_change_hook; -- cgit v1.2.1 From 38182d901d030c7d65f4aa7a49b583afb30eb9b7 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Thu, 5 Jul 2012 11:35:48 -0700 Subject: More xmalloc and related cleanup. * alloc.c, bidi.c, buffer.c, buffer.h, bytecode.c, callint.c: * callproc.c, charset.c, coding.c, composite.c, data.c, dispnew.c: * doc.c, editfns.c, emacs.c, eval.c, fileio.c, filelock.c, fns.c: * font.c, fontset.c, frame.c, fringe.c, ftfont.c, ftxfont.c, gmalloc.c: * gtkutil.c, image.c, keyboard.c, keymap.c, lread.c, macros.c, menu.c: * nsfns.m, nsfont.m, nsmenu.m, nsterm.m, print.c, process.c, ralloc.c: * regex.c, region-cache.c, scroll.c, search.c, sound.c, syntax.c: * sysdep.c, term.c, termcap.c, unexmacosx.c, window.c, xdisp.c: * xfaces.c, xfns.c, xftfont.c, xgselect.c, xmenu.c, xrdb.c, xselect.c: * xterm.c: Omit needless casts involving void * pointers and allocation. Prefer "P = xmalloc (sizeof *P)" to "P = xmalloc (sizeof (TYPE_OF_P))", as the former is more robust if P's type is changed. Prefer xzalloc to xmalloc + memset 0. Simplify malloc-or-realloc to realloc. Don't worry about xmalloc returning a null pointer. Prefer xstrdup to xmalloc + strcpy. * editfns.c (Fmessage_box): Grow message_text by at least 80 when growing it. * keyboard.c (apply_modifiers_uncached): Prefer local array to alloca of a constant. --- src/buffer.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/buffer.h') diff --git a/src/buffer.h b/src/buffer.h index b58c5c165e1..0615f85bfe6 100644 --- a/src/buffer.h +++ b/src/buffer.h @@ -918,13 +918,13 @@ extern void mmap_set_vars (int); #define GET_OVERLAYS_AT(posn, overlays, noverlays, nextp, chrq) \ do { \ ptrdiff_t maxlen = 40; \ - overlays = (Lisp_Object *) alloca (maxlen * sizeof (Lisp_Object)); \ + overlays = alloca (maxlen * sizeof *overlays); \ noverlays = overlays_at (posn, 0, &overlays, &maxlen, \ nextp, NULL, chrq); \ if (noverlays > maxlen) \ { \ maxlen = noverlays; \ - overlays = (Lisp_Object *) alloca (maxlen * sizeof (Lisp_Object)); \ + overlays = alloca (maxlen * sizeof *overlays); \ noverlays = overlays_at (posn, 0, &overlays, &maxlen, \ nextp, NULL, chrq); \ } \ -- cgit v1.2.1 From 22657b40985ec990ea20df878bde97af76b19ed1 Mon Sep 17 00:00:00 2001 From: Dmitry Antipov Date: Tue, 17 Jul 2012 08:29:50 +0400 Subject: Cleanup overlays checking. * buffer.h (OVERLAY_VALID): Remove as useless synonym of OVERLAYP. * buffer.c (overlay_touches_p, recenter_overlay_lists): Change to eassert and OVERLAYP. (sort_overlays): Change to use OVERLAYP. --- src/buffer.h | 4 ---- 1 file changed, 4 deletions(-) (limited to 'src/buffer.h') diff --git a/src/buffer.h b/src/buffer.h index 0615f85bfe6..4003be5c8c4 100644 --- a/src/buffer.h +++ b/src/buffer.h @@ -971,10 +971,6 @@ BUF_FETCH_MULTIBYTE_CHAR (struct buffer *buf, ptrdiff_t pos) /* Overlays */ -/* 1 if the OV is an overlay object. */ - -#define OVERLAY_VALID(OV) (OVERLAYP (OV)) - /* Return the marker that stands for where OV starts in the buffer. */ #define OVERLAY_START(OV) (XOVERLAY (OV)->start) -- cgit v1.2.1 From d17337e501a189c1d46f758e10c6c2842cafff17 Mon Sep 17 00:00:00 2001 From: Dmitry Antipov Date: Thu, 19 Jul 2012 07:55:59 +0400 Subject: New macro to iterate over all buffers, miscellaneous cleanups. * lisp.h (all_buffers): Remove declaration. * buffer.h (all_buffers): Add declaration, with comment. (for_each_buffer): New macro. * alloc.c (Fgarbage_collect, mark_object): Use it. * buffer.c (Fkill_buffer, Fbuffer_swap_text, Fset_buffer_multibyte) (init_buffer): Likewise. * data.c (Fset_default): Likewise. * coding.c (code_conversion_restore): Remove redundant check for dead buffer. * buffer.c (Fkill_buffer): Likewise. Remove obsolete comment. --- src/buffer.h | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/buffer.h') diff --git a/src/buffer.h b/src/buffer.h index 4003be5c8c4..8c596835fcc 100644 --- a/src/buffer.h +++ b/src/buffer.h @@ -857,6 +857,15 @@ struct buffer }; +/* Chain of all buffers, including killed ones. */ + +extern struct buffer *all_buffers; + +/* Used to iterate over the chain above. */ + +#define for_each_buffer(b) \ + for ((b) = all_buffers; (b); (b) = (b)->header.next.buffer) + /* This points to the current buffer. */ extern struct buffer *current_buffer; -- cgit v1.2.1 From 9cd47b72e021f76a6e2481d986ce4b0cb0b859d3 Mon Sep 17 00:00:00 2001 From: Dmitry Antipov Date: Thu, 19 Jul 2012 12:56:53 +0400 Subject: Compact buffers when idle. * lisp/compact.el: New file. * src/buffer.c (compact_buffer, Fcompact_buffer): New function. (syms_of_buffer): Register Fcompact_buffer. * src/alloc.c (Fgarbage_collect): Use compact_buffer. * src/buffer.h (compact_buffer): New prototype. (struct buffer_text): New member. --- src/buffer.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/buffer.h') diff --git a/src/buffer.h b/src/buffer.h index 8c596835fcc..6f090479a24 100644 --- a/src/buffer.h +++ b/src/buffer.h @@ -436,6 +436,9 @@ struct buffer_text EMACS_INT overlay_modiff; /* Counts modifications to overlays. */ + EMACS_INT compact; /* Set to modiff each time when compact_buffer + is called for this buffer. */ + /* Minimum value of GPT - BEG since last redisplay that finished. */ ptrdiff_t beg_unchanged; @@ -903,6 +906,7 @@ extern struct buffer buffer_local_symbols; extern void delete_all_overlays (struct buffer *); extern void reset_buffer (struct buffer *); +extern int compact_buffer (struct buffer *); extern void evaporate_overlays (ptrdiff_t); extern ptrdiff_t overlays_at (EMACS_INT pos, int extend, Lisp_Object **vec_ptr, ptrdiff_t *len_ptr, ptrdiff_t *next_ptr, -- cgit v1.2.1 From 52b852c77d74800aaa1338dc72f786f7e261bfee Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Thu, 19 Jul 2012 15:35:58 -0700 Subject: * buffer.h (FOR_EACH_BUFFER): Rename from 'for_each_buffer'. (FOR_EACH_PER_BUFFER_OBJECT_AT): Rename from 'for_each_per_buffer_object_at'. All uses changed. It's better to use upper-case for macros that cannot be implemented as functions, to give the reader a clue that they're special. --- src/buffer.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/buffer.h') diff --git a/src/buffer.h b/src/buffer.h index 6f090479a24..a97cc13705b 100644 --- a/src/buffer.h +++ b/src/buffer.h @@ -866,7 +866,7 @@ extern struct buffer *all_buffers; /* Used to iterate over the chain above. */ -#define for_each_buffer(b) \ +#define FOR_EACH_BUFFER(b) \ for ((b) = all_buffers; (b); (b) = (b)->header.next.buffer) /* This points to the current buffer. */ @@ -1021,7 +1021,7 @@ extern int last_per_buffer_idx; Lisp_Objects except undo_list). If you add, remove, or reorder Lisp_Objects in a struct buffer, make sure that this is still correct. */ -#define for_each_per_buffer_object_at(offset) \ +#define FOR_EACH_PER_BUFFER_OBJECT_AT(offset) \ for (offset = PER_BUFFER_VAR_OFFSET (name); \ offset <= PER_BUFFER_VAR_OFFSET (cursor_in_non_selected_windows); \ offset += sizeof (Lisp_Object)) -- cgit v1.2.1 From 9928463dcdb0164477785e83406602065de79ef8 Mon Sep 17 00:00:00 2001 From: Dmitry Antipov Date: Fri, 20 Jul 2012 20:05:47 +0400 Subject: Add indirection counting to speed up Fkill_buffer. * buffer.h (struct buffer): New member. * buffer.c (Fget_buffer_create): Set indirection counter to 0. (Fmake_indirect_buffer): Set indirection counter to -1, increment base buffer indirection counter. (compact_buffer): If ENABLE_CHECKING, verify indirection counters. (Fkill_buffer): Adjust indirection counters as needed, don't walk through buffer list if indirection counter is 0. --- src/buffer.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/buffer.h') diff --git a/src/buffer.h b/src/buffer.h index a97cc13705b..69be4dc7773 100644 --- a/src/buffer.h +++ b/src/buffer.h @@ -775,6 +775,11 @@ struct buffer In an ordinary buffer, it is 0. */ struct buffer *base_buffer; + /* In an indirect buffer, this is -1. In an ordinary buffer, + it's the number of indirect buffers which shares our text; + zero means that we're the only owner of this text. */ + int indirections; + /* A non-zero value in slot IDX means that per-buffer variable with index IDX has a local value in this buffer. The index IDX for a buffer-local variable is stored in that variable's slot -- cgit v1.2.1 From fb9ea40fc511eb7e42a512ada9e369cce1bfd932 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Sat, 21 Jul 2012 20:44:35 -0700 Subject: * buffer.h (struct buffer.indirections): Now ptrdiff_t, not int, as it's limited by the amount of memory, not by INT_MAX. --- src/buffer.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/buffer.h') diff --git a/src/buffer.h b/src/buffer.h index 69be4dc7773..61f9e72fcfd 100644 --- a/src/buffer.h +++ b/src/buffer.h @@ -776,9 +776,9 @@ struct buffer struct buffer *base_buffer; /* In an indirect buffer, this is -1. In an ordinary buffer, - it's the number of indirect buffers which shares our text; + it's the number of indirect buffers that share our text; zero means that we're the only owner of this text. */ - int indirections; + ptrdiff_t indirections; /* A non-zero value in slot IDX means that per-buffer variable with index IDX has a local value in this buffer. The index IDX -- cgit v1.2.1