unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#47877: [PATCH] Respect sgml-xml-mode
@ 2021-04-18 18:56 Philip Kaludercic
  2021-04-20 23:45 ` Stefan Kangas
  0 siblings, 1 reply; 4+ messages in thread
From: Philip Kaludercic @ 2021-04-18 18:56 UTC (permalink / raw)
  To: 47877

[-- Attachment #1: Type: text/plain, Size: 436 bytes --]


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.

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-sgml-mode-Only-set-sgml-xml-mode-if-guessed-to-be-an.patch --]
[-- Type: text/x-diff, Size: 1148 bytes --]

From 934906eacc02ded6784653ef7b714b57b7b952b7 Mon Sep 17 00:00:00 2001
From: Philip K <philipk@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


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* bug#47877: [PATCH] Respect sgml-xml-mode
  2021-04-18 18:56 bug#47877: [PATCH] Respect sgml-xml-mode Philip Kaludercic
@ 2021-04-20 23:45 ` Stefan Kangas
  2021-04-21  7:27   ` Philip Kaludercic
  0 siblings, 1 reply; 4+ messages in thread
From: Stefan Kangas @ 2021-04-20 23:45 UTC (permalink / raw)
  To: Philip Kaludercic; +Cc: 47877

Philip Kaludercic <philipk@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)?





^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#47877: [PATCH] Respect sgml-xml-mode
  2021-04-20 23:45 ` Stefan Kangas
@ 2021-04-21  7:27   ` Philip Kaludercic
  2021-04-21 13:41     ` Stefan Kangas
  0 siblings, 1 reply; 4+ messages in thread
From: Philip Kaludercic @ 2021-04-21  7:27 UTC (permalink / raw)
  To: Stefan Kangas; +Cc: 47877

Stefan Kangas <stefan@marxist.se> writes:

> Philip Kaludercic <philipk@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.





^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#47877: [PATCH] Respect sgml-xml-mode
  2021-04-21  7:27   ` Philip Kaludercic
@ 2021-04-21 13:41     ` Stefan Kangas
  0 siblings, 0 replies; 4+ messages in thread
From: Stefan Kangas @ 2021-04-21 13:41 UTC (permalink / raw)
  To: Philip Kaludercic; +Cc: 47877

tags 47877 fixed
close 47877 28.1
thanks

Philip Kaludercic <philipk@posteo.net> writes:

> Stefan Kangas <stefan@marxist.se> writes:
>
>> Philip Kaludercic <philipk@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.





^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-04-21 13:41 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-18 18:56 bug#47877: [PATCH] Respect sgml-xml-mode Philip Kaludercic
2021-04-20 23:45 ` Stefan Kangas
2021-04-21  7:27   ` Philip Kaludercic
2021-04-21 13:41     ` Stefan Kangas

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).