diff options
author | Alan Mackenzie <acm@muc.de> | 2015-12-28 16:01:05 +0000 |
---|---|---|
committer | Alan Mackenzie <acm@muc.de> | 2015-12-28 16:01:05 +0000 |
commit | 326ffcce5fbbb0ca368cfa08a33101dbbcaa2ace (patch) | |
tree | 1b86615b5bed5089446aa9c5a8ae0619703aa3b0 /src | |
parent | 17ab0d10e1db9cc4924ceb778e5c4e6bb9a90c3d (diff) | |
download | emacs-326ffcce5fbbb0ca368cfa08a33101dbbcaa2ace.tar.gz |
Allow line comments ending with escaped NL to be continued to the next line.
Use this in C, C++, and Objective C Modes. Fixes bug#22246
* src/syntax.c (comment-end-can-be-escaped): New buffer local variable.
(forw-comment, back-comment): On encountering an end of comment character,
test whether it is escaped when `comment-end-can-be-escaped' is non-nil.
* doc/lispref/syntax.texi (Control Parsing): Describe
`comment-end-can-be-escaped'.
* etc/NEWS (Lisp Changes): Describe `comment-end-can-be-escaped'.
* lisp/progmodes/cc-langs.el: New c-lang-setvar `comment-end-can-be-escaped'.
Diffstat (limited to 'src')
-rw-r--r-- | src/syntax.c | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/src/syntax.c b/src/syntax.c index 5b0ec6d071b..2acbd413858 100644 --- a/src/syntax.c +++ b/src/syntax.c @@ -790,8 +790,10 @@ back_comment (ptrdiff_t from, ptrdiff_t from_byte, ptrdiff_t stop, || SYNTAX_FLAGS_COMMENT_NESTED (syntax) != comnested)) continue; - /* Ignore escaped characters, except comment-enders. */ - if (code != Sendcomment && char_quoted (from, from_byte)) + /* Ignore escaped characters, except comment-enders which cannot + be escaped. */ + if ((Vcomment_end_can_be_escaped || code != Sendcomment) + && char_quoted (from, from_byte)) continue; switch (code) @@ -2346,7 +2348,8 @@ forw_comment (ptrdiff_t from, ptrdiff_t from_byte, ptrdiff_t stop, if (code == Sendcomment && SYNTAX_FLAGS_COMMENT_STYLE (syntax, 0) == style && (SYNTAX_FLAGS_COMMENT_NESTED (syntax) ? - (nesting > 0 && --nesting == 0) : nesting < 0)) + (nesting > 0 && --nesting == 0) : nesting < 0) + && !(Vcomment_end_can_be_escaped && char_quoted (from, from_byte))) /* We have encountered a comment end of the same style as the comment sequence which began this comment section. */ @@ -3702,6 +3705,12 @@ character of that word. In both cases, LIMIT bounds the search. */); Vfind_word_boundary_function_table = Fmake_char_table (Qnil, Qnil); + DEFVAR_BOOL ("comment-end-can-be-escaped", Vcomment_end_can_be_escaped, + doc: /* Non-nil means an escaped ender inside a comment doesn'tend the comment. */); + Vcomment_end_can_be_escaped = 0; + DEFSYM (Qcomment_end_can_be_escaped, "comment-end-can-be-escaped"); + Fmake_variable_buffer_local (Qcomment_end_can_be_escaped); + defsubr (&Ssyntax_table_p); defsubr (&Ssyntax_table); defsubr (&Sstandard_syntax_table); |