[Top][All Lists]

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

Re: Raw strings (experimental patches inside)

From: Pascal J. Bourguignon
Subject: Re: Raw strings (experimental patches inside)
Date: Mon, 06 Aug 2012 12:55:56 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.4 (gnu/linux)

Stefan Monnier <address@hidden> writes:

>> I have a CL reader, written in CL.  One could port it to emacs-24 easily
>> enough I'd say.  It's AGPL3, I wouldn't mind assigning the copyright of
>> a derived work of it to the FSF for inclusion in emacs.
> I think the problem is to get emacs-lisp-mode to understand it.

Indeed, CL reader macros are a problem for editors.  But the only practical
solution involves having the CL reader (and thus the whole CL language)
implemented in the editor.  Therefore including emacs-cl would indeed be
more indicated (bar a rewrite of emacs in Common Lisp).

In general, you need to be able to read the reader macro to know where
it starts and where it ends.  Reading is recursive, and reading a reader
macro may involve reading other embedded reader macros, thus you can
obtain a tree of ranges.

For indenting, we need in general more information, but this could be
provided by a table mapping reader macros and indenting rules.

To give a taste of the problem, here is an example of the kind of Common
Lisp code I'm working with now:

    (with-handle (viewh view)
      [viewh setNeedsDisplayInRect:(nsrect #@(10 10) 
                                           #@(200 100))])

Here, we have:
- one standard CL reader macro for #\(
- one non standardreader macro for #\[
- one non standard dispatching reader macro for #\# address@hidden

The syntax of the text inside [] is complex, similar to Objective-C, and
we would like to have Objective-C-like font-locking and indenting, but
the parts in parentheses in this reader macro are actually read by the
standard CL reader macro for #\(, and here we want the normal Common
Lisp font-locking and indenting.

The dispatching reader macro for #\# #\@ here is a usual example of CL
reader macros, where the syntax following it is read with the standard
CL lisp reader (contrarily to what's read by the #\[ reader macro).

That information however can only be learned by executing the reader
macro and taking note of what reader macros are run.  There are
difficulties such as the fact that reader macros may seek in the stream
and read some parts twice, but a conforming reader macro should not have
side effects preventing its repeated use on the same text, so the editor
itself can do that.

__Pascal Bourguignon__                     http://www.informatimago.com/
A bad day in () is better than a good day in {}.

reply via email to

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