[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Return value not as expected in Emacs Lisp function
From: |
Pascal J. Bourguignon |
Subject: |
Re: Return value not as expected in Emacs Lisp function |
Date: |
Wed, 07 Aug 2013 23:07:05 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.2 (gnu/linux) |
Thorsten Jolitz <tjolitz@gmail.com> writes:
> and I ask myself what happened between the second-last and the last line of
> the function? I cannot reproduce this with a MWE, and the real function is too
> convoluted to present it here, so I keep the problem description on an
> abstract level.
On an abstract leve, I can't debug a function if I don't have it's
code. That's the reason d'ĂȘtre of the MWE, and by default the real code.
> I'm actually only interested in the result string as a return value, the
> message statement is just for logging. But why is the string produced by
> 'mapconcat' missing in the return value?
The real question is why you use mapconcat to produce a string
representation of a sexp? Just use prin1-to-string!
(let ((list '((click NIL 1) (press NIL 1) (click NIL 4) (click NIL 1))))
(prin1-to-string `(prog ,@list )))
--> "(prog (click NIL 1) (press NIL 1) (click NIL 4) (click NIL 1))"
Notice:
- emacs lisp is a lisp-2, not a lst-1.
- NIL is true:
(not (not 'NIL)) --> t
(not 'NIL) --> nil
(if 'NIL 'true 'false) --> true
--
__Pascal Bourguignon__ http://www.informatimago.com/
A bad day in () is better than a good day in {}.
You know you've been lisping too long when you see a recent picture of George
Lucas and think "Wait, I thought John McCarthy was dead!" -- Dalek_Baldwin