[AUCTeX-devel] Re: Changes in font locking

David Kastrup dak at gnu.org
Tue Mar 13 05:27:34 EDT 2007


"Robert Pluim" <rpluim at gmail.com> 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 http://mid.gmane.org/
> cp7323$qm7$1%40sea.gmane.org 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)
>           , at 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
following:

(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)))
       (unwind-protect
	   (progn
	     (set-syntax-table ,table)
	     , at body)
	 (save-current-buffer
	   (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



More information about the XEmacs-Beta mailing list