GNU bug report logs - #47877
[PATCH] Respect sgml-xml-mode

Previous Next

Package: emacs;

Reported by: Philip Kaludercic <philipk <at> posteo.net>

Date: Sun, 18 Apr 2021 18:57:02 UTC

Severity: normal

Tags: fixed, patch

Fixed in version 28.1

Done: Stefan Kangas <stefan <at> marxist.se>

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 47877 in the body.
You can then email your comments to 47877 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#47877; Package emacs. (Sun, 18 Apr 2021 18:57:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Philip Kaludercic <philipk <at> posteo.net>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Sun, 18 Apr 2021 18:57:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Philip Kaludercic <philipk <at> posteo.net>
To: bug-gnu-emacs <at> gnu.org
Subject: [PATCH] Respect sgml-xml-mode
Date: Sun, 18 Apr 2021 18:56:26 +0000
[Message part 1 (text/plain, inline)]
sgml-xml-mode is a user option that is over-riden by smgl-mode. When I
customize sgml-xml-mode to be enabled for every sgml-mode derived mode
(specifically html-mode), it is disabled because a HTML file does not
have to be a valid XML file -- even if I would want it to be.

This patch only sets sgml-xml-mode if we know that the current file is
an XML file, but leaves the default value if it cannot be said for sure.

-- 
	Philip K.
[0001-sgml-mode-Only-set-sgml-xml-mode-if-guessed-to-be-an.patch (text/x-diff, inline)]
From 934906eacc02ded6784653ef7b714b57b7b952b7 Mon Sep 17 00:00:00 2001
From: Philip K <philipk <at> posteo.net>
Date: Wed, 14 Apr 2021 19:19:01 +0200
Subject: [PATCH 1/4] sgml-mode: Only set sgml-xml-mode if guessed to be an XML
 file

The user preference for sgml-xml-mode is overridden by default if the
result of the guess is used as the buffer local value.
---
 lisp/textmodes/sgml-mode.el | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/lisp/textmodes/sgml-mode.el b/lisp/textmodes/sgml-mode.el
