* A couple rudimentary elisp questions
@ 2004-02-29 23:55 exits funnel
0 siblings, 0 replies; 7+ messages in thread
From: exits funnel @ 2004-02-29 23:55 UTC (permalink / raw)
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?
2) I see alot of lists of the form (foo . bar). What
does the dot specify?
Thanks in advance for answering what must seem like
foolish questions.
-exits
__________________________________
Do you Yahoo!?
Get better spam protection with Yahoo! Mail.
http://antispam.yahoo.com/tools
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: A couple rudimentary elisp questions
[not found] <mailman.810.1078098980.340.help-gnu-emacs@gnu.org>
@ 2004-03-01 0:56 ` Guldo K
2004-03-01 0:57 ` Johan Bockgård
2004-03-01 2:17 ` Pascal Bourguignon
2 siblings, 0 replies; 7+ messages in thread
From: Guldo K @ 2004-03-01 0:56 UTC (permalink / raw)
exits funnel <exitsfunnel@yahoo.com> writes:
> 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?
I don't know of multiline comments, but I'm no emacs
expert, and no programmer either...
Anyway, perhaps you could use single-line commenting on a region;
lisp-interaction-mode and the comment-region command.
You have to mark the beginning of the region (C-spacebar)
to do so.
*Guldo*
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: A couple rudimentary elisp questions
[not found] <mailman.810.1078098980.340.help-gnu-emacs@gnu.org>
2004-03-01 0:56 ` A couple rudimentary elisp questions Guldo K
@ 2004-03-01 0:57 ` Johan Bockgård
2004-03-01 1:09 ` exits funnel
2004-03-01 2:17 ` Pascal Bourguignon
2 siblings, 1 reply; 7+ messages in thread
From: Johan Bockgård @ 2004-03-01 0:57 UTC (permalink / raw)
exits funnel <exitsfunnel@yahoo.com> writes:
> 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.
Why? While Emacs Lisp does indeed not have multi-line comments, there
are commands in Emacs for commenting and uncommenting regions.
> 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?
Reloading the entire file is the real kludge here. Reading this
section in the manual should be helpful:
(info "(emacs)Lisp Eval")
> 2) I see alot of lists of the form (foo . bar). What does the dot
> specify?
(info "(elisp)Dotted Pair Notation")
--
Johan Bockgård
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: A couple rudimentary elisp questions
2004-03-01 0:57 ` Johan Bockgård
@ 2004-03-01 1:09 ` exits funnel
0 siblings, 0 replies; 7+ messages in thread
From: exits funnel @ 2004-03-01 1:09 UTC (permalink / raw)
> Why? While Emacs Lisp does indeed not have
> multi-line comments, there
> are commands in Emacs for commenting and
> uncommenting regions.
Thanks. I should have found these on my own.
> Reloading the entire file is the real kludge here.
> Reading this
> section in the manual should be helpful:
>
> (info "(emacs)Lisp Eval")
>
> > 2) I see alot of lists of the form (foo . bar).
> What does the dot
> > specify?
>
> (info "(elisp)Dotted Pair Notation")
Thanks for both pointers. I will read them post haste
:)
-exits
__________________________________
Do you Yahoo!?
Get better spam protection with Yahoo! Mail.
http://antispam.yahoo.com/tools
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: A couple rudimentary elisp questions
[not found] <mailman.810.1078098980.340.help-gnu-emacs@gnu.org>
2004-03-01 0:56 ` A couple rudimentary elisp questions Guldo K
2004-03-01 0:57 ` Johan Bockgård
@ 2004-03-01 2:17 ` Pascal Bourguignon
2004-03-02 21:40 ` exits funnel
2 siblings, 1 reply; 7+ messages in thread
From: Pascal Bourguignon @ 2004-03-01 2:17 UTC (permalink / raw)
exits funnel <exitsfunnel@yahoo.com> 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/
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: A couple rudimentary elisp questions
[not found] <mailman.812.1078103660.340.help-gnu-emacs@gnu.org>
@ 2004-03-01 17:09 ` Stefan Monnier
0 siblings, 0 replies; 7+ messages in thread
From: Stefan Monnier @ 2004-03-01 17:09 UTC (permalink / raw)
>> Why? While Emacs Lisp does indeed not have
>> multi-line comments, there
>> are commands in Emacs for commenting and
>> uncommenting regions.
> Thanks. I should have found these on my own.
If you have turned on transient-mark-mode (which I recommend), you can
access these two command via M-;
Stefan
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: A couple rudimentary elisp questions
2004-03-01 2:17 ` Pascal Bourguignon
@ 2004-03-02 21:40 ` exits funnel
0 siblings, 0 replies; 7+ messages in thread
From: exits funnel @ 2004-03-02 21:40 UTC (permalink / raw)
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=us-ascii, Size: 3125 bytes --]
> 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).
> 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, I just wanted to take a quick moment to thank
you for your detailed reply. All of the information
was very helpful.
-exits
__________________________________
Do you Yahoo!?
Yahoo! Search - Find what youre looking for faster
http://search.yahoo.com
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2004-03-02 21:40 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <mailman.810.1078098980.340.help-gnu-emacs@gnu.org>
2004-03-01 0:56 ` A couple rudimentary elisp questions Guldo K
2004-03-01 0:57 ` Johan Bockgård
2004-03-01 1:09 ` exits funnel
2004-03-01 2:17 ` Pascal Bourguignon
2004-03-02 21:40 ` exits funnel
[not found] <mailman.812.1078103660.340.help-gnu-emacs@gnu.org>
2004-03-01 17:09 ` Stefan Monnier
2004-02-29 23:55 exits funnel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).