unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#66660: [PATCH] Fix dns-mode-syntax-table
@ 2023-10-20 16:21 Lassi Kortela
  2023-10-21  9:15 ` Stefan Kangas
  0 siblings, 1 reply; 8+ messages in thread
From: Lassi Kortela @ 2023-10-20 16:21 UTC (permalink / raw)
  To: 66660

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

Attached is a simple fix to the syntax highlighting of dns-mode.

The patch highlights double-quoted strings as specified in RFC 1035.	

[-- Attachment #2: dns-mode-syntax-table.patch --]
[-- Type: text/plain, Size: 407 bytes --]

--- dns-mode.el.orig	2023-10-20 19:12:43.000000000 +0300
+++ dns-mode.el	2023-10-20 19:13:01.000000000 +0300
@@ -137,6 +137,8 @@
   (let ((table (make-syntax-table)))
     (modify-syntax-entry ?\; "<   " table)
     (modify-syntax-entry ?\n ">   " table)
+    (modify-syntax-entry ?\" "\"" table)
+    (modify-syntax-entry ?\\ "\\" table)
     table)
   "Syntax table in use in DNS master file buffers.")
 

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

* bug#66660: [PATCH] Fix dns-mode-syntax-table
  2023-10-20 16:21 bug#66660: [PATCH] Fix dns-mode-syntax-table Lassi Kortela
@ 2023-10-21  9:15 ` Stefan Kangas
  2023-10-21  9:31   ` Lassi Kortela
  0 siblings, 1 reply; 8+ messages in thread
From: Stefan Kangas @ 2023-10-21  9:15 UTC (permalink / raw)
  To: Lassi Kortela, 66660

Lassi Kortela <lassi@lassi.io> writes:

> Attached is a simple fix to the syntax highlighting of dns-mode.
>
> The patch highlights double-quoted strings as specified in RFC 1035.	

Thanks for the patch.

Could you provide an example of something which is incorrectly
highlighted, briefly explain what is wrong before your patch, and what
your patch does?  Thanks again.

> --- dns-mode.el.orig	2023-10-20 19:12:43.000000000 +0300
> +++ dns-mode.el	2023-10-20 19:13:01.000000000 +0300
> @@ -137,6 +137,8 @@
>    (let ((table (make-syntax-table)))
>      (modify-syntax-entry ?\; "<   " table)
>      (modify-syntax-entry ?\n ">   " table)
> +    (modify-syntax-entry ?\" "\"" table)
> +    (modify-syntax-entry ?\\ "\\" table)
>      table)
>    "Syntax table in use in DNS master file buffers.")
>





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

* bug#66660: [PATCH] Fix dns-mode-syntax-table
  2023-10-21  9:15 ` Stefan Kangas
@ 2023-10-21  9:31   ` Lassi Kortela
  2023-10-21  9:41     ` Stefan Kangas
  0 siblings, 1 reply; 8+ messages in thread
From: Lassi Kortela @ 2023-10-21  9:31 UTC (permalink / raw)
  To: Stefan Kangas, 66660

> Could you provide an example of something which is incorrectly
> highlighted, briefly explain what is wrong before your patch, and what
> your patch does?  Thanks again.

Sure. Here is the DNS zone for the domain schemers.org:

https://raw.githubusercontent.com/schemeorg/schemeorg/master/dns/schemers.org.zone

On the following two lines, the text in double quotes was not
highlighted.

@ IN TXT "v=spf1 include:simplelists.com -all"

srfi IN TXT "v=spf1 include:simplelists.com -all"

On the following line, the part "k=rsa was not highlighted, and the
rest of the line ;p=MIGf[...]QAB" starting at the semicolon was
incorrectly highlighted as a comment instead of a string literal.

selector1._domainkey.srfi IN TXT "k=rsa;p=MIGf[...]QAB"

The patch causes the parts in double quotes to be highlighted as string 
literals. Since the part starting at the semicolon is inside a string, 
it is no longer incorrectly highlighted as a comment.

Motion commands such as forward-sexp are likewise fixed.





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

