X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/a0b5606ec769968b10c765f8ff50f312d691ef62..ae4002ce294f21a82979edacef39f82d8e4cd1cc:/src/buffer.c diff --git a/src/buffer.c b/src/buffer.c index 58530248ab..e44908a543 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -20,8 +20,6 @@ along with GNU Emacs. If not, see . */ #include -#define BUFFER_INLINE EXTERN_INLINE - #include #include #include @@ -888,8 +886,8 @@ drop_overlay (struct buffer *b, struct Lisp_Overlay *ov) eassert (b == XBUFFER (Fmarker_buffer (ov->start))); modify_overlay (b, marker_position (ov->start), marker_position (ov->end)); - Fset_marker (ov->start, Qnil, Qnil); - Fset_marker (ov->end, Qnil, Qnil); + unchain_marker (XMARKER (ov->start)); + unchain_marker (XMARKER (ov->end)); } @@ -933,7 +931,7 @@ reset_buffer (register struct buffer *b) bset_filename (b, Qnil); bset_file_truename (b, Qnil); bset_directory (b, current_buffer ? BVAR (current_buffer, directory) : Qnil); - b->modtime = make_emacs_time (0, UNKNOWN_MODTIME_NSECS); + b->modtime = make_timespec (0, UNKNOWN_MODTIME_NSECS); b->modtime_size = -1; XSETFASTINT (BVAR (b, save_length), 0); b->last_window_start = 1; @@ -2076,7 +2074,7 @@ the current buffer's major mode. */) count = SPECPDL_INDEX (); /* To select a nonfundamental mode, - select the buffer temporarily and then call the mode function. */ + select the buffer temporarily and then call the mode function. */ record_unwind_protect (save_excursion_restore, save_excursion_save ()); @@ -2116,7 +2114,7 @@ set_buffer_internal_1 (register struct buffer *b) old_buf = current_buffer; current_buffer = b; - last_known_column_point = -1; /* invalidate indentation cache */ + last_known_column_point = -1; /* Invalidate indentation cache. */ if (old_buf) { @@ -2140,7 +2138,7 @@ set_buffer_internal_1 (register struct buffer *b) fetch_buffer_markers (b); /* Look down buffer's list of local Lisp variables - to find and update any that forward into C variables. */ + to find and update any that forward into C variables. */ do { @@ -3834,7 +3832,8 @@ for the front of the overlay advance when text is inserted there The fifth arg REAR-ADVANCE, if non-nil, makes the marker for the rear of the overlay advance when text is inserted there \(which means the text *is* included in the overlay). */) - (Lisp_Object beg, Lisp_Object end, Lisp_Object buffer, Lisp_Object front_advance, Lisp_Object rear_advance) + (Lisp_Object beg, Lisp_Object end, Lisp_Object buffer, + Lisp_Object front_advance, Lisp_Object rear_advance) { Lisp_Object overlay; struct buffer *b; @@ -3843,12 +3842,11 @@ for the rear of the overlay advance when text is inserted there XSETBUFFER (buffer, current_buffer); else CHECK_BUFFER (buffer); - if (MARKERP (beg) - && ! EQ (Fmarker_buffer (beg), buffer)) - error ("Marker points into wrong buffer"); - if (MARKERP (end) - && ! EQ (Fmarker_buffer (end), buffer)) - error ("Marker points into wrong buffer"); + + if (MARKERP (beg) && !EQ (Fmarker_buffer (beg), buffer)) + signal_error ("Marker points into wrong buffer", beg); + if (MARKERP (end) && !EQ (Fmarker_buffer (end), buffer)) + signal_error ("Marker points into wrong buffer", end); CHECK_NUMBER_COERCE_MARKER (beg); CHECK_NUMBER_COERCE_MARKER (end); @@ -3974,12 +3972,10 @@ buffer. */) if (NILP (Fbuffer_live_p (buffer))) error ("Attempt to move overlay to a dead buffer"); - if (MARKERP (beg) - && ! EQ (Fmarker_buffer (beg), buffer)) - error ("Marker points into wrong buffer"); - if (MARKERP (end) - && ! EQ (Fmarker_buffer (end), buffer)) - error ("Marker points into wrong buffer"); + if (MARKERP (beg) && !EQ (Fmarker_buffer (beg), buffer)) + signal_error ("Marker points into wrong buffer", beg); + if (MARKERP (end) && !EQ (Fmarker_buffer (end), buffer)) + signal_error ("Marker points into wrong buffer", end); CHECK_NUMBER_COERCE_MARKER (beg); CHECK_NUMBER_COERCE_MARKER (end); @@ -4161,6 +4157,9 @@ DEFUN ("overlays-at", Foverlays_at, Soverlays_at, 1, 1, 0, CHECK_NUMBER_COERCE_MARKER (pos); + if (!buffer_has_overlays ()) + return Qnil; + len = 10; /* We can't use alloca here because overlays_at can call xrealloc. */ overlay_vec = xmalloc (len * sizeof *overlay_vec); @@ -4193,6 +4192,9 @@ end of the buffer. */) CHECK_NUMBER_COERCE_MARKER (beg); CHECK_NUMBER_COERCE_MARKER (end); + if (!buffer_has_overlays ()) + return Qnil; + len = 10; overlay_vec = xmalloc (len * sizeof *overlay_vec); @@ -4221,6 +4223,9 @@ the value is (point-max). */) CHECK_NUMBER_COERCE_MARKER (pos); + if (!buffer_has_overlays ()) + return make_number (ZV); + len = 10; overlay_vec = xmalloc (len * sizeof *overlay_vec); @@ -4260,6 +4265,9 @@ the value is (point-min). */) CHECK_NUMBER_COERCE_MARKER (pos); + if (!buffer_has_overlays ()) + return make_number (BEGV); + /* At beginning of buffer, we know the answer; avoid bug subtracting 1 below. */ if (XINT (pos) == BEGV) @@ -4526,7 +4534,7 @@ report_overlay_modification (Lisp_Object start, Lisp_Object end, bool after, Lisp_Object *copy = alloca (size * sizeof *copy); ptrdiff_t i; - memcpy (copy, XVECTOR (last_overlay_modification_hooks)->contents, + memcpy (copy, XVECTOR (last_overlay_modification_hooks)->u.contents, size * word_size); gcpro1.var = copy; gcpro1.nvars = size; @@ -5890,7 +5898,7 @@ See also the functions `display-table-slot' and `set-display-table-slot'. */); DEFVAR_PER_BUFFER ("left-margin-width", &BVAR (current_buffer, left_margin_cols), Qintegerp, - doc: /* Width of left marginal area for display of a buffer. + doc: /* Width in columns of left marginal area for display of a buffer. A value of nil means no marginal area. Setting this variable does not take effect until a new buffer is displayed @@ -5898,7 +5906,7 @@ in a window. To make the change take effect, call `set-window-buffer'. */); DEFVAR_PER_BUFFER ("right-margin-width", &BVAR (current_buffer, right_margin_cols), Qintegerp, - doc: /* Width of right marginal area for display of a buffer. + doc: /* Width in columns of right marginal area for display of a buffer. A value of nil means no marginal area. Setting this variable does not take effect until a new buffer is displayed @@ -6182,7 +6190,9 @@ If the value is a list, a text character is invisible if its `invisible' property is an element in that list (or is a list with members in common). If an element is a cons cell of the form (PROP . ELLIPSIS), then characters with property value PROP are invisible, -and they have an ellipsis as well if ELLIPSIS is non-nil. */); +and they have an ellipsis as well if ELLIPSIS is non-nil. +Setting this variable is very fast, much faster than scanning all the +text in the buffer looking for properties to change. */); DEFVAR_PER_BUFFER ("buffer-display-count", &BVAR (current_buffer, display_count), Qintegerp,