unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Linefeeds (\n) to stdout
@ 2013-10-07 20:24 Thorsten Jolitz
  2013-10-10  9:42 ` Thorsten Jolitz
  0 siblings, 1 reply; 4+ messages in thread
From: Thorsten Jolitz @ 2013-10-07 20:24 UTC (permalink / raw)
  To: help-gnu-emacs


Hi List,

I'm trying to figure out some strange issues I have with linefeeds:

 1. with standalone Emacs

#+begin_src sh
      $ emacs -Q -e ...
#+end_src

    sending an Org-mode text from another program Emacs and receiving the HTML
    produced by Org-mode's exporter (stdout and stdin) works fine.
 2. doing exactly the same thing with emacs server/client

#+begin_src sh
      $ emacsclient -e ...
#+end_src

    results in HTML cluttered with \n that are printed verbatim in the webpage

Another problem I face is that sending a parse-tree containing strings with
only a linefeed (printed with '(print-escape-newlines t)')

#+begin_src emacs-lisp
#(\"\\n\" 0 1 (:parent #3))
#+end_src

to another Lisp (that only knows about "^J", not about "\n") via
stdout/stdin results, after the other Lisp's reader did its work, into
something like 

#+begin_src picolisp
(\# ("n" 0 1 (:parent \#3)))
#+end_src

[ignore the # stuff, but note that the linefeed was read as "n" string].

Now I wonder:

 - what does Emacs sends to stdout when it sends a linefeed? I use
   `prin1-to-string' and then `buffer-substring-no-properties' to produce the
   string I send from Emacs.
 - why are there differences between standalone Emacs and Emacsclient?

--
cheers,
Thorsten




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Linefeeds (\n) to stdout
  2013-10-07 20:24 Linefeeds (\n) to stdout Thorsten Jolitz
@ 2013-10-10  9:42 ` Thorsten Jolitz
  2013-10-10 11:49   ` Stefan Monnier
  0 siblings, 1 reply; 4+ messages in thread
From: Thorsten Jolitz @ 2013-10-10  9:42 UTC (permalink / raw)
  To: help-gnu-emacs

Thorsten Jolitz <tjolitz@gmail.com> writes:


> I'm trying to figure out some strange issues I have with linefeeds:
>
>  1. with standalone Emacs
>
> #+begin_src sh
>       $ emacs -Q -e ...
> #+end_src
>
>     sending an Org-mode text from another program Emacs and receiving
>     the HTML produced by Org-mode's exporter (stdout and stdin) works
>     fine.

>  2. doing exactly the same thing with emacs server/client
>
> #+begin_src sh
>       $ emacsclient -e ...
> #+end_src
>
>     results in HTML cluttered with \n that are printed verbatim in the
>     webpage


Just for the record: after much research I found out that apparently

,-----------------------------------------------------
| "emacsclient compresses double and tripple slashes."
`-----------------------------------------------------

so its no wonder that calling emacs from another program to do some
html-exporting results in something like this

,-------------------------------------------------------------------------
| <div id="outline-container-sec-1" class="outline-2">
| <h2 id="sec-1"><span class="section-number-2">1</span> NEXT
| A1&#xa0;&#xa0;&#xa0;<span class="tag"><span
| class="home">home</span>&#xa0;<span class="iorg">iorg</span></span></h2>
| <div class="outline-text-2" id="text-1">
| <p>
| B1
| </p>
| </div>
|
| <div id="outline-container-sec-1-1" class="outline-3">
| <h3 id="sec-1-1"><span class="section-number-3">1.1</span> <span
| class="todo TODO">TODO</span> B1&#xa0;&#xa0;&#xa0;<span
| class="tag"><span class="ARCHIVED">ARCHIVED</span></span></h3>
| <div class="outline-text-3" id="text-1-1">
| <p>
| Text B1
| </p>
| </div>
| </div>
`-------------------------------------------------------------------------

when emacs is called standalone

#+begin_src sh
  $ emacs -Q -e ...
#+end_src

and something like this

,----------------------------------------------------------------------
| "\n<div id=\"outline-container-sec-1\" class=\"outline-2\">\n<h2
| id=\"sec-1\"><span class=\"section-number-2\">1</span> NEXT
| A1&#xa0;&#xa0;&#xa0;<span class=\"tag\"><span
| class=\"home\">home</span>&#xa0;<span
| class=\"iorg\">iorg</span></span></h2>\n<div class=\"outline-text-2\"
| id=\"text-1\">\n<p>\nB1\n</p>\n</div>\n\n<div
| id=\"outline-container-sec-1-1\" class=\"outline-3\">\n<h3
| id=\"sec-1-1\"><span class=\"section-number-3\">1.1</span> <span
| class=\"todo TODO\">TODO</span> B1&#xa0;&#xa0;&#xa0;<span
| class=\"tag\"><span
| class=\"ARCHIVED\">ARCHIVED</span></span></h3>\n<div
| class=\"outline-text-3\" id=\"text-1-1\">\n<p>\nText
| B1\n</p>\n</div>\n</div>
`----------------------------------------------------------------------

when exactly the same html-exporting functionality is called via

#+begin_src sh
   $ emacsclient -e ...
#+end_src

I would call that at least strange behaviour, if not a bug.

--
cheers,
Thorsten




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Linefeeds (\n) to stdout
  2013-10-10  9:42 ` Thorsten Jolitz
@ 2013-10-10 11:49   ` Stefan Monnier
  2013-10-10 17:17     ` Thorsten Jolitz
  0 siblings, 1 reply; 4+ messages in thread
From: Stefan Monnier @ 2013-10-10 11:49 UTC (permalink / raw)
  To: help-gnu-emacs

> I would call that at least strange behaviour, if not a bug.

M-x report-emacs-bug


        Stefan





^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Linefeeds (\n) to stdout
  2013-10-10 11:49   ` Stefan Monnier
@ 2013-10-10 17:17     ` Thorsten Jolitz
  0 siblings, 0 replies; 4+ messages in thread
From: Thorsten Jolitz @ 2013-10-10 17:17 UTC (permalink / raw)
  To: help-gnu-emacs

Stefan Monnier <monnier@iro.umontreal.ca> writes:

>> I would call that at least strange behaviour, if not a bug.
>
> M-x report-emacs-bug

I can file a bug-report later, but currently I would rather need to know
what is the matter with emacsclient? And find some kind of work-around
pretty soon ...

I output the html produced by Emacs with `princ', and with standalone
Emacs, this is received by the calling program as expected - \n are
actual line-breaks, \" are printed as  " (unquoted) etc.

But with emacsclient, \n are printed verbatim, just like the \" etc.
Furthermore, the whole html string send by Emacs is printed enclosed in
double-quotes. And there are some random underscores in the text parts
of the html page, but I'm not sure if this only happens with
emacsclient.

To me it seems 'the right thing' to do

,---------------------------------------------
| (princ (function-that-returns-a-string ...))
`---------------------------------------------

and since emacsclient isn't really a brandnew feature, I wonder if
nobody witnessed the same problem before? The guys who wrote
'org-protocol.el' obviously dealt with this problem, but on the Emacs
side, when processing input from another application.

I hacked together some code on the calling PicoLisp-program side that
post-processes the html-string received from Emacs (via emacsclient) -
but is this really the only way to deal with this problem?

--
cheers,
Thorsten




^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2013-10-10 17:17 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-10-07 20:24 Linefeeds (\n) to stdout Thorsten Jolitz
2013-10-10  9:42 ` Thorsten Jolitz
2013-10-10 11:49   ` Stefan Monnier
2013-10-10 17:17     ` Thorsten Jolitz

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).