From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Pascal J. Bourguignon" Newsgroups: gmane.emacs.help Subject: Re: Return value not as expected in Emacs Lisp function Date: Fri, 09 Aug 2013 00:31:19 +0200 Organization: Informatimago Message-ID: <87li4bolvs.fsf@informatimago.com> References: <8738qlfic3.fsf@gmail.com> <87pptpnrba.fsf@informatimago.com> <87pptpdscs.fsf@gmail.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: ger.gmane.org 1376001131 24214 80.91.229.3 (8 Aug 2013 22:32:11 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 8 Aug 2013 22:32:11 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Aug 09 00:32:13 2013 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1V7Yke-0004lP-HB for geh-help-gnu-emacs@m.gmane.org; Fri, 09 Aug 2013 00:32:12 +0200 Original-Received: from localhost ([::1]:43951 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V7Yke-0003t2-5C for geh-help-gnu-emacs@m.gmane.org; Thu, 08 Aug 2013 18:32:12 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:36802) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V7YkO-0003pr-E0 for help-gnu-emacs@gnu.org; Thu, 08 Aug 2013 18:32:02 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1V7YkI-0001IX-JV for help-gnu-emacs@gnu.org; Thu, 08 Aug 2013 18:31:56 -0400 Original-Received: from plane.gmane.org ([80.91.229.3]:42911) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V7YkI-0001ID-Dw for help-gnu-emacs@gnu.org; Thu, 08 Aug 2013 18:31:50 -0400 Original-Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1V7YkG-0004Pe-4R for help-gnu-emacs@gnu.org; Fri, 09 Aug 2013 00:31:48 +0200 Original-Received: from amontsouris-651-1-13-20.w90-46.abo.wanadoo.fr ([90.46.104.20]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 09 Aug 2013 00:31:48 +0200 Original-Received: from pjb by amontsouris-651-1-13-20.w90-46.abo.wanadoo.fr with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 09 Aug 2013 00:31:48 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 54 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: amontsouris-651-1-13-20.w90-46.abo.wanadoo.fr Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwAQMAAABtzGvEAAAABlBMVEUAAAD///+l2Z/dAAAA oElEQVR4nK3OsRHCMAwF0O8YQufUNIQRGIAja9CxSA55AxZgFO4coMgYrEDDQZWPIlNAjwq9 033pbOBPtbXuB6PKNBn5gZkhGa86Z4x2wE67O+06WxGD/HCOGR0deY3f9Ijwwt7rNGNf6Oac l/GuZTF1wFGKiYYHKSFAkjIo1b6sCYS1sVmFhhhahKQssRjRT90ITWUk6vvK3RsPGs+M1RuR mV+hO/VvFAAAAABJRU5ErkJggg== X-Accept-Language: fr, es, en User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2 (gnu/linux) Cancel-Lock: sha1:MzBmODljNjIzYzg2YTFmZDVhNWRhNzU3ODNkM2M3MjVkNmZjMGExMQ== X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 80.91.229.3 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:92784 Archived-At: Thorsten Jolitz 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. 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. -- __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