-DEFUN ("newline", Fnewline, Snewline, 0, 1, "P",
- "Insert a newline. With arg, insert that many newlines.\n\
-In Auto Fill mode, if no numeric arg, break the preceding line if it's long.")
- (arg1)
- Lisp_Object arg1;
-{
- int flag;
- Lisp_Object arg;
- char c1 = '\n';
-
- arg = Fprefix_numeric_value (arg1);
-
- if (!NILP (current_buffer->read_only))
- Fbarf_if_buffer_read_only ();
-
- /* Inserting a newline at the end of a line produces better
- redisplay in try_window_id than inserting at the ebginning fo a
- line, and the textual result is the same. So, if we're at
- beginning of line, pretend to be at the end of the previous line.
-
- We can't use internal_self_insert in that case since it won't do
- the insertion correctly. Luckily, internal_self_insert's special
- features all do nothing in that case. */
-
- flag = point > BEGV && FETCH_CHAR (point - 1) == '\n';
- if (flag)
- SET_PT (point - 1);
-
- while (XINT (arg) > 0)
- {
- if (flag)
- insert (&c1, 1);
- else
- internal_self_insert ('\n', !NILP (arg1));
- XFASTINT (arg)--; /* Ok since old and new vals both nonneg */
- }
-
- if (flag)
- SET_PT (point + 1);
-
- return Qnil;
-}
-