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

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

Re: Bringing psgml back to life


From: Stefan Monnier
Subject: Re: Bringing psgml back to life
Date: Mon, 27 Aug 2012 00:14:05 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2.50 (gnu/linux)

> I have several reasons for wanting to bring psgml back to life, and I

I'd be interested to hear them.

> 1. The following seems to trigger a fatal error (from psgml-parse.el, line 
> 903)
> (defmacro sgml-prop-fields (&rest names)
>   (cons
>    'progn
>    (loop for n in names collect
>        (`(defmacro (, (intern (format "sgml-eltype-%s" n))) (et)
>            (list 'get et ''(, n)))))))
> namely:
> File mode specification error: (invalid-function (\` (defmacro ((\, (intern 
> (format "sgml-eltype-%s" n)))) (et) (list (quote get) et (quote (quote ((\, 
> n))))))))

You need a space after "(`".  That's the old backquote syntax (which
originally didn't require the space, but now does, as a first step
towards fully removing support for it).

> 2. The old-style backquotes which psgml uses do not seem to be fatal
> on compiling, but at runtime. E.g., 
> `(1 2 3 ,(+ 2 2))
> works fine, but 
> (`(1 2 3 (,(+ 2 2))))
> throws an error and complains that (` ...) is an invalid function.

Again, you need a space after the old-style "(`" and "(,".

> Is it correct to assume that the fix is to simply remove the
> surrounding quotes? E.g.,
> (` (char-int (, ch)))  -->  `(char-int ,ch)

Yes, that's the conversion to new-style and is what you should do.

> And, likewise, (,@ ... ) --> ,@ ... ?

Yup.

> (In other words, is this the straightforward fix for the error in 1?)

Yes, that should fix it as well.

> (defmacro sgml-move-token (x)
>   (` (car (, x))))
> I'm never really sure if defmacro (which I have never used) would
> normally require me to put parentheses around its body anyway,

No, the body of a defmacro is a normal expression.

> or if the fix for this piece of code could legally look like:
> (defmacro sgml-move-token (x)
>   `(car , x))

Yes, this is the better new-style form (tho I wouldn't put a space
between the "," and the "x").

> Another example is of course the (loop ...) construct shown in 1 (see
> above).  Does loop want parentheses where the backquote is preceded
> by one?

No, the extra parens are for the old-style backquote and have nothing to
do with `loop'.

> 4. And what, for heaven's sake, is this stuff in the last line of the
> (defmacro ) form in 1.?
> ''(, n)  ?

That's the old-style form of "'',n".

> A quick check shows that it would apparently be legal syntax to remove
> the parentheses:
> `(1 2 3 '',(+ 2 2))
> --> (1 2 3 (quote (quote 4)))
> So, simply no worries, and go ahead?

I think so, yes.


        Stefan


reply via email to

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