From: Stephen Berman <stephen.berman@gmx.net>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 43941@debbugs.gnu.org, jidanni@jidanni.org
Subject: bug#43941: HTML+ mode: dangerous apostrophe after fullwidth parenthesis
Date: Tue, 13 Oct 2020 12:37:32 +0200 [thread overview]
Message-ID: <87sgai76oj.fsf@gmx.net> (raw)
In-Reply-To: <878scbyw3s.fsf@rub.de> (Stephen Berman's message of "Mon, 12 Oct 2020 23:26:15 +0200")
[-- Attachment #1: Type: text/plain, Size: 570 bytes --]
On Mon, 12 Oct 2020 23:26:15 +0200 Stephen Berman <stephen.berman@gmx.net> wrote:
> On Mon, 12 Oct 2020 20:38:15 +0300 Eli Zaretskii <eliz@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:
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: sgml-mode-syntax-table patch --]
[-- Type: text/x-patch, Size: 1061 bytes --]
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.
[-- Attachment #3: Type: text/plain, Size: 1738 bytes --]
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
next prev parent reply other threads:[~2020-10-13 10:37 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-11 14:30 bug#43941: HTML+ mode: dangerous apostrophe after fullwidth parenthesis 積丹尼 Dan Jacobson
2020-10-12 14:48 ` Eli Zaretskii
2020-10-12 14:52 ` 積丹尼 Dan Jacobson
2020-10-12 15:11 ` Stephen Berman
2020-10-12 15:20 ` Eli Zaretskii
2020-10-12 16:17 ` Stephen Berman
2020-10-12 16:29 ` Eli Zaretskii
2020-10-12 17:21 ` Stephen Berman
2020-10-12 17:38 ` Eli Zaretskii
2020-10-12 21:26 ` Stephen Berman
2020-10-13 10:37 ` Stephen Berman [this message]
2021-06-13 12:21 ` bug#43941: bug#40844: html mode sometimes fooled by apostrophe Lars Ingebrigtsen
2021-06-13 18:14 ` Stephen Berman
2021-06-14 13:00 ` bug#43941: bug#46312: HTML+ mode vs. quotes Lars Ingebrigtsen
2021-06-14 13:02 ` bug#40844: " Eli Zaretskii
2021-06-14 13:52 ` Stephen Berman
2021-06-14 13:58 ` bug#43941: " Lars Ingebrigtsen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87sgai76oj.fsf@gmx.net \
--to=stephen.berman@gmx.net \
--cc=43941@debbugs.gnu.org \
--cc=eliz@gnu.org \
--cc=jidanni@jidanni.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).