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: Return value not as expected in Emacs Lisp function
Date: Fri, 09 Aug 2013 14:03:06 +0200	[thread overview]
Message-ID: <8761vfm5qd.fsf@gmail.com> (raw)
In-Reply-To: 87li4bolvs.fsf@informatimago.com

"Pascal J. Bourguignon" <pjb@informatimago.com> writes:

> Thorsten Jolitz <tjolitz@gmail.com> writes:
>
>> ,-----------------------------------------------------------------
>> | "(prog (click NIL 1) (press NIL 1) (click NIL 4) (click NIL 1))"
>> `-----------------------------------------------------------------
>>
>> is actually PicoLisp, a lisp-1 with NIL and T syntax (uppercase!). I
>> thought the 'prog in the beginning (PicoLisp's 'progn)  would make it
>> clear its not Elisp. At least C-h f doesn' show me a 'prog function in
>> Elisp. 
>>
>> But thanks for your answer, I did not know `prin1-to-string', and finally
>> looked up the difference between lisp-1 and lisp-2. 
>
> Ok, that explains the 'lst.
>
> Now, emacs has one good characteristic that helps in manipilating sexps
> from other lisps:  it has no module or package system and it has case
> sensitive symbols, with no lisp reader to upcase them automatically by
> default.
>
> Therefore, you can perfectly manipulate picolisp sexps as emacs lisp
> sexps.  Unless you have to deal with reader macros or other strange
> syntaxes, my advice would be to stick to sexps, this has big advantages
> over strings.

But isn't the communication between the two lisps (picolisp and elisp)
always done with strings? It `comint-send-string' or
`process-send-string', no matter if that string contains a sexp or
something else. Of course, both lisps can then "read-from-string" the
sexps they recieve from the other program if the syntax matches, but
they are send and arrive as strings - right?

> As for the misplaced parenthesis problem, be sure to let emacs
> auto-indent lisp (any) code for you, selectnig a region and typing C-M-\
> (indent-region), or using paredit (strongly advised, to edit any kind of
> sexps), typing M-q (paredit-reindent-defun) from time to time inside
> sexps.
>
> Then you will be shocked by any misplaced parenthesis, since it will
> imply very strange indentation, like this:
>
>
> (defun hostname ()
>   (interactive "Hello"
>                (cond ((boundp  'system-name) system-name)
>                      ((fboundp 'system-name) (system-name)))
>                (t (shell-command-to-string
>                    "echo -n $( (hostname -f 2>/dev/null) || (hostname 2>/dev/null) )"))))
>
> where it is obvious that there's a missing closing parenthesis for
> interactive, and that the cond is closed too early (before the (t …)
> branch.

ok, thx for the tip. 

-- 
cheers,
Thorsten




      reply	other threads:[~2013-08-09 12:03 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-07 18:48 Return value not as expected in Emacs Lisp function Thorsten Jolitz
2013-08-07 21:00 ` Stefan Monnier
2013-08-07 22:47   ` Thorsten Jolitz
2013-08-07 21:07 ` Pascal J. Bourguignon
2013-08-07 22:54   ` Thorsten Jolitz
2013-08-08 22:31     ` Pascal J. Bourguignon
2013-08-09 12:03       ` 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

  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=8761vfm5qd.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).