GNU bug report logs - #43941
HTML+ mode: dangerous apostrophe after fullwidth parenthesis

Previous Next

Package: emacs;

Reported by: 積丹尼 Dan Jacobson <jidanni <at> jidanni.org>

Date: Mon, 12 Oct 2020 05:12:01 UTC

Severity: minor

Tags: confirmed, patch

Merged with 40844, 46312

Found in versions 26.3, 27.0.91

Fixed in version 28.1

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

Full log


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

From: Stephen Berman <stephen.berman <at> gmx.net>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 43941 <at> debbugs.gnu.org, jidanni <at> jidanni.org
Subject: Re: bug#43941: HTML+ mode: dangerous apostrophe after fullwidth
 parenthesis
Date: Tue, 13 Oct 2020 12:37:32 +0200
[Message part 1 (text/plain, inline)]
On Mon, 12 Oct 2020 23:26:15 +0200 Stephen Berman <stephen.berman <at> gmx.net> wrote:

> On Mon, 12 Oct 2020 20:38:15 +0300 Eli Zaretskii <eliz <at> gnu.org> wrote:
>
[...]
>> 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:
[...]
> But this fails to prevent the unwanted string face fontification.

I made a silly mistake (it was late and I was tired).  Here is a
corrected version:

[Message part 2 (text/x-patch, inline)]
diff --git a/lisp/textmodes/sgml-mode.el b/lisp/textmodes/sgml-mode.el
index f3d8695e24..26ca536004 100644
--- a/lisp/textmodes/sgml-mode.el
+++ b/lisp/textmodes/sgml-mode.el
@@ -192,8 +192,19 @@ 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)
+    (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))
+    (setq brackets (delete-dups (flatten-tree brackets)))
+    (dolist (char (append brackets (list ?$ ?% ?& ?* ?+ ?/)))
       (modify-syntax-entry char "." table))
     (unless (memq ?' sgml-specials)
       ;; Avoid that skipping a tag backwards skips any "'" prefixing it.
[Message part 3 (text/plain, inline)]
With this patch, when any of the paired-bracket characters is followed
by `'' in html-mode, there is indeed no string face fontification on the
latter (and following characters).  The following function demonstrates
this:

(defun sgml-test-brackets ()
  "Test fontification of apostrophe preceded by paired-bracket character."
  (interactive)
  (let ((buf (get-buffer-create "*sgml-test*"))
	brackets results)
    (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))
    (setq brackets (delete-dups (flatten-tree brackets)))
    (setq brackets (append brackets (list ?$ ?% ?& ?* ?+ ?/)))
    (while brackets
      (let ((char (string (pop brackets)))
	    (face "default"))
	(with-current-buffer buf
	  ;; (erase-buffer)
	  (fundamental-mode)
	  (insert (concat "<p>" char "'s</p>\n"))
	  (html-mode)
	  ;; (let ((val (get-text-property 5 'face)))
	  ;;   (when val (setq face (symbol-name val))))
	  ;; (push (concat char " : " face "\n") results)
	  )))
    ;; (with-current-buffer buf
    ;;   (newline)
    ;;   (while results
    ;; 	(insert (pop results))))
    (switch-to-buffer buf)))

I wanted to turn this function into a test, and that's what the
commented out lines are supposed to do.  But when I uncomment these
lines and call this function with the unpatched (i.e. current) version
of sgml-mode-syntax-table, it still shows default face for `'' with all
the paired-bracket characters.  Yet when I step through the function
with Ediff, I do see some cases with font-lock-string-face.  I don't
understand what's going on here.

Steve Berman

This bug report was last modified 4 years and 36 days ago.

Previous Next


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