GNU bug report logs -
#16160
[PATCH] define-derived-mode clobbers syntax tables
Previous Next
Reported by: Daniel Colascione <dancol <at> dancol.org>
Date: Mon, 16 Dec 2013 11:14:02 UTC
Severity: normal
Tags: confirmed
Fixed in version 26.1
Done: Glenn Morris <rgm <at> gnu.org>
Bug is archived. No further changes may be made.
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 16160 in the body.
You can then email your comments to 16160 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#16160
; Package
emacs
.
(Mon, 16 Dec 2013 11:14:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Daniel Colascione <dancol <at> dancol.org>
:
New bug report received and forwarded. Copy sent to
bug-gnu-emacs <at> gnu.org
.
(Mon, 16 Dec 2013 11:14:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
Repro:
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.
The define-derived-mode macro in sh-script.el emits code that clobbers
sh-mode-syntax-table because we don't have a :syntax-table argument. I
think the following patch changes the code to the expected behavior.
~/edev/trunk
$ bzr diff
=== modified file 'lisp/emacs-lisp/derived.el'
--- lisp/emacs-lisp/derived.el 2013-05-27 16:12:52 +0000
+++ lisp/emacs-lisp/derived.el 2013-12-16 11:09:41 +0000
@@ -206,11 +206,11 @@
,(if declare-syntax
`(progn
(unless (boundp ',syntax)
- (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)))))))
,(if declare-abbrev
`(progn
(put ',abbrev 'definition-name ',child)
That is, we shouldn't touch the syntax table variable at all unless the
variable is unbound.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#16160
; Package
emacs
.
(Mon, 16 Dec 2013 19:18:02 GMT)
Full text and
rfc822 format available.
Message #8 received at 16160 <at> debbugs.gnu.org (full text, mbox):
> 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
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#16160
; Package
emacs
.
(Tue, 17 Dec 2013 02:19:02 GMT)
Full text and
rfc822 format available.
Message #11 received at 16160 <at> debbugs.gnu.org (full text, mbox):
On 12/16/2013 11:17 AM, Stefan Monnier wrote:
>> 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".
I can't repro it either now, with or without -Q. That was odd. I know
what I saw, and I know that my patch resolved the problem in that
instance of Emacs, but I have no idea how defvar was clobbering that
variable. I was able to repro it over an dover again though. I can only
conclude that Emacs was punishing me for my many sins.
If I see it again, I'll try to hook Emacs up to a debugger. In the
meantime, let's avoid changing fundamental infrastructure before a
feature freeze.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#16160
; Package
emacs
.
(Tue, 17 Dec 2013 02:37:02 GMT)
Full text and
rfc822 format available.
Message #14 received at 16160 <at> debbugs.gnu.org (full text, mbox):
> I can only conclude that Emacs was punishing me for my many sins.
I believe He may forgive you, if you fix a few bugs for penance.
Stefan
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#16160
; Package
emacs
.
(Fri, 20 Dec 2013 21:46:01 GMT)
Full text and
rfc822 format available.
Message #17 received at 16160 <at> debbugs.gnu.org (full text, mbox):
Actually...
On 12/16/2013 06:17 PM, Daniel Colascione wrote:
> On 12/16/2013 11:17 AM, Stefan Monnier wrote:
>>> 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.
The repro steps are incorrect. Try these:
1) emacs -Q
2) visit a shell script
3) M-x find-library sh-script RET
4) C-s define-derived-mode RET
5) C-M-x
6) switch to your shell script buffer
7) C-x C-v
8) Observe that the shell script is fontified incorrectly; the syntax
table is now clobbered.
Removed tag(s) moreinfo.
Request was from
Lars Ingebrigtsen <larsi <at> gnus.org>
to
control <at> debbugs.gnu.org
.
(Sat, 26 Dec 2015 01:36:01 GMT)
Full text and
rfc822 format available.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#16160
; Package
emacs
.
(Tue, 01 Mar 2016 02:12:02 GMT)
Full text and
rfc822 format available.
Message #22 received at 16160 <at> debbugs.gnu.org (full text, mbox):
Daniel Colascione <dancol <at> dancol.org> writes:
> The repro steps are incorrect. Try these:
>
> 1) emacs -Q
> 2) visit a shell script
> 3) M-x find-library sh-script RET
> 4) C-s define-derived-mode RET
> 5) C-M-x
> 6) switch to your shell script buffer
> 7) C-x C-v
> 8) Observe that the shell script is fontified incorrectly; the syntax
> table is now clobbered.
I can confirm that this bug still exists.
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
Added tag(s) confirmed.
Request was from
Lars Ingebrigtsen <larsi <at> gnus.org>
to
control <at> debbugs.gnu.org
.
(Tue, 01 Mar 2016 02:12:04 GMT)
Full text and
rfc822 format available.
Removed tag(s) unreproducible.
Request was from
Lars Ingebrigtsen <larsi <at> gnus.org>
to
control <at> debbugs.gnu.org
.
(Tue, 01 Mar 2016 02:12:04 GMT)
Full text and
rfc822 format available.
Reply sent
to
Glenn Morris <rgm <at> gnu.org>
:
You have taken responsibility.
(Tue, 13 Dec 2016 01:05:02 GMT)
Full text and
rfc822 format available.
Notification sent
to
Daniel Colascione <dancol <at> dancol.org>
:
bug acknowledged by developer.
(Tue, 13 Dec 2016 01:05:02 GMT)
Full text and
rfc822 format available.
Message #31 received at 16160-done <at> debbugs.gnu.org (full text, mbox):
Version: 26.1
>> The repro steps are incorrect. Try these:
>>
>> 1) emacs -Q
>> 2) visit a shell script
>> 3) M-x find-library sh-script RET
>> 4) C-s define-derived-mode RET
>> 5) C-M-x
>> 6) switch to your shell script buffer
>> 7) C-x C-v
>> 8) Observe that the shell script is fontified incorrectly; the syntax
>> table is now clobbered.
Fixed in 8db7b65 along the suggested lines.
So AIUI the issue is that define-derived-mode expands to
(defvar ,syntax (make-syntax-table))
Normally this has no effect if ,syntax is already bound.
But M-x eval-defun resets defvars to their default settings...
Hence if you selectively re-evaluate only the mode definition from
sh-script.el, you get the reported problem.
So I changed it to explicitly check if ,syntax is bound.
This will however now make things go wrong in the opposite way for
someone who has been playing around with customizing a syntax table that
was actually defined by define-derived-mode and wants to reset it by
re-evaluating the derived mode definition. But AFAICS there's no way to
fix both scenarios, and the second seems less likely (?) to me than the
one reported here.
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Tue, 10 Jan 2017 12:24:04 GMT)
Full text and
rfc822 format available.
This bug report was last modified 8 years and 166 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.