unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: 2QdxY4RzWzUUiLuE@potatochowder.com
To: help-gnu-emacs@gnu.org
Subject: Re: Messages - Avoiding newlines
Date: Tue, 8 Dec 2020 07:47:28 -0600	[thread overview]
Message-ID: <X8+D8JWzisNHaeCQ@scrozzle> (raw)
In-Reply-To: <m2360gtoi7.fsf@athena.moeding.net>

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	other threads:[~2020-12-08 13:47 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-08 12:51 Messages - Avoiding newlines pietru
2020-12-08 13:29 ` Stefan Möding
2020-12-08 13:47   ` 2QdxY4RzWzUUiLuE [this message]
2020-12-08 13:47   ` pietru
2020-12-08 14:23   ` pietru
2020-12-08 15:32 ` Michael Heerdegen
2020-12-15  3:34 ` Tim Landscheidt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=X8+D8JWzisNHaeCQ@scrozzle \
    --to=2qdxy4rzwzuuilue@potatochowder.com \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).