From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Pascal Bourguignon Newsgroups: gmane.emacs.help Subject: Re: A couple rudimentary elisp questions Date: 01 Mar 2004 03:17:55 +0100 Organization: [posted via Easynet Spain] Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Message-ID: <87smgtxqcs.fsf@thalassa.informatimago.com> References: NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1078108339 12676 80.91.224.253 (1 Mar 2004 02:32:19 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Mon, 1 Mar 2004 02:32:19 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Mon Mar 01 03:32:11 2004 Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1AxdE2-0003iJ-00 for ; Mon, 01 Mar 2004 03:32:10 +0100 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.30) id 1AxdCk-0003BL-G8 for geh-help-gnu-emacs@m.gmane.org; Sun, 29 Feb 2004 21:30:50 -0500 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!news.tele.dk!news.tele.dk!small.news.tele.dk!proxad.net!proxad.net!easynet-monga!easynet.net!easynet-post2!not-for-mail Original-Newsgroups: gnu.emacs.help User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 Original-Lines: 121 Original-NNTP-Posting-Host: 62.93.174.79 Original-X-Trace: DXC==2WQjQ]HdjcmF4S;1`]E3dle1^NnlQj7bbBd4DjF1d]a Original-Xref: shelby.stanford.edu gnu.emacs.help:121384 Original-To: help-gnu-emacs@gnu.org X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.2 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 Xref: main.gmane.org gmane.emacs.help:17339 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:17339 exits funnel writes: > Hello, > > I'm pretty new to emacs and I've decided it's time to > take a crack at some simple lisp. I have a couple > silly questions: > > 1) Is there no way to specify multi-line comments? I > read the 'comments' section in the 'Emacs Lisp > Reference Manual' and it seems to indicate not, but it > seems kind of hard to believe. I'm trying to write a > custom c-style and it would be helpful if I could > comment/uncomment large chunks of my .emacs file and > reload it so I could try to figure out what's going > on. If there really are no multi line comments is > there any tricks for kludging it? In emacs lisp there's no multiline comment. You can use comment-region / uncomment-region to comment several lines at once. Otherwise you can use this trick: use a multi-line string as a comment, like you do for documentation strings: (defun my-fun () " This is the documentation string of the function my-fun that appears when you ask for the function documentation with (describe-function 'my-fun) or C-h C-f my-fun RET " (do-something) " Here is a ''comment'' spread on several lines. Actually, it's not a comment, it's a string that is ''evaluated'' in the course of this function, but since we don't do anything with it, it's finally ignored. " (do-something-else) (get-result)) Of course, since the strings are syntactically significant, you must take care where you put them. You can't put them inside function argument lists, or inside other data lists. They eventually get ignored only in statement lists, inside progn and equivalent (and not in a result position!). Perhaps a cleaner way to do it would be to defined a comment macro: (defmacro rem (&rest args)) (defun my-fun () " This is the documentation string of the function my-fun that appears when you ask for the function documentation with (describe-function 'my-fun) or C-h C-f my-fun RET " (do-something) (rem Here we have a "comment" but it is still scanned and tokenized. "So we may still use strings and use any kind of invalid token such as . . . :-) But note that you must still escape double-quotes such as: \" ") (do-something-else) (get-result)) You get two advantages with this rem macro: 1- a code walker can find your comments if you need to process them. 2- since the macro generates nothing, the comment/strings don't eventually appear in compiled code, and the execution of compiled code is strictly equivalent with or without the (rem ...) (that could be not the case without the macro). > 2) I see alot of lists of the form (foo . bar). What > does the dot specify? It's the notation for a cons cell: (cons 'foo 'bar) == (foo . bar) Lists are built on cons cells, starting from the empty list (): (cons 'foo ()) == (foo . ()) == (foo) (cons 'bar (cons 'foo ())) == (bar . (foo . ())) == (bar foo) (cons 'baz (cons 'bar (cons 'foo ()))) == (baz . (bar . (foo . ()))) == (baz bar foo) The value assigned to the symbol nil is (), the empty list, which is actually a special atom. The empty list () is NOT a cons: (consp ()) == nil, (atom ()) == t. -- __Pascal_Bourguignon__ http://www.informatimago.com/ There is no worse tyranny than to force a man to pay for what he doesn't want merely because you think it would be good for him.--Robert Heinlein http://www.theadvocates.org/