Subject: bug#16160: [PATCH] define-derived-mode clobbers syntax tables

From: Stefan Monnier <[email-masked]>
Date: Mon, 16 Dec 2013 14:17:19 -0500

> 1) Visit shell script with comments. See comments fontified properly.
> 2) M-x find-library sh-script RET
> 3) M-x eval-buffer
> 4) Return to shell script buffer
> 5) C-x C-v RET
> 6) Observe that comments are no longer fontified as comments.

I can't reproduce it, starting from "emacs -Q".

> -		 (put ',syntax 'definition-name ',child))
> -	       (defvar ,syntax (make-syntax-table))
> -	       (unless (get ',syntax 'variable-documentation)
> -		 (put ',syntax 'variable-documentation
> -		      (purecopy ,(format "Syntax table for `%s'." child))))))
> +		 (put ',syntax 'definition-name ',child)
> +                 (defvar ,syntax (make-syntax-table))
> +                 (unless (get ',syntax 'variable-documentation)
> +                   (put ',syntax 'variable-documentation
> +                        (purecopy ,(format "Syntax table for `%s'." child)))))))
> That is, we shouldn't touch the syntax table variable at all unless the
> variable is unbound.

But that shouldn't make much difference since none of the code you
changed should affect the var's value when it is already bound.
I'm not necessarily opposed to the change (haven't dug enough to try and
remember why it's written this way), but I'd first like to understand
why it fixes the problem you see.

        Stefan