diff options
author | Glenn Morris <rgm@gnu.org> | 2020-02-16 07:50:36 -0800 |
---|---|---|
committer | Glenn Morris <rgm@gnu.org> | 2020-02-16 07:50:36 -0800 |
commit | f633e014aca727b9ccecaf8e6d69386f93c5073f (patch) | |
tree | 8db3ca5c8726fe382033559ec6a3bdf2cf28b74a /lisp/progmodes/cc-engine.el | |
parent | 3480071dfab30eaca7f1d014600b864d2ea22f62 (diff) | |
parent | 7ceb45f61f91d99c045966d8463c8ae30add8930 (diff) | |
download | emacs-f633e014aca727b9ccecaf8e6d69386f93c5073f.tar.gz |
Merge from origin/emacs-27
7ceb45f61f (origin/emacs-27) Reformulate c-end-of-macro, handling mul...
888ffd960c Fix unexec failure on macOS 10.15.4
b392c9f365 Fix 'reverse-region' when less than one line is in region
7448834f73 Correct default regexp in 'package-menu-hide-package'
faada7ca42 Remove obsolete menu entry "Redisplay buffer"
78d76cd93c Remove redundant 'msft' compilation error rule (bug#39595)
75a9eee8b8 ; * src/editfns.c (Fbuffer_size): Tiny clarification.
4d8d25d641 * doc/lispref/variables.texi (special-variable-p): Clarify...
9f6a4bbcc9 Remove the optional KEEP-ORDER argument to regexp-opt
d1e8ce8bb6 Make after-change-functions called from call-process get t...
# Conflicts:
# etc/NEWS
Diffstat (limited to 'lisp/progmodes/cc-engine.el')
-rw-r--r-- | lisp/progmodes/cc-engine.el | 58 |
1 files changed, 28 insertions, 30 deletions
diff --git a/lisp/progmodes/cc-engine.el b/lisp/progmodes/cc-engine.el index 23fb1effdd4..0964c04b899 100644 --- a/lisp/progmodes/cc-engine.el +++ b/lisp/progmodes/cc-engine.el @@ -358,7 +358,8 @@ comment at the start of cc-engine.el for more info." "Go to the end of a preprocessor directive. More accurately, move the point to the end of the closest following line that doesn't end with a line continuation backslash - no check is -done that the point is inside a cpp directive to begin with. +done that the point is inside a cpp directive to begin with, although +it is assumed that point isn't inside a comment or string. If LIM is provided, it is a limit position at which point is left if the end of the macro doesn't occur earlier. @@ -379,35 +380,32 @@ comment at the start of cc-engine.el for more info." c-macro-cache-syntactic nil c-macro-cache-no-comment nil)) (save-match-data - (while - (progn - (while (progn - (end-of-line) - (when (and (eq (char-before) ?\\) - (not (eobp))) - (forward-char) - t))) - (let ((cand-EOM (point))) - (if (and c-open-c-comment-on-logical-line-re - (re-search-backward - 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) - (> (point) (car c-macro-cache)) ; in case we have a - ; zero-sized region. - (bolp) - (not (eq (char-before (1- (point))) ?\\))) - (setcdr c-macro-cache (point)) - (setq c-macro-cache-syntactic nil))))) + (let ((safe-pos (point))) ; a point ouside any literal. + ;; Move over stuff followed by a multiline block comment lacking + ;; escaped newlines each time around this loop. + (while + (progn + (while (progn + (end-of-line) + (when (and (eq (char-before) ?\\) + (not (eobp))) + (forward-char) + t))) + (let ((s (parse-partial-sexp safe-pos (point)))) + (when ;; Are we in a block comment? + (and (nth 4 s) (not (nth 7 s))) + (progn + ;; Move to after the block comment. + (parse-partial-sexp + (point) (point-max) nil nil s 'syntax-table) + (setq safe-pos (point))))))) + + (when (and (car c-macro-cache) + (> (point) (car c-macro-cache)) ; in case we have a + ; zero-sized region. + (not (eq (char-before (1- (point))) ?\\))) + (setcdr c-macro-cache (point)) + (setq c-macro-cache-syntactic nil))))))) (defun c-syntactic-end-of-macro () ;; Go to the end of a CPP directive, or a "safe" pos just before. |