help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Return value not as expected in Emacs Lisp function


From: Thorsten Jolitz
Subject: Re: Return value not as expected in Emacs Lisp function
Date: Fri, 09 Aug 2013 14:03:06 +0200
User-agent: Gnus/5.130002 (Ma Gnus v0.2) Emacs/24.3 (gnu/linux)

"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 via email to

[Prev in Thread] Current Thread [Next in Thread]