Subject: Re: bug#43941: HTML+ mode: dangerous apostrophe after fullwidth parenthesis

From: Stephen Berman <[email-masked]>
Date: Mon, 12 Oct 2020 23:26:15 +0200

On Mon, 12 Oct 2020 20:38:15 +0300 Eli Zaretskii <[email-masked]> wrote:

>> From: Stephen Berman <[email-masked]>
>> Cc: Stephen Berman <[email-masked]>,  [email-masked],
>>   [email-masked]
>> Date: Mon, 12 Oct 2020 19:21:08 +0200
>> 
>> diff --git a/lisp/textmodes/sgml-mode.el b/lisp/textmodes/sgml-mode.el
>> index f3d8695e24..92a2215ed7 100644
>> --- a/lisp/textmodes/sgml-mode.el
>> +++ b/lisp/textmodes/sgml-mode.el
>> @@ -193,7 +193,7 @@ sgml-mode-syntax-table
>>  
>>  (defconst sgml-tag-syntax-table
>>    (let ((table (sgml-make-syntax-table sgml-specials)))
>> -    (dolist (char '(?\( ?\) ?\{ ?\} ?\[ ?\] ?$ ?% ?& ?* ?+ ?/))
>> +    (dolist (char '(?\( ?\) ?\{ ?\} ?\[ ?\] ?$ ?% ?& ?* ?+ ?/ ?（))
>>        (modify-syntax-entry char "." table))
>>      (unless (memq ?' sgml-specials)
>>        ;; Avoid that skipping a tag backwards skips any "'" prefixing it.
>> 
>> If this is the right approach, then all such characters would have to be
>> added, or is there a better alternative?
>
> It shouldn't be hard to add to the list some of the characters that
> have the paired bracket semantics, see uni-brackets.el.

Some, but which?  I used the following the code to add all the
paired-bracket characters listed in that file:

diff --git a/lisp/textmodes/sgml-mode.el b/lisp/textmodes/sgml-mode.el
index f3d8695e24..c2c3f61e3d 100644
--- a/lisp/textmodes/sgml-mode.el
+++ b/lisp/textmodes/sgml-mode.el
@@ -192,8 +192,20 @@ sgml-mode-syntax-table
   "Syntax table used in SGML mode.  See also `sgml-specials'.")

 (defconst sgml-tag-syntax-table
-  (let ((table (sgml-make-syntax-table sgml-specials)))
-    (dolist (char '(?\( ?\) ?\{ ?\} ?\[ ?\] ?$ ?% ?& ?* ?+ ?/))
+  (let ((table (sgml-make-syntax-table sgml-specials))
+	brackets)
+    (setq brackets (delete-dups
+		    (flatten-tree
+		     (map-char-table
+		      (lambda (key value)
+			(setq brackets (cons (list
+				              (if (consp key)
+					          (list (car key) (cdr key))
+				                key)
+				              value)
+				             brackets)))
+		      (unicode-property-table-internal 'paired-bracket)))))
+    (dolist (char (append brackets (list ?$ ?% ?& ?* ?+ ?/)))
       (modify-syntax-entry char "." table))
     (unless (memq ?' sgml-specials)
       ;; Avoid that skipping a tag backwards skips any "'" prefixing it.

But this fails to prevent the unwanted string face fontification.
According to the above code, there are 120 different paired-bracket
characters, so it will be time-consuming to isolate just the ones that
work.

>                                                          But some
> SGML/HTML expert should say if that is TRT, indeed.

Yes, hopefully before Someone™ toils through the 120 characters.

Steve Berman