[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
emacs-27 ad5e350: c-end-of-macro: Handle block coment lines with unescap
From: |
Alan Mackenzie |
Subject: |
emacs-27 ad5e350: c-end-of-macro: Handle block coment lines with unescaped NLs correctly |
Date: |
Mon, 10 Feb 2020 16:22:47 -0500 (EST) |
branch: emacs-27
commit ad5e350ab764f3a420d29f24ab3222f671b2e8c0
Author: Alan Mackenzie <address@hidden>
Commit: Alan Mackenzie <address@hidden>
c-end-of-macro: Handle block coment lines with unescaped NLs correctly
* lisp/progmodes/cc-langs.el (c-last-open-c-comment-start-on-line-re): Make
obsolete, and supersede by ...
(c-open-c-comment-on-logical-line-re): New language variable.
* lisp/progmodes/cc-engine.el (c-end-of-macro): Inside macros, handle
multiline block comments whose line ends are not escaped correctly.
---
lisp/progmodes/cc-engine.el | 17 ++++++++++-------
lisp/progmodes/cc-langs.el | 19 ++++++++++++++++++-
2 files changed, 28 insertions(+), 8 deletions(-)
diff --git a/lisp/progmodes/cc-engine.el b/lisp/progmodes/cc-engine.el
index c3cd31f..23fb1ef 100644
--- a/lisp/progmodes/cc-engine.el
+++ b/lisp/progmodes/cc-engine.el
@@ -388,14 +388,17 @@ comment at the start of cc-engine.el for more info."
(forward-char)
t)))
(let ((cand-EOM (point)))
- (if (and c-last-open-c-comment-start-on-line-re
+ (if (and c-open-c-comment-on-logical-line-re
(re-search-backward
- c-last-open-c-comment-start-on-line-re
- (c-point 'bol) t))
- (progn
- (goto-char (match-beginning 1))
- (and (c-forward-single-comment)
- (> (point) cand-EOM)))
+ c-open-c-comment-on-logical-line-re
+ nil t)
+ (match-beginning 1)
+ (progn
+ (goto-char (match-beginning 1))
+ (and (c-forward-single-comment)
+ (> (point) cand-EOM))))
+ t
+ (goto-char cand-EOM)
nil)))))
(when (and (car c-macro-cache)
diff --git a/lisp/progmodes/cc-langs.el b/lisp/progmodes/cc-langs.el
index 8d0ade7..6675617 100644
--- a/lisp/progmodes/cc-langs.el
+++ b/lisp/progmodes/cc-langs.el
@@ -1707,7 +1707,10 @@ ender."
(c-lang-const c-last-c-comment-end-on-line-re))
(c-lang-defconst c-last-open-c-comment-start-on-line-re
- "Regexp which matches the last block comment start on the
+ "Do NOT use this constant any more. Instead use
+`c-open-c-comment-on-logical-line-re' (2020-02-10).
+
+Regexp which matches the last block comment start on the
current ine, if any, or nil in those languages without block
comments. When a match is found, submatch 1 contains the comment
starter."
@@ -1715,6 +1718,20 @@ starter."
awk nil)
(c-lang-defvar c-last-open-c-comment-start-on-line-re
(c-lang-const c-last-open-c-comment-start-on-line-re))
+(make-obsolete-variable 'c-last-open-c-comment-start-on-line-re
+ 'c-open-c-comment-on-logical-line-re
+ "5.35")
+
+(c-lang-defconst c-open-c-comment-on-logical-line-re
+ "Regexp which matches an open block comment on the current logical line.
+It is intended for searching backwards from the end of a line.
+Such a search will stop at the first encountered non-escaped
+newline or open block comment. If the comment is found, submatch
+1 contains the comment starter."
+t "[^\\\n][\r\n]\\|\\(/\\*\\)\\([^*]\\|\\*+\\([^*/]\\|$\\)\\)*$"
+awk nil)
+(c-lang-defvar c-open-c-comment-on-logical-line-re
+ (c-lang-const c-open-c-comment-on-logical-line-re))
(c-lang-defconst c-literal-start-regexp
;; Regexp to match the start of comments and string literals.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- emacs-27 ad5e350: c-end-of-macro: Handle block coment lines with unescaped NLs correctly,
Alan Mackenzie <=