* bug#66660: [PATCH] Fix dns-mode-syntax-table
  2023-10-21  9:31   ` Lassi Kortela
@ 2023-10-21  9:41     ` Stefan Kangas
  2023-10-21  9:49       ` Lassi Kortela
  0 siblings, 1 reply; 8+ messages in thread
From: Stefan Kangas @ 2023-10-21  9:41 UTC (permalink / raw)
  To: Lassi Kortela, 66660

Lassi Kortela <lassi@lassi.io> writes:

> On the following two lines, the text in double quotes was not
> highlighted.
>
> @ IN TXT "v=spf1 include:simplelists.com -all"
>
> srfi IN TXT "v=spf1 include:simplelists.com -all"
>
> On the following line, the part "k=rsa was not highlighted, and the
> rest of the line ;p=MIGf[...]QAB" starting at the semicolon was
> incorrectly highlighted as a comment instead of a string literal.
>
> selector1._domainkey.srfi IN TXT "k=rsa;p=MIGf[...]QAB"
>
> The patch causes the parts in double quotes to be highlighted as string
> literals. Since the part starting at the semicolon is inside a string,
> it is no longer incorrectly highlighted as a comment.
>
> Motion commands such as forward-sexp are likewise fixed.

Thanks, this seems to have already been fixed on master:

    commit c586d984f279aa61de4f5dfc4f6df660188dd0f6
    Author: Stefan Kangas <stefankangas@gmail.com>
    Date:   Tue Sep 5 23:06:21 2023 +0200

        Make `dns-mode` fontify quoted values correctly

        * lisp/textmodes/dns-mode.el (dns-mode-syntax-table): Fontify
        quoted values correctly.  (Bug#62214)
        Suggested by Trent W. Buck <trentbuck@gmail.com>.

However, the patch on master only has:

+    (modify-syntax-entry ?\" "\""   table)

But your patch has this:

+    (modify-syntax-entry ?\" "\"" table)
+    (modify-syntax-entry ?\\ "\\" table)

Do we need the second line there, too?  If yes, why?

Perhaps this fix should be cherry-picked to emacs-29, as well.

Thanks.





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

* bug#66660: [PATCH] Fix dns-mode-syntax-table
  2023-10-21  9:41     ` Stefan Kangas
@ 2023-10-21  9:49       ` Lassi Kortela
  2023-10-21  9:58         ` Stefan Kangas
  0 siblings, 1 reply; 8+ messages in thread
From: Lassi Kortela @ 2023-10-21  9:49 UTC (permalink / raw)
  To: Stefan Kangas, 66660

> Thanks, this seems to have already been fixed on master:

Indeed. My apologies. I did not realize that.

> However, the patch on master only has:
> 
> +    (modify-syntax-entry ?\" "\""   table)
> 
> But your patch has this:
> 
> +    (modify-syntax-entry ?\" "\"" table)
> +    (modify-syntax-entry ?\\ "\\" table)
> 
> Do we need the second line there, too?  If yes, why?

Quoting from <https://datatracker.ietf.org/doc/html/rfc1035>:

<character-string> is expressed in one or two ways: as a contiguous set
of characters without interior spaces, or as a string beginning with a "
and ending with a ".  Inside a " delimited string any character can
occur, except for a " itself, which must be quoted using \ (back slash).





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

* bug#66660: [PATCH] Fix dns-mode-syntax-table
  2023-10-21  9:49       ` Lassi Kortela
@ 2023-10-21  9:58         ` Stefan Kangas
  2023-10-21 10:15           ` Lassi Kortela
  0 siblings, 1 reply; 8+ messages in thread
From: Stefan Kangas @ 2023-10-21  9:58 UTC (permalink / raw)
  To: Lassi Kortela, 66660

Lassi Kortela <lassi@lassi.io> writes:

> Quoting from <https://datatracker.ietf.org/doc/html/rfc1035>:
>
> <character-string> is expressed in one or two ways: as a contiguous set
> of characters without interior spaces, or as a string beginning with a "
> and ending with a ".  Inside a " delimited string any character can
> occur, except for a " itself, which must be quoted using \ (back slash).

Thanks, so I would like to install this patch.

Could you please send the patch as an attachment formatted by this
command:

    git format-patch -1

That would save me time when installing the patch, and its easier to
make sure I don't make any mistakes with attributing the change to you.

Please also add the bug number of this bug in the commit message, like
so: Bug#66660.

Thanks in advance.





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

* bug#66660: [PATCH] Fix dns-mode-syntax-table
  2023-10-21  9:58         ` Stefan Kangas