index 67f731917e..d5930e82df 100644
--- a/lisp/textmodes/sgml-mode.el
+++ b/lisp/textmodes/sgml-mode.el
@@ -623,7 +623,8 @@ sgml-mode
   (setq-local syntax-propertize-function #'sgml-syntax-propertize)
   (setq-local syntax-ppss-table sgml-tag-syntax-table)
   (setq-local facemenu-add-face-function 'sgml-mode-facemenu-add-face-function)
-  (setq-local sgml-xml-mode (sgml-xml-guess))
+  (when (sgml-xml-guess)
+    (setq-local sgml-xml-mode t))
   (unless sgml-xml-mode
     (setq-local skeleton-transformation-function sgml-transformation-function))
   ;; This will allow existing comments within declarations to be
-- 
2.30.2


Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#47877; Package emacs. (Tue, 20 Apr 2021 23:46:01 GMT) Full text and rfc822 format available.

Message #8 received at 47877 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Kangas <stefan <at> marxist.se>
To: Philip Kaludercic <philipk <at> posteo.net>
Cc: 47877 <at> debbugs.gnu.org
Subject: Re: bug#47877: [PATCH] Respect sgml-xml-mode
Date: Tue, 20 Apr 2021 18:45:18 -0500
Philip Kaludercic <philipk <at> posteo.net> writes:

> sgml-xml-mode is a user option that is over-riden by smgl-mode. When I
> customize sgml-xml-mode to be enabled for every sgml-mode derived mode
> (specifically html-mode), it is disabled because a HTML file does not
> have to be a valid XML file -- even if I would want it to be.
>
> This patch only sets sgml-xml-mode if we know that the current file is
> an XML file, but leaves the default value if it cannot be said for sure.

Thanks for the patch.

Your explanation sounds reasonable, but could you perhaps provide a
recipe for how to reproduce this problem (preferably starting from emacs
-Q)?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#47877; Package emacs. (Wed, 21 Apr 2021 07:28:01 GMT) Full text and rfc822 format available.

Message #11 received at 47877 <at> debbugs.gnu.org (full text, mbox):

From: Philip Kaludercic <philipk <at> posteo.net>
To: Stefan Kangas <stefan <at> marxist.se>
Cc: 47877 <at> debbugs.gnu.org
Subject: Re: bug#47877: [PATCH] Respect sgml-xml-mode
Date: Wed, 21 Apr 2021 07:27:16 +0000
Stefan Kangas <stefan <at> marxist.se> writes:

> Philip Kaludercic <philipk <at> posteo.net> writes:
>
>> sgml-xml-mode is a user option that is over-riden by smgl-mode. When I
>> customize sgml-xml-mode to be enabled for every sgml-mode derived mode
>> (specifically html-mode), it is disabled because a HTML file does not
>> have to be a valid XML file -- even if I would want it to be.
>>
>> This patch only sets sgml-xml-mode if we know that the current file is
>> an XML file, but leaves the default value if it cannot be said for sure.
>
> Thanks for the patch.
>
> Your explanation sounds reasonable, but could you perhaps provide a
> recipe for how to reproduce this problem (preferably starting from emacs
> -Q)?

1. Customize sgml-xml-mode to t
2. Open a HTML file
3. Insert a tag using C-c C-o, eg. <p>

Compare this to


1. Open a HTML file
2. Manually set sgml-xml-mode to t
3. Insert a tag using C-c C-o, eg. <p>

and in this time you will also have a </p> tag generated, as intended.

-- 
	Philip K.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#47877; Package emacs. (Wed, 21 Apr 2021 13:42:01 GMT) Full text and rfc822 format available.

Message #14 received at 47877 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Kangas <stefan <at> marxist.se>
To: Philip Kaludercic <philipk <at> posteo.net>
Cc: 47877 <at> debbugs.gnu.org
Subject: Re: bug#47877: [PATCH] Respect sgml-xml-mode
Date: Wed, 21 Apr 2021 08:41:45 -0500
tags 47877 fixed
close 47877 28.1
thanks

Philip Kaludercic <philipk <at> posteo.net> writes:

> Stefan Kangas <stefan <at> marxist.se> writes:
>
>> Philip Kaludercic <philipk <at> posteo.net> writes:
>>
>>> sgml-xml-mode is a user option that is over-riden by smgl-mode. When I
>>> customize sgml-xml-mode to be enabled for every sgml-mode derived mode
>>> (specifically html-mode), it is disabled because a HTML file does not
>>> have to be a valid XML file -- even if I would want it to be.
>>>
>>> This patch only sets sgml-xml-mode if we know that the current file is
>>> an XML file, but leaves the default value if it cannot be said for sure.
>>
>> Thanks for the patch.
>>
>> Your explanation sounds reasonable, but could you perhaps provide a
>> recipe for how to reproduce this problem (preferably starting from emacs
>> -Q)?
>
> 1. Customize sgml-xml-mode to t
> 2. Open a HTML file
> 3. Insert a tag using C-c C-o, eg. <p>
>
> Compare this to
>
>
> 1. Open a HTML file
> 2. Manually set sgml-xml-mode to t
> 3. Insert a tag using C-c C-o, eg. <p>
>
> and in this time you will also have a </p> tag generated, as intended.

Thanks, I can now see that your patch indeed fixes that problem.

So I fixed your commit message to follow our preferred format:

    sgml-mode: Only set sgml-xml-mode if guessed to be an XML file

    * lisp/textmodes/sgml-mode.el (sgml-mode): Don't override
    sgml-xml-mode if the result of the guess is used as the buffer local
    value.  (Bug#47877)

It is now pushed to master (3e727cf20b); closing this bug.




Added tag(s) fixed. Request was from Stefan Kangas <stefan <at> marxist.se> to control <at> debbugs.gnu.org. (Wed, 21 Apr 2021 13:42:02 GMT) Full text and rfc822 format available.

bug marked as fixed in version 28.1, send any further explanations to 47877 <at> debbugs.gnu.org and Philip Kaludercic <philipk <at> posteo.net> Request was from Stefan Kangas <stefan <at> marxist.se> to control <at> debbugs.gnu.org. (Wed, 21 Apr 2021 13:42:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Thu, 20 May 2021 11:24:09 GMT) Full text and rfc822 format available.

This bug report was last modified 2 years and 313 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.