if (NILP (object))
XSETBUFFER (object, current_buffer);
else if (WINDOWP (object))
- object = XWINDOW (object)->buffer;
+ object = XWINDOW (object)->contents;
if (!BUFFERP (object))
/* pos-property only makes sense in buffers right now, since strings
ptrdiff_t noverlays;
Lisp_Object *overlay_vec, tem;
struct buffer *obuf = current_buffer;
+ USE_SAFE_ALLOCA;
set_buffer_temp (XBUFFER (object));
make enough space for all, and try again. */
if (noverlays > 40)
{
- overlay_vec = alloca (noverlays * sizeof *overlay_vec);
+ SAFE_ALLOCA_LISP (overlay_vec, noverlays);
noverlays = overlays_around (posn, overlay_vec, noverlays);
}
noverlays = sort_overlays (overlay_vec, noverlays, NULL);
; /* The overlay will not cover a char inserted at point. */
else
{
+ SAFE_FREE ();
return tem;
}
}
}
+ SAFE_FREE ();
{ /* Now check the text properties. */
int stickiness = text_property_stickiness (prop, position, object);
a non-nil property of that name, then any field boundaries are ignored.
Field boundaries are not noticed if `inhibit-field-text-motion' is non-nil. */)
- (Lisp_Object new_pos, Lisp_Object old_pos, Lisp_Object escape_from_edge, Lisp_Object only_in_line, Lisp_Object inhibit_capture_property)
+ (Lisp_Object new_pos, Lisp_Object old_pos, Lisp_Object escape_from_edge,
+ Lisp_Object only_in_line, Lisp_Object inhibit_capture_property)
{
/* If non-zero, then the original point, before re-positioning. */
ptrdiff_t orig_point = 0;
/* This is the ONLY_IN_LINE case, check that NEW_POS and
FIELD_BOUND are on the same line by seeing whether
there's an intervening newline or not. */
- || (scan_buffer ('\n',
- XFASTINT (new_pos), XFASTINT (field_bound),
- fwd ? -1 : 1, &shortage, 1),
+ || (find_newline (XFASTINT (new_pos), -1,
+ XFASTINT (field_bound), -1,
+ fwd ? -1 : 1, &shortage, NULL, 1),
shortage != 0)))
/* Constrain NEW_POS to FIELD_BOUND. */
new_pos = field_bound;
CHECK_NUMBER (n);
clipped_n = clip_to_bounds (PTRDIFF_MIN + 1, XINT (n), PTRDIFF_MAX);
- end_pos = find_before_next_newline (orig, 0, clipped_n - (clipped_n <= 0));
+ end_pos = find_before_next_newline (orig, 0, clipped_n - (clipped_n <= 0),
+ NULL);
/* Return END_POS constrained to the current input field. */
return Fconstrain_to_field (make_number (end_pos), make_number (orig),
Lisp_Object
save_excursion_save (void)
{
- Lisp_Object save, *data = xmalloc (word_size * 4);
-
- data[0] = Fpoint_marker ();
- /* Do not copy the mark if it points to nowhere. */
- data[1] = (XMARKER (BVAR (current_buffer, mark))->buffer
- ? Fcopy_marker (BVAR (current_buffer, mark), Qnil)
- : Qnil);
- /* Selected window if current buffer is shown in it, nil otherwise. */
- data[2] = ((XBUFFER (XWINDOW (selected_window)->buffer) == current_buffer)
- ? selected_window : Qnil);
- data[3] = BVAR (current_buffer, mark_active);
-
- save = make_save_value (data, 4);
- XSAVE_VALUE (save)->dogc = 1;
- return save;
+ return make_save_obj_obj_obj_obj
+ (Fpoint_marker (),
+ /* Do not copy the mark if it points to nowhere. */
+ (XMARKER (BVAR (current_buffer, mark))->buffer
+ ? Fcopy_marker (BVAR (current_buffer, mark), Qnil)
+ : Qnil),
+ /* Selected window if current buffer is shown in it, nil otherwise. */
+ (EQ (XWINDOW (selected_window)->contents, Fcurrent_buffer ())
+ ? selected_window : Qnil),
+ BVAR (current_buffer, mark_active));
}
/* Restore saved buffer before leaving `save-excursion' special form. */
-Lisp_Object
+void
save_excursion_restore (Lisp_Object info)
{
- Lisp_Object tem, tem1, omark, nmark, *data = XSAVE_VALUE (info)->pointer;
+ Lisp_Object tem, tem1, omark, nmark;
struct gcpro gcpro1, gcpro2, gcpro3;
- tem = Fmarker_buffer (data[0]);
+ tem = Fmarker_buffer (XSAVE_OBJECT (info, 0));
/* If we're unwinding to top level, saved buffer may be deleted. This
means that all of its markers are unchained and so tem is nil. */
if (NILP (tem))
Fset_buffer (tem);
/* Point marker. */
- tem = data[0];
+ tem = XSAVE_OBJECT (info, 0);
Fgoto_char (tem);
unchain_marker (XMARKER (tem));
/* Mark marker. */
- tem = data[1];
+ tem = XSAVE_OBJECT (info, 1);
omark = Fmarker_position (BVAR (current_buffer, mark));
if (NILP (tem))
unchain_marker (XMARKER (BVAR (current_buffer, mark)));
}
/* Mark active. */
- tem = data[3];
+ tem = XSAVE_OBJECT (info, 3);
tem1 = BVAR (current_buffer, mark_active);
bset_mark_active (current_buffer, tem);
/* If buffer was visible in a window, and a different window was
selected, and the old selected window is still showing this
buffer, restore point in that window. */
- tem = data[2];
+ tem = XSAVE_OBJECT (info, 2);
if (WINDOWP (tem)
&& !EQ (tem, selected_window)
- && (tem1 = XWINDOW (tem)->buffer,
+ && (tem1 = XWINDOW (tem)->contents,
(/* Window is live... */
BUFFERP (tem1)
/* ...and it shows the current buffer. */
out:
- free_save_value (info);
- return Qnil;
+ free_misc (info);
}
DEFUN ("save-excursion", Fsave_excursion, Ssave_excursion, 0, UNEVALLED, 0,
make_lisp_time (EMACS_TIME t)
{
int ns = EMACS_NSECS (t);
- return make_time_tail (EMACS_SECS (t),
- list2 (make_number (ns / 1000),
- make_number (ns % 1000 * 1000)));
+ return make_time_tail (EMACS_SECS (t), list2i (ns / 1000, ns % 1000 * 1000));
}
/* Decode a Lisp list SPECIFIED_TIME that represents a time.
EMACS_INT zone_hr = abszone / (60*60);
int zone_min = (abszone/60) % 60;
int zone_sec = abszone % 60;
- sprintf (tzbuf, tzbuf_format, "-" + (XINT (zone) < 0),
+ sprintf (tzbuf, tzbuf_format, &"-"[XINT (zone) < 0],
zone_hr, zone_min, zone_sec);
tzstring = tzbuf;
}
If the current buffer is unibyte, multibyte strings are converted
to unibyte for insertion.
+If an overlay begins at the insertion point, the inserted text falls
+outside the overlay; if a nonempty overlay ends at the insertion
+point, the inserted text falls inside that overlay.
+
usage: (insert-before-markers &rest ARGS) */)
(ptrdiff_t nargs, Lisp_Object *args)
{
return make_number (0);
}
\f
-static Lisp_Object
+static void
subst_char_in_region_unwind (Lisp_Object arg)
{
bset_undo_list (current_buffer, arg);
- return arg;
}
-static Lisp_Object
+static void
subst_char_in_region_unwind_1 (Lisp_Object arg)
{
bset_filename (current_buffer, arg);
- return arg;
}
DEFUN ("subst-char-in-region", Fsubst_char_in_region,
else if (!changed)
{
changed = -1;
- modify_region_1 (pos, XINT (end), false);
+ modify_text (pos, XINT (end));
if (! NILP (noundo))
{
pos = XINT (start);
pos_byte = CHAR_TO_BYTE (pos);
end_pos = XINT (end);
- modify_region_1 (pos, end_pos, false);
+ modify_text (pos, end_pos);
cnt = 0;
for (; pos < end_pos; )
}
}
-Lisp_Object
+void
save_restriction_restore (Lisp_Object data)
{
struct buffer *cur = NULL;
if (cur)
set_buffer_internal (cur);
-
- return Qnil;
}
DEFUN ("save-restriction", Fsave_restriction, Ssave_restriction, 0, UNEVALLED, 0,
return unbind_to (count, val);
}
\f
-/* Buffer for the most recent text displayed by Fmessage_box. */
-static char *message_text;
-
-/* Allocated length of that buffer. */
-static ptrdiff_t message_length;
-
DEFUN ("message", Fmessage, Smessage, 1, MANY, 0,
doc: /* Display a message at the bottom of the screen.
The message also goes into the `*Messages*' buffer, if `message-log-max'
|| (STRINGP (args[0])
&& SBYTES (args[0]) == 0))
{
- message (0);
+ message1 (0);
return args[0];
}
else
{
register Lisp_Object val;
val = Fformat (nargs, args);
- message3 (val, SBYTES (val), STRING_MULTIBYTE (val));
+ message3 (val);
return val;
}
}
{
if (NILP (args[0]))
{
- message (0);
+ message1 (0);
return Qnil;
}
else
{
- register Lisp_Object val;
- val = Fformat (nargs, args);
+ Lisp_Object val = Fformat (nargs, args);
#ifdef HAVE_MENUS
/* The MS-DOS frames support popup menus even though they are
not FRAME_WINDOW_P. */
{
Lisp_Object pane, menu;
struct gcpro gcpro1;
- pane = Fcons (Fcons (build_string ("OK"), Qt), Qnil);
+ pane = list1 (Fcons (build_string ("OK"), Qt));
GCPRO1 (pane);
menu = Fcons (val, pane);
Fx_popup_dialog (Qt, menu, Qt);
return val;
}
#endif /* HAVE_MENUS */
- /* Copy the data so that it won't move when we GC. */
- if (SBYTES (val) > message_length)
- {
- ptrdiff_t new_length = SBYTES (val) + 80;
- message_text = xrealloc (message_text, new_length);
- message_length = new_length;
- }
- memcpy (message_text, SDATA (val), SBYTES (val));
- message2 (message_text, SBYTES (val),
- STRING_MULTIBYTE (val));
+ message3 (val);
return val;
}
}
ptrdiff_t bufsize = sizeof initial_buffer;
ptrdiff_t max_bufsize = STRING_BYTES_BOUND + 1;
char *p;
- Lisp_Object buf_save_value IF_LINT (= {0});
+ ptrdiff_t buf_save_value_index IF_LINT (= 0);
char *format, *end, *format_start;
ptrdiff_t formatlen, nchars;
/* True if the format is multibyte. */
trailing "d"). */
pMlen = sizeof pMd - 2
};
- verify (0 < USEFUL_PRECISION_MAX);
+ verify (USEFUL_PRECISION_MAX > 0);
int prec;
ptrdiff_t padding, sprintf_bytes;
{
buf = xmalloc (bufsize);
sa_must_free = 1;
- buf_save_value = make_save_value (buf, 0);
- record_unwind_protect (safe_alloca_unwind, buf_save_value);
+ buf_save_value_index = SPECPDL_INDEX ();
+ record_unwind_protect_ptr (xfree, buf);
memcpy (buf, initial_buffer, used);
}
else
- XSAVE_VALUE (buf_save_value)->pointer = buf = xrealloc (buf, bufsize);
+ {
+ buf = xrealloc (buf, bufsize);
+ set_unwind_protect_ptr (buf_save_value_index, xfree, buf);
+ }
p = buf + used;
}
if (end1 == start2) /* adjacent regions */
{
- modify_region_1 (start1, end2, false);
+ modify_text (start1, end2);
record_change (start1, len1 + len2);
tmp_interval1 = copy_intervals (cur_intv, start1, len1);
{
USE_SAFE_ALLOCA;
- modify_region_1 (start1, end1, false);
- modify_region_1 (start2, end2, false);
+ modify_text (start1, end1);
+ modify_text (start2, end2);
record_change (start1, len1);
record_change (start2, len2);
tmp_interval1 = copy_intervals (cur_intv, start1, len1);
{
USE_SAFE_ALLOCA;
- modify_region_1 (start1, end2, false);
+ modify_text (start1, end2);
record_change (start1, (end2 - start1));
tmp_interval1 = copy_intervals (cur_intv, start1, len1);
tmp_interval_mid = copy_intervals (cur_intv, end1, len_mid);
USE_SAFE_ALLOCA;
record_change (start1, (end2 - start1));
- modify_region_1 (start1, end2, false);
+ modify_text (start1, end2);
tmp_interval1 = copy_intervals (cur_intv, start1, len1);
tmp_interval_mid = copy_intervals (cur_intv, end1, len_mid);