unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Thorsten Jolitz <tjolitz@gmail.com>
To: help-gnu-emacs@gnu.org
Subject: Re: Emacsclient sends ^J, PicoLisp receives _
Date: Wed, 26 Feb 2014 16:54:26 +0100	[thread overview]
Message-ID: <871typx425.fsf@gmail.com> (raw)
In-Reply-To: 87mwhew394.fsf@gmail.com

Thorsten Jolitz <tjolitz@gmail.com> writes:

Again following up to myself, I detected another possible culprit for
the 'bad' underscore introduced when sending output from Emacsclient to
PicoLisp:

In emacsclient.c I found this function:

#+begin_src C
  /* In STR, insert a & before each &, each space, each newline, and
     any initial -.  Change spaces to underscores, too, so that the
     return value never contains a space.
  
     Does not change the string.  Outputs the result to S.  */
  static void
  quote_argument (HSOCKET s, const char *str)
  {
    char *copy = (char *) xmalloc (strlen (str) * 2 + 1);
    const char *p;
    char *q;
  
    p = str;
    q = copy;
    while (*p)
      {
        if (*p == ' ')
          {
            ,*q++ = '&';
            ,*q++ = '_';
            p++;
          } [...]
#+end_src

that is called (together with its antipode `unquote_argument') quite a
few times:

,----------------------------------------------------------------------------
| 17 matches for "quote_argument" in buffer: emacsclient.c
|     782:quote_argument (HSOCKET s, const char *str)
|     819:/* The inverse of quote_argument.  Removes quoting in string STR by
|     823:unquote_argument (char *str)
|    1599:          quote_argument (emacs_socket, environ[i]);
|    1604:  quote_argument (emacs_socket, cwd);
|    1618:      quote_argument (emacs_socket, display);
|    1625:      quote_argument (emacs_socket, parent_id);
|    1632:      quote_argument (emacs_socket, frame_parameters);
|    1649:          quote_argument (emacs_socket, tty_name);
|    1651:          quote_argument (emacs_socket, tty_type);
|    1669:              quote_argument (emacs_socket, argv[i]);
|    1681:                  quote_argument (emacs_socket, argv[i]);
|    1708:          quote_argument (emacs_socket, argv[i]);
|    1718:          quote_argument (emacs_socket, str);
|    1786:              str = unquote_argument (p + strlen ("-print "));
|    1796:              str = unquote_argument (p + strlen ("-print-nonl "));
|    1803:              str = unquote_argument (p + strlen ("-error "));
`----------------------------------------------------------------------------

Now I'm not that much of a C programmer, so I'm not sure what is
actually quoted and unquoted.

Is it possible that Emacsclients quotes and unquotes the output string
produced by my Org-exporter when sending it to PicoLisp (replacing
spaces with underscores and vice-versa) and occasionally things go
wrong in the process (i.e. some underscores are left in the final
string arriving at the PicoLisp side)?

Or is this quoting/unquoting done by Emacsclient completely unrelated
to my issue?

-- 
cheers,
Thorsten




  reply	other threads:[~2014-02-26 15:54 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-26 10:12 Emacsclient sends ^J, PicoLisp receives _ Thorsten Jolitz
2014-02-26 10:57 ` Thorsten Jolitz
2014-02-26 15:54   ` Thorsten Jolitz [this message]
     [not found]   ` <mailman.16107.1393430045.10748.help-gnu-emacs@gnu.org>
2014-02-28 10:17     ` duthen01
2014-02-28 18:59       ` Thorsten Jolitz

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=871typx425.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.
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).