[Top][All Lists]

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

Re: [AUCTeX-devel] Re: Changes in font locking

From: David Kastrup
Subject: Re: [AUCTeX-devel] Re: Changes in font locking
Date: Tue, 13 Mar 2007 10:27:34 +0100
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux)

"Robert Pluim" <address@hidden> writes:

> Patch to paper over this problem follows.  I suspect that 'copy-syntax-table'
> is actually at fault, but with this at least the test in
> cp7323$qm7$ works.
> Robert
> Index: subr.el
> ===================================================================
> RCS file: /pack/xemacscvs/XEmacs/xemacs/lisp/subr.el,v
> retrieving revision 1.39
> diff -u - r1.39 subr.el
> --- subr.el    2006/08/11 01:30:23    1.39
> +++ subr.el    2007/03/13 09:03:05
> @@ -607,7 +607,7 @@
>         (,old-buffer (current-buffer)))
>         (unwind-protect
>         (progn
> -         (set-syntax-table (copy-syntax-table ,table))
> +         (set-syntax-table ,table)
>           ,@body)
>       (save-current-buffer
>         (set-buffer ,old-buffer)

The idea of the copy probably was to have things like
`modify-syntax-entry' in `body' not have a lasting effect.  I doubt
that this is actually the intent of the macro according to its doc
string: actually, it is quite likely that people would set up a syntax
table with

(with-syntax-table some-table
  (modify-syntax-entry ?x ?y)

The corresponding macro in Emacs, if I am not mistaken, is the

(defmacro with-syntax-table (table &rest body)
  "Evaluate BODY with syntax table of current buffer set to TABLE.
The syntax table of the current buffer is saved, BODY is evaluated, and the
saved table is restored, even in case of an abnormal exit.
Value is what BODY returns."
  (declare (debug t))
  (let ((old-table (make-symbol "table"))
        (old-buffer (make-symbol "buffer")))
    `(let ((,old-table (syntax-table))
           (,old-buffer (current-buffer)))
             (set-syntax-table ,table)
           (set-buffer ,old-buffer)
           (set-syntax-table ,old-table))))))

I think it likely that copying the syntax table is a mistake, given
what people would expect from the doc string of the macro and given
that there is a non-trivial amount of code around which relies on the
non-copying behavior.

So I don't think your patch is "papering over the problem", but rather
fixing it.  I think it likely that `copy-syntax-table' works as
intended, and that it is just misused here.

David Kastrup

reply via email to

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