diff options
| author | Alan Mackenzie | 2020-02-16 17:46:02 +0000 |
|---|---|---|
| committer | Alan Mackenzie | 2020-02-16 17:46:02 +0000 |
| commit | efc9d4fe3ef256e6c546c1690bf7dd968f1fdac8 (patch) | |
| tree | c43207269b2839327141a753ee17951dda3a3947 | |
| parent | 7ceb45f61f91d99c045966d8463c8ae30add8930 (diff) | |
| download | emacs-efc9d4fe3ef256e6c546c1690bf7dd968f1fdac8.tar.gz emacs-efc9d4fe3ef256e6c546c1690bf7dd968f1fdac8.zip | |
Amend c-backward-sws better to handle multiline block comments
In particular, multiline comments lacking escaped newlines.
* lisp/progmodes/cc-engine.el (c-backward-sws): Whilst searching backward for
a putative beginning of macro, move back over block comments whose innards
lack escaped newlines.
| -rw-r--r-- | lisp/progmodes/cc-engine.el | 35 |
1 files changed, 27 insertions, 8 deletions
diff --git a/lisp/progmodes/cc-engine.el b/lisp/progmodes/cc-engine.el index 0964c04b899..0c338fa3868 100644 --- a/lisp/progmodes/cc-engine.el +++ b/lisp/progmodes/cc-engine.el | |||
| @@ -327,6 +327,8 @@ comment at the start of cc-engine.el for more info." | |||
| 327 | (when (or (null lim) | 327 | (when (or (null lim) |
| 328 | (>= here lim)) | 328 | (>= here lim)) |
| 329 | (save-match-data | 329 | (save-match-data |
| 330 | ;; Note the similarity of the code here to some in | ||
| 331 | ;; `c-backward-sws'. | ||
| 330 | (while | 332 | (while |
| 331 | (progn | 333 | (progn |
| 332 | (while (eq (char-before (1- (point))) ?\\) | 334 | (while (eq (char-before (1- (point))) ?\\) |
| @@ -2461,17 +2463,34 @@ comment at the start of cc-engine.el for more info." | |||
| 2461 | (/= cmt-skip-pos simple-ws-beg) | 2463 | (/= cmt-skip-pos simple-ws-beg) |
| 2462 | (c-beginning-of-macro)) | 2464 | (c-beginning-of-macro)) |
| 2463 | ;; Inside a cpp directive. See if it should be skipped over. | 2465 | ;; Inside a cpp directive. See if it should be skipped over. |
| 2464 | (let ((cpp-beg (point))) | 2466 | (let ((cpp-beg (point)) |
| 2467 | pause pos) | ||
| 2465 | 2468 | ||
| 2466 | ;; Move back over all line continuations in the region skipped | 2469 | ;; Move back over all line continuations and block comments in |
| 2467 | ;; over by `c-backward-comments'. If we go past it then we | 2470 | ;; the region skipped over by `c-backward-comments'. If we go |
| 2468 | ;; started inside the cpp directive. | 2471 | ;; past it then we started inside the cpp directive. |
| 2469 | (goto-char simple-ws-beg) | 2472 | (goto-char simple-ws-beg) |
| 2470 | (beginning-of-line) | 2473 | (beginning-of-line) |
| 2471 | (while (and (> (point) cmt-skip-pos) | 2474 | ;; Note the similarity of the code here to some in |
| 2472 | (progn (backward-char) | 2475 | ;; `c-beginning-of-macro'. |
| 2473 | (eq (char-before) ?\\))) | 2476 | (setq pause (point)) |
| 2474 | (beginning-of-line)) | 2477 | (while |
| 2478 | (progn | ||
| 2479 | (while (and (> (point) cmt-skip-pos) | ||
| 2480 | (progn (backward-char) | ||
| 2481 | (eq (char-before) ?\\))) | ||
| 2482 | (beginning-of-line)) | ||
| 2483 | (setq pos (point)) | ||
| 2484 | (when (and c-last-c-comment-end-on-line-re | ||
| 2485 | (re-search-forward | ||
| 2486 | c-last-c-comment-end-on-line-re pause t)) | ||
| 2487 | (goto-char (match-end 1)) | ||
| 2488 | (if (c-backward-single-comment) | ||
| 2489 | (progn | ||
| 2490 | (beginning-of-line) | ||
| 2491 | (setq pause (point))) | ||
| 2492 | (goto-char pos) | ||
| 2493 | nil)))) | ||
| 2475 | 2494 | ||
| 2476 | (if (< (point) cmt-skip-pos) | 2495 | (if (< (point) cmt-skip-pos) |
| 2477 | ;; Don't move past the cpp directive if we began inside | 2496 | ;; Don't move past the cpp directive if we began inside |