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

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

Return value not as expected in Emacs Lisp function


From: Thorsten Jolitz
Subject: Return value not as expected in Emacs Lisp function
Date: Wed, 07 Aug 2013 20:48:12 +0200
User-agent: Gnus/5.130002 (Ma Gnus v0.2) Emacs/24.3 (gnu/linux)

Hi List, 

I have a hard time to understand the following behaviour of an Emacs Lisp
program of mine. Here is an abstract version of this program:

#+begin_src emacs-lisp
  (defun my-fun ()
    (let ((result (concat
                    "(prog "
                    (mapconcat
                     (lambda ...)
                     lst "")
                    ")")))
      (message "%s" result) ; just for logging
      result))
#+end_src

After running the program, I find, as expected, something like this in
the *Messages* buffer:

#+begin_quote
(prog (click NIL 1)(press NIL 1)(click NIL 4)(click NIL 1))
#+end_quote

so the value of 'result' is just fine in the second-last line of the
fun.

But the return value is not what I would expect

#+begin_src emacs-lisp
 (print (my-fun))
#+end_src

or 

#+begin_src emacs-lisp
 (message "%s" (my-fun))
#+end_src

yield

#+begin_quote
(prog )
#+end_quote

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. 

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?

-- 
cheers,
Thorsten




reply via email to

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