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

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

Re: Messages - Avoiding newlines


From: 2QdxY4RzWzUUiLuE
Subject: Re: Messages - Avoiding newlines
Date: Tue, 8 Dec 2020 07:47:28 -0600

On 2020-12-08 at 14:29:20 +0100,
Stefan Möding <s.moeding@gmail.com> wrote:

> pietru@caramail.com writes:
> 
> > I would like to print some values but I am getting a new-line
> > after (pp bounds).  Haw may I avoid it?
> 
> You could remove the trailing newlines returned by pp:
> 
> (message "Bounds: %s [%s, %s]"
>          (replace-regexp-in-string "\n+$" "" (pp bounds)) $ma $mb)

A regular expression is a heavyweight solution to this problem.  Try a
substring containing all but the trailing newline:

    (substring (pp bounds t) 0 -1)

> pp (Pretty Print) is meant to be used interactively so the newline
> make sense when showing the output on a terminal.

Note also that by passing a second argument to pp, you can suppress pp's
output and make it just return the string.

HTH,
Dan



reply via email to

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