@ 2023-10-21 10:15           ` Lassi Kortela
  2023-10-21 10:30             ` Stefan Kangas
  0 siblings, 1 reply; 8+ messages in thread
From: Lassi Kortela @ 2023-10-21 10:15 UTC (permalink / raw)
  To: Stefan Kangas, 66660

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

> Could you please send the patch as an attachment formatted by this
> command:
> 
>      git format-patch -1
> 
> That would save me time when installing the patch, and its easier to
> make sure I don't make any mistakes with attributing the change to you.
> 
> Please also add the bug number of this bug in the commit message, like
> so: Bug#66660.

Attached. Thank you.

[-- Attachment #2: 0001-Recognize-backslash-in-dns-mode-quoted-values.patch --]
[-- Type: text/plain, Size: 885 bytes --]

From b10ec2264ce293b2fde866b712e86be44683c5c9 Mon Sep 17 00:00:00 2001
From: Lassi Kortela <lassi@lassi.io>
Date: Sat, 21 Oct 2023 13:10:50 +0300
Subject: [PATCH] Recognize backslash in `dns-mode` quoted values

* lisp/textmodes/dns-mode.el (dns-mode-syntax-table): Recognize
backslash as an escape character.  (Bug#66660)
---
 lisp/textmodes/dns-mode.el | 1 +
 1 file changed, 1 insertion(+)

diff --git a/lisp/textmodes/dns-mode.el b/lisp/textmodes/dns-mode.el
index 1b5f0c1..bc3fa8d 100644
--- a/lisp/textmodes/dns-mode.el
+++ b/lisp/textmodes/dns-mode.el
@@ -132,6 +132,7 @@ manually with \\[dns-mode-soa-increment-serial]."
     (modify-syntax-entry ?\; "<   " table)
     (modify-syntax-entry ?\n ">   " table)
     (modify-syntax-entry ?\" "\""   table)
+    (modify-syntax-entry ?\\ "\\"   table)
     table)
   "Syntax table in use in DNS master file buffers.")
 
-- 
2.36.0


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

* bug#66660: [PATCH] Fix dns-mode-syntax-table
  2023-10-21 10:15           ` Lassi Kortela
@ 2023-10-21 10:30             ` Stefan Kangas
  0 siblings, 0 replies; 8+ messages in thread
From: Stefan Kangas @ 2023-10-21 10:30 UTC (permalink / raw)
  To: Lassi Kortela, 66660-done

Version: 30.1

Lassi Kortela <lassi@lassi.io> writes:

>> Could you please send the patch as an attachment formatted by this
>> command:
>>
>>      git format-patch -1
>>
>> That would save me time when installing the patch, and its easier to
>> make sure I don't make any mistakes with attributing the change to you.
>>
>> Please also add the bug number of this bug in the commit message, like
>> so: Bug#66660.
>
> Attached. Thank you.

Thanks, installed on master.

I will backport it to emacs-29 as well, unless anyone objects.

[1: e6f05e189db]: 2023-10-21 12:28:34 +0200
  Recognize backslash in `dns-mode` quoted values
  https://git.savannah.gnu.org/cgit/emacs.git/commit/?id=e6f05e189db73a0f0b29f987381ffef61a409232





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

end of thread, other threads:[~2023-10-21 10:30 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-10-20 16:21 bug#66660: [PATCH] Fix dns-mode-syntax-table Lassi Kortela
2023-10-21  9:15 ` Stefan Kangas
2023-10-21  9:31   ` Lassi Kortela
2023-10-21  9:41     ` Stefan Kangas
2023-10-21  9:49       ` Lassi Kortela
2023-10-21  9:58         ` Stefan Kangas
2023-10-21 10:15           ` Lassi Kortela
2023-10-21 10:30             ` 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).