all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Thorsten Jolitz <tjolitz@gmail.com>
To: help-gnu-emacs@gnu.org
Subject: Re: `print' inside Emacs vs `print' to stdout (with Emacsclient)
Date: Wed, 23 Oct 2013 12:24:40 +0200	[thread overview]
Message-ID: <87zjq01dzr.fsf@gmail.com> (raw)
In-Reply-To: 87vc0o2zrf.fsf@gmail.com

Thorsten Jolitz <tjolitz@gmail.com> writes:

Hi List, 

> What I would really need is being able to just `print' a structure to
> stdout in an emacsclient call and receive as input of another program on
> stdin exactly what would be printed in the Emacs *Messages* buffer when
> evaluating the print commands in an emacs-lisp-mode buffer.
>
> Is there any way to achieve this?

following up to my own post, I wonder how printing does work in the
*Messages* buffer?

Looking at the examples below, I see that - with `print-circle' set to t
- `print' and `(message "%S" ...)' produce the output I want to receive
in another program. And what I want is the first part of the output, the
unquoted lisp structure, not the second (string) part. 

I wonder how this first part (the return value of
`org-element-parse-buffer' I would guess) is captured and printed
unquoted in the *Messages* buffer _with_ the 'circular' labels and
references?

To send something via stdout to another program, one must print
something, so what I receive in the other program is always the the
output - either unquoted but without the 'circular' labels and
references, or quoted and including them.

How can I send the raw lisp structure with print-circle information
to another program (instead of a string)?

###################################

    ,-------------------------------
    | (print 
    |  (org-element-parse-buffer))))
    `-------------------------------

#2=(org-data nil #1=(headline (:raw-value "A" :begin 1 :end 7 :pre-blank
 0 :hiddenp outline :contents-begin 5 :contents-end 7 :level 1 :priority
 nil :tags nil :todo-keyword nil :todo-type nil :post-blank 0
 :footnote-section-p nil :archivedp nil :commentedp nil :quotedp nil
 :CATEGORY nil :title (#("A" 0 1 (:parent #1#))) :parent #2#)
 #3=(section (:begin 5 :end 7 :contents-begin 5 :contents-end 7
 :post-blank 0 :parent #1#) #4=(paragraph (:begin 5 :end 7
 :contents-begin 5 :contents-end 7 :post-blank 0 :post-affiliated 5
 :parent #3#) #("B\n" 0 2 (:parent #4#))))))

(org-data nil (headline (:raw-value "A" :begin 1 :end 7 :pre-blank 0
:hiddenp outline :contents-begin 5 ...) (section (:begin 5 :end 7
:contents-begin 5 :contents-end 7 :post-blank 0 :parent #1) (paragraph
... #("B " 0 2 ...)))))

##################################

    ,-------------------------------
    | (message "%S"
    |  (org-element-parse-buffer))))
    `-------------------------------

#2=(org-data nil #1=(headline (:raw-value "A" :begin 1 :end 7 :pre-blank
 0 :hiddenp outline :contents-begin 5 :contents-end 7 :level 1 :priority
 nil :tags nil :todo-keyword nil :todo-type nil :post-blank 0
 :footnote-section-p nil :archivedp nil :commentedp nil :quotedp nil
 :CATEGORY nil :title (#("A" 0 1 (:parent #1#))) :parent #2#)
 #3=(section (:begin 5 :end 7 :contents-begin 5 :contents-end 7
 :post-blank 0 :parent #1#) #4=(paragraph (:begin 5 :end 7
 :contents-begin 5 :contents-end 7 :post-blank 0 :post-affiliated 5
 :parent #3#) #("B\n" 0 2 (:parent #4#))))))

"#2=(org-data nil #1=(headline (:raw-value \"A\" :begin 1 :end 7
:pre-blank 0 :hiddenp outline :contents-begin 5 :contents-end 7 :level 1
:priority nil :tags nil :todo-keyword nil :todo-type nil :post-blank 0
:footnote-section-p nil :archivedp nil :commentedp nil :quotedp nil
:CATEGORY nil :title (#(\"A\" 0 1 (:parent #1#))) :parent #2#)
#3=(section (:begin 5 :end 7 :contents-begin 5 :contents-end 7
:post-blank 0 :parent #1#) #4=(paragraph (:begin 5 :end 7
:contents-begin 5 :contents-end 7 :post-blank 0 :post-affiliated 5
:parent #3#) #(\"B\\n\" 0 2 (:parent #4#))))))"


##################################

    ,-------------------------------
    | (message "%s"
    |  (org-element-parse-buffer))))
    `-------------------------------

#2=(org-data nil #1=(headline (:raw-value A :begin 1 :end 7 :pre-blank 0
:hiddenp outline :contents-begin 5 :contents-end 7 :level 1 :priority
nil :tags nil :todo-keyword nil :todo-type nil :post-blank 0
:footnote-section-p nil :archivedp nil :commentedp nil :quotedp nil
:CATEGORY nil :title (A) :parent #2#) #3=(section (:begin 5 :end 7
:contents-begin 5 :contents-end 7 :post-blank 0 :parent #1#)
#4=(paragraph (:begin 5 :end 7 :contents-begin 5 :contents-end 7
:post-blank 0 :post-affiliated 5 :parent #3#) B ))))

"#2=(org-data nil #1=(headline (:raw-value A :begin 1 :end 7 :pre-blank
0 :hiddenp outline :contents-begin 5 :contents-end 7 :level 1 :priority
nil :tags nil :todo-keyword nil :todo-type nil :post-blank 0
:footnote-section-p nil :archivedp nil :commentedp nil :quotedp nil
:CATEGORY nil :title (A) :parent #2#) #3=(section (:begin 5 :end 7
:contents-begin 5 :contents-end 7 :post-blank 0 :parent #1#)
#4=(paragraph (:begin 5 :end 7 :contents-begin 5 :contents-end 7
:post-blank 0 :post-affiliated 5 :parent #3#) B ))))"

####################################

-- 
cheers,
Thorsten




      reply	other threads:[~2013-10-23 10:24 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-23  7:49 `print' inside Emacs vs `print' to stdout (with Emacsclient) Thorsten Jolitz
2013-10-23 10:24 ` Thorsten Jolitz [this message]

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

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

  git send-email \
    --in-reply-to=87zjq01dzr.fsf@gmail.com \
    --to=tjolitz@gmail.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.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.