Enhance CC Mode's fontification, etc., of unterminated strings.
commitbb591f139f0602af292c772f974dcc14dabb1deb
authorAlan Mackenzie <acm@muc.de>
Sun, 20 May 2018 13:28:14 +0000 (20 13:28 +0000)
committerAlan Mackenzie <acm@muc.de>
Sun, 20 May 2018 13:28:14 +0000 (20 13:28 +0000)
treef0c0c0a8d534a30cc841ea82d72a17a211f1f88d
parente2f68c144f83b4634096b8180ee9d5d56329a01d
Enhance CC Mode's fontification, etc., of unterminated strings.

String delimiters, including escaped new lines, of correctly terminated
strings are left in font-lock-string-face.  All others get
font-lock-warning-face.  The latter get syntax-table text properties on the
opening string delim and the "terminating EOL".

Correct two miscellaneous bugs: the handling of text properties on Java Mode's
generic delimiters; the handling of c-just-done-before-change.

* lisp/progmodes/cc-defs.el (c-point): New position 'eoll "end of logical line".
(c-characterp): New macro.

* lisp/progmodes/cc-fonts.el (c-font-lock-invalid-string): Removed.
(c-basic-matchers-before): Use a simple matcher in place of the form around
c-font-lock-invalid-string.

* lisp/progmodes/cc-langs.el (c-get-state-before-change-functions): Add
c-before-change-check-unbalanced-strings to the value for all modes except AWK
Mode.  Also add c-before-change-check-<>-operators to Java Mode, correcting an
error in that mode's handling of generic delimiters.
(c-before-font-lock-functions): Add c-after-change-re-mark-unbalanced-strings
to the value for all modes except AWK Mode.
(c-single-quotes-quote-strings, c-string-delims): New lang variables for
future enhancements.
(c-string-innards-re-alist): New lang variable.

* lisp/progmodes/cc-mode.el (c-just-done-before-change): Do not set this
variable when a change is the alteration of text properties.
(c-basic-common-init): Set parse-sexp-lookup-properties (and the XEmacs
equivalent) also for Pike Mode.
(c-neutralize-CPP-line): No longer neutralize unbalanced quotes here.
(c-unescaped-nls-in-string-p, c-multiline-string-start-is-being-detached)
(c-pps-to-string-delim, c-before-change-check-unbalanced-strings)
(c-after-change-re-mark-unbalanced-strings): New functions.
(c-after-change): Fix a bug with the handling of c-just-done-before-change.
lisp/progmodes/cc-defs.el
lisp/progmodes/cc-fonts.el
lisp/progmodes/cc-langs.el
lisp/progmodes/cc-mode.el