all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#13844: [PATCH] Fix html-mode quotes syntax in text
@ 2013-03-01  1:01 Dale
  2013-03-01  3:44 ` Stefan Monnier
  0 siblings, 1 reply; 3+ messages in thread
From: Dale @ 2013-03-01  1:01 UTC (permalink / raw
  To: 13844

Hi,

	I noticed Emacs was colorizing the following sample wrong in
html-mode:

~~~~~~
<pre>
" Dangling quote makes the closing tag get highlighted as a string
</pre>
" Highlighting now fixed: <hr />

Additionally, if you have apostrophe in sgml-specials, this more common
usage will break:

Dave's bar
Now this tag will have incorrect highlighting:
<br />
~~~~~~

	I believe I've tracked this down to two problems:

1. sgml-syntax-propertize-function is already prepared to correctly set
the syntax on " (double quotes) within text, but returns "." for the
syntax-table property value.  That's not a valid value for syntax-table
propertize.  It needs to use (string-to-syntax ".").

2. sgml-syntax-propertize-function doesn't account for the fact that you
could have set ' (apostrophe) in sgml-specials, which causes apostrophe
to be set as string syntax in the syntax table, just like " is by
default.

	The patch below hopefully fixes both problems.

	I believe I have filed my copyright assignment with the FSF for
Emacs already.

	ChangeLog entry:

~~~~~~
2013-02-28  Dale Sedivec <dale@codefu.org>

	* textmodes/sgml-mode.el (sgml-syntax-propertize-function):
	Return valid syntax-table property value when converting
	quotes within text from string syntax to punctuation syntax.
	Also perform this adjustment when apostrophe (?') is in
	sgml-specials.
~~~~~~

	Patch against Git master follows.

Dale


*** /var/folders/l1/l_tpw26n35zbm0fp4x22_vjh0000kk/T//85VjC0_sgml-mode.el	2013-02-28 19:00:02.000000000 -0600
--- lisp/textmodes/sgml-mode.el	2013-02-28 18:54:52.000000000 -0600
***************
*** 312,328 ****
  
  (defconst sgml-syntax-propertize-function
    (syntax-propertize-rules
!   ;; Use the `b' style of comments to avoid interference with the -- ... --
!   ;; comments recognized when `sgml-specials' includes ?-.
!   ;; FIXME: beware of <!--> blabla <!--> !!
     ("\\(<\\)!--" (1 "< b"))
!     ("--[ \t\n]*\\(>\\)" (1 "> b"))
!     ;; Double quotes outside of tags should not introduce strings.
!     ;; Be careful to call `syntax-ppss' on a position before the one we're
!     ;; going to change, so as not to need to flush the data we just computed.
!     ("\"" (0 (if (prog1 (zerop (car (syntax-ppss (match-beginning 0))))
!                    (goto-char (match-end 0)))
!                  "."))))
    "Syntactic keywords for `sgml-mode'.")
  
  ;; internal
--- 312,335 ----
  
  (defconst sgml-syntax-propertize-function
    (syntax-propertize-rules
!    ;; Use the `b' style of comments to avoid interference with the -- ... --
!    ;; comments recognized when `sgml-specials' includes ?-.
!    ;; FIXME: beware of <!--> blabla <!--> !!
     ("\\(<\\)!--" (1 "< b"))
!    ("--[ \t\n]*\\(>\\)" (1 "> b"))
!    ;; Quotes (single or double) outside of tags should not introduce
!    ;; strings.  Be careful to call `syntax-ppss' on a position before
!    ;; the one we're going to change, so as not to need to flush the
!    ;; data we just computed.
!    ((let (string-delimiters)
!       (when (memq ?\" sgml-specials)
!         (setq string-delimiters (cons ?\" string-delimiters)))
!       (when (memq ?' sgml-specials)
!         (setq string-delimiters (cons ?' string-delimiters)))
!       (regexp-opt-charset string-delimiters))
!     (0 (if (prog1 (zerop (car (syntax-ppss (match-beginning 0))))
!              (goto-char (match-end 0)))
!            (string-to-syntax ".")))))
    "Syntactic keywords for `sgml-mode'.")
  
  ;; internal





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

* bug#13844: [PATCH] Fix html-mode quotes syntax in text
  2013-03-01  1:01 bug#13844: [PATCH] Fix html-mode quotes syntax in text Dale
@ 2013-03-01  3:44 ` Stefan Monnier
  2016-02-24  5:43   ` Lars Ingebrigtsen
  0 siblings, 1 reply; 3+ messages in thread
From: Stefan Monnier @ 2013-03-01  3:44 UTC (permalink / raw
  To: Dale; +Cc: 13844

> 	The patch below hopefully fixes both problems.
> 	I believe I have filed my copyright assignment with the FSF for
> Emacs already.

Thanks.  I installed the first part, but the second breaks compilation
(because the regexp is computed during compilation, at which point
sgml-specials is not yet defined).


        Stefan





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

* bug#13844: [PATCH] Fix html-mode quotes syntax in text
  2013-03-01  3:44 ` Stefan Monnier
@ 2016-02-24  5:43   ` Lars Ingebrigtsen
  0 siblings, 0 replies; 3+ messages in thread
From: Lars Ingebrigtsen @ 2016-02-24  5:43 UTC (permalink / raw
  To: Stefan Monnier; +Cc: Dale, 13844

Stefan Monnier <monnier@iro.umontreal.ca> writes:

>> 	The patch below hopefully fixes both problems.
>> 	I believe I have filed my copyright assignment with the FSF for
>> Emacs already.
>
> Thanks.  I installed the first part, but the second breaks compilation
> (because the regexp is computed during compilation, at which point
> sgml-specials is not yet defined).


---
Additionally, if you have apostrophe in sgml-specials, this more common
usage will break:

Dave's bar
Now this tag will have incorrect highlighting:
<br />
---

This is now done correctly in the Emacs trunk, apparently, so I'm
closing this bug report.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





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

end of thread, other threads:[~2016-02-24  5:43 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-03-01  1:01 bug#13844: [PATCH] Fix html-mode quotes syntax in text Dale
2013-03-01  3:44 ` Stefan Monnier
2016-02-24  5:43   ` Lars Ingebrigtsen

Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.