bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#18652: 25.0.50; [PATCH] Add fresh-line


From: Leo Liu
Subject: bug#18652: 25.0.50; [PATCH] Add fresh-line
Date: Tue, 07 Oct 2014 21:03:05 +0800

I often find myself wanting to start printing at a newline and it is a
lot of work to do it properly. I wonder if we can add something along
these lines?

Thanks,
Leo

=== modified file 'src/print.c'
--- src/print.c 2014-09-11 06:21:55 +0000
+++ src/print.c 2014-10-07 13:01:46 +0000
@@ -530,6 +530,30 @@
   return Qt;
 }
 
+DEFUN ("fresh-line", Ffresh_line, Sfresh_line, 0, 1, 0,
+       doc: /* Output a newline unless already at the beginning of a line.
+Value is non-nil if a newline is printed.
+Do nothing and return nil if PRINTCHARFUN is a function.  */)
+  (Lisp_Object printcharfun)
+{
+  PRINTDECLARE;
+  if (NILP (printcharfun))
+    printcharfun = Vstandard_output;
+  PRINTPREPARE;
+
+  if (!FUNCTIONP (printcharfun) && NILP (Fbolp ()))
+    {
+      PRINTCHAR ('\n');
+      PRINTFINISH;
+      return Qt;
+    }
+  else
+    {
+      PRINTFINISH;
+      return Qnil;
+    }
+}
+
 DEFUN ("prin1", Fprin1, Sprin1, 1, 2, 0,
        doc: /* Output the printed representation of OBJECT, any Lisp object.
 Quoting characters are printed when needed to make output that `read'
@@ -2334,6 +2358,7 @@
   defsubr (&Sprinc);
   defsubr (&Sprint);
   defsubr (&Sterpri);
+  defsubr (&Sfresh_line);
   defsubr (&Swrite_char);
 #ifdef WITH_REDIRECT_DEBUGGING_OUTPUT
   defsubr (&Sredirect_debugging_output);





reply via email to

[Prev in Thread] Current Thread [Next in Thread]