diff options
| author | Alan Mackenzie | 2019-04-20 11:30:55 +0000 |
|---|---|---|
| committer | Alan Mackenzie | 2019-04-20 11:30:55 +0000 |
| commit | a85befa4aa52033bd6d9927144b358529ec2b360 (patch) | |
| tree | 2c536fc9d7bd53809984e55b52efb945b8951f36 | |
| parent | 6f334b6bc0f0c343bbf34c3fee0848aadb5d1d84 (diff) | |
| download | emacs-a85befa4aa52033bd6d9927144b358529ec2b360.tar.gz emacs-a85befa4aa52033bd6d9927144b358529ec2b360.zip | |
Fix Pike Mode's autodoc doc comments style's continued lines.
* lisp/progmodes/cc-engine.el (c-forward-sws, c-backward-sws): Recognize
matches of c-doc-line-join-re as syntactic whitespace.
(c-find-decl-prefix-search): Recognize and move over matches of
c-doc-line-join-re as whitespace.
(c-find-decl-spots): Before moving backward a char, check (bobp). Before
moving forward over a comment, check it isn't possibly a "bright" comment.
* lisp/progmodes/cc-fonts.el (c-get-doc-comment-style): New function,
extracted from c-compose-keywords-list.
(c-compose-keywords-list): Call the above new function.
(pike-font-lock-keywords, pike-font-lock-keywords-2)
(pike-font-lock-keywords-3): Call c-set-doc-comment-res.
(c-doc-line-join-re, c-doc-bright-comment-start-re, c-doc-line-join-end-ch):
New variables.
(c-set-doc-comment-re-element, c-set-doc-comment-char-list): New macros.
(c-set-doc-comment-res): New function.
(c-font-lock-doc-comments): For consistency and repeatability, in a sequence
of C++ style doc comments, don't fontify the region between BOL and the
comment marker.
(autodoc-line-join-re, autodoc-bright-comment-start-re)
(autodoc-line-join-end-ch): New variables.
* lisp/progmodes/cc-mode.el (c-doc-fl-decl-start, c-doc-fl-decl-end): New
functions.
(c-change-expand-fl-region, c-context-expand-fl-region): Call the above two
new functions for extra possibilities for the start and end of a construct.
* doc/misc/cc-mode.texi (Doc Comments): Add a sentence drawing attention to
the possibility of fontifying constructs within a doc comment.
| -rw-r--r-- | doc/misc/cc-mode.texi | 5 | ||||
| -rw-r--r-- | lisp/progmodes/cc-engine.el | 56 | ||||
| -rw-r--r-- | lisp/progmodes/cc-fonts.el | 101 | ||||
| -rw-r--r-- | lisp/progmodes/cc-mode.el | 39 |
4 files changed, 177 insertions, 24 deletions
diff --git a/doc/misc/cc-mode.texi b/doc/misc/cc-mode.texi index f73a7fb57cb..6db2c96f2dc 100644 --- a/doc/misc/cc-mode.texi +++ b/doc/misc/cc-mode.texi | |||
| @@ -2140,7 +2140,10 @@ with @code{c-doc-comment-style}: Supply a variable or function | |||
| 2140 | in @code{c-doc-comment-style}. If it's a variable, it's prepended to | 2140 | in @code{c-doc-comment-style}. If it's a variable, it's prepended to |
| 2141 | @code{font-lock-keywords}. If it's a function, it's called at mode | 2141 | @code{font-lock-keywords}. If it's a function, it's called at mode |
| 2142 | initialization and the result is prepended. For an example, see | 2142 | initialization and the result is prepended. For an example, see |
| 2143 | @code{javadoc-font-lock-keywords} in @file{cc-fonts.el}. | 2143 | @code{javadoc-font-lock-keywords} in @file{cc-fonts.el}. It is even |
| 2144 | possible, to a limited extent, to fontify constructs inside a doc | ||
| 2145 | comment with other faces. For an example, see pike autodoc comment | ||
| 2146 | style towards the end of @file{cc-fonts-el}. | ||
| 2144 | 2147 | ||
| 2145 | If you add support for another doc comment style, please consider | 2148 | If you add support for another doc comment style, please consider |
| 2146 | contributing it: send a note to @email{bug-cc-mode@@gnu.org}. | 2149 | contributing it: send a note to @email{bug-cc-mode@@gnu.org}. |
diff --git a/lisp/progmodes/cc-engine.el b/lisp/progmodes/cc-engine.el index f0b44d2183d..80115fb3a35 100644 --- a/lisp/progmodes/cc-engine.el +++ b/lisp/progmodes/cc-engine.el | |||
| @@ -152,6 +152,10 @@ | |||
| 152 | (cc-require-when-compile 'cc-langs) | 152 | (cc-require-when-compile 'cc-langs) |
| 153 | (cc-require 'cc-vars) | 153 | (cc-require 'cc-vars) |
| 154 | 154 | ||
| 155 | (defvar c-doc-line-join-re) | ||
| 156 | (defvar c-doc-bright-comment-start-re) | ||
| 157 | (defvar c-doc-line-join-end-ch) | ||
| 158 | |||
| 155 | 159 | ||
| 156 | ;; Make declarations for all the `c-lang-defvar' variables in cc-langs. | 160 | ;; Make declarations for all the `c-lang-defvar' variables in cc-langs. |
| 157 | 161 | ||
| @@ -1930,7 +1934,8 @@ comment at the start of cc-engine.el for more info." | |||
| 1930 | (skip-chars-forward " \t\n\r\f\v") | 1934 | (skip-chars-forward " \t\n\r\f\v") |
| 1931 | (when (or (looking-at c-syntactic-ws-start) | 1935 | (when (or (looking-at c-syntactic-ws-start) |
| 1932 | (and c-opt-cpp-prefix | 1936 | (and c-opt-cpp-prefix |
| 1933 | (looking-at c-noise-macro-name-re))) | 1937 | (looking-at c-noise-macro-name-re)) |
| 1938 | (looking-at c-doc-line-join-re)) | ||
| 1934 | 1939 | ||
| 1935 | (setq rung-end-pos (min (1+ (point)) (point-max))) | 1940 | (setq rung-end-pos (min (1+ (point)) (point-max))) |
| 1936 | (if (setq rung-is-marked (text-property-any rung-pos rung-end-pos | 1941 | (if (setq rung-is-marked (text-property-any rung-pos rung-end-pos |
| @@ -2060,6 +2065,13 @@ comment at the start of cc-engine.el for more info." | |||
| 2060 | (looking-at c-noise-macro-name-re)) | 2065 | (looking-at c-noise-macro-name-re)) |
| 2061 | ;; Skip over a noise macro. | 2066 | ;; Skip over a noise macro. |
| 2062 | (goto-char (match-end 1)) | 2067 | (goto-char (match-end 1)) |
| 2068 | (not (eobp))) | ||
| 2069 | |||
| 2070 | ((looking-at c-doc-line-join-re) | ||
| 2071 | ;; Skip over a line join in (e.g.) Pike autodoc. | ||
| 2072 | (goto-char (match-end 0)) | ||
| 2073 | (setq safe-start nil) ; Never cache this; the doc style could be | ||
| 2074 | ; changed at any time. | ||
| 2063 | (not (eobp))))) | 2075 | (not (eobp))))) |
| 2064 | 2076 | ||
| 2065 | ;; We've searched over a piece of non-white syntactic ws. See if this | 2077 | ;; We've searched over a piece of non-white syntactic ws. See if this |
| @@ -2154,7 +2166,8 @@ comment at the start of cc-engine.el for more info." | |||
| 2154 | (let (;; `rung-pos' is set to a position as late as possible in the unmarked | 2166 | (let (;; `rung-pos' is set to a position as late as possible in the unmarked |
| 2155 | ;; part of the simple ws region. | 2167 | ;; part of the simple ws region. |
| 2156 | (rung-pos (point)) next-rung-pos last-put-in-sws-pos | 2168 | (rung-pos (point)) next-rung-pos last-put-in-sws-pos |
| 2157 | rung-is-marked simple-ws-beg cmt-skip-pos) | 2169 | rung-is-marked simple-ws-beg cmt-skip-pos |
| 2170 | (doc-line-join-here (concat c-doc-line-join-re "\\="))) | ||
| 2158 | 2171 | ||
| 2159 | ;; Skip simple horizontal ws and do a quick check on the preceding | 2172 | ;; Skip simple horizontal ws and do a quick check on the preceding |
| 2160 | ;; character to see if it's anything that can't end syntactic ws, so we can | 2173 | ;; character to see if it's anything that can't end syntactic ws, so we can |
| @@ -2164,12 +2177,17 @@ comment at the start of cc-engine.el for more info." | |||
| 2164 | (skip-chars-backward " \t\f") | 2177 | (skip-chars-backward " \t\f") |
| 2165 | (when (and (not (bobp)) | 2178 | (when (and (not (bobp)) |
| 2166 | (save-excursion | 2179 | (save-excursion |
| 2167 | (backward-char) | 2180 | (or (and |
| 2168 | (or (looking-at c-syntactic-ws-end) | 2181 | (memq (char-before) c-doc-line-join-end-ch) ; For speed. |
| 2169 | (and c-opt-cpp-prefix | 2182 | (re-search-backward doc-line-join-here |
| 2170 | (looking-at c-symbol-char-key) | 2183 | (c-point 'bopl) t)) |
| 2171 | (progn (c-beginning-of-current-token) | 2184 | (progn |
| 2172 | (looking-at c-noise-macro-name-re)))))) | 2185 | (backward-char) |
| 2186 | (or (looking-at c-syntactic-ws-end) | ||
| 2187 | (and c-opt-cpp-prefix | ||
| 2188 | (looking-at c-symbol-char-key) | ||
| 2189 | (progn (c-beginning-of-current-token) | ||
| 2190 | (looking-at c-noise-macro-name-re)))))))) | ||
| 2173 | ;; Try to find a rung position in the simple ws preceding point, so that | 2191 | ;; Try to find a rung position in the simple ws preceding point, so that |
| 2174 | ;; we can get a cache hit even if the last bit of the simple ws has | 2192 | ;; we can get a cache hit even if the last bit of the simple ws has |
| 2175 | ;; changed recently. | 2193 | ;; changed recently. |
| @@ -2309,7 +2327,11 @@ comment at the start of cc-engine.el for more info." | |||
| 2309 | (looking-at c-noise-macro-name-re))))) | 2327 | (looking-at c-noise-macro-name-re))))) |
| 2310 | ;; Skipped over a noise macro | 2328 | ;; Skipped over a noise macro |
| 2311 | (goto-char next-rung-pos) | 2329 | (goto-char next-rung-pos) |
| 2312 | t))) | 2330 | t) |
| 2331 | |||
| 2332 | ((and | ||
| 2333 | (memq (char-before) c-doc-line-join-end-ch) ; For speed. | ||
| 2334 | (re-search-backward doc-line-join-here (c-point 'bopl) t))))) | ||
| 2313 | 2335 | ||
| 2314 | ;; We've searched over a piece of non-white syntactic ws. See if this | 2336 | ;; We've searched over a piece of non-white syntactic ws. See if this |
| 2315 | ;; can be cached. | 2337 | ;; can be cached. |
| @@ -5691,7 +5713,16 @@ comment at the start of cc-engine.el for more info." | |||
| 5691 | 5713 | ||
| 5692 | (when (< cfd-match-pos cfd-limit) | 5714 | (when (< cfd-match-pos cfd-limit) |
| 5693 | ;; Skip forward past comments only so we don't skip macros. | 5715 | ;; Skip forward past comments only so we don't skip macros. |
| 5694 | (c-forward-comments) | 5716 | (while |
| 5717 | (progn | ||
| 5718 | (c-forward-comments) | ||
| 5719 | ;; The following is of use within a doc comment when a doc | ||
| 5720 | ;; comment style has removed face properties from a construct, | ||
| 5721 | ;; and is relying on `c-font-lock-declarations' to add them | ||
| 5722 | ;; again. | ||
| 5723 | (and (< (point) cfd-limit) | ||
| 5724 | (looking-at c-doc-line-join-re) | ||
| 5725 | (goto-char (match-end 0))))) | ||
| 5695 | ;; Set the position to continue at. We can avoid going over | 5726 | ;; Set the position to continue at. We can avoid going over |
| 5696 | ;; the comments skipped above a second time, but it's possible | 5727 | ;; the comments skipped above a second time, but it's possible |
| 5697 | ;; that the comment skipping has taken us past `cfd-prop-match' | 5728 | ;; that the comment skipping has taken us past `cfd-prop-match' |
| @@ -5950,7 +5981,7 @@ comment at the start of cc-engine.el for more info." | |||
| 5950 | (goto-char (or start-in-literal cfd-start-pos)) | 5981 | (goto-char (or start-in-literal cfd-start-pos)) |
| 5951 | ;; The only syntactic ws in macros are comments. | 5982 | ;; The only syntactic ws in macros are comments. |
| 5952 | (c-backward-comments) | 5983 | (c-backward-comments) |
| 5953 | (backward-char) | 5984 | (or (bobp) (backward-char)) |
| 5954 | (c-beginning-of-current-token)) | 5985 | (c-beginning-of-current-token)) |
| 5955 | 5986 | ||
| 5956 | (start-in-literal | 5987 | (start-in-literal |
| @@ -5975,7 +6006,8 @@ comment at the start of cc-engine.el for more info." | |||
| 5975 | (not (eq (c-get-char-property (point) 'c-type) | 6006 | (not (eq (c-get-char-property (point) 'c-type) |
| 5976 | 'c-decl-end)))))) | 6007 | 'c-decl-end)))))) |
| 5977 | 6008 | ||
| 5978 | (when (= (point) start-in-literal) | 6009 | (when (and (= (point) start-in-literal) |
| 6010 | (not (looking-at c-doc-bright-comment-start-re))) | ||
| 5979 | ;; Didn't find any property inside the comment, so we can | 6011 | ;; Didn't find any property inside the comment, so we can |
| 5980 | ;; skip it entirely. (This won't skip past a string, but | 6012 | ;; skip it entirely. (This won't skip past a string, but |
| 5981 | ;; that'll be handled quickly by the next | 6013 | ;; that'll be handled quickly by the next |
diff --git a/lisp/progmodes/cc-fonts.el b/lisp/progmodes/cc-fonts.el index e7a3748af43..5832f1f451c 100644 --- a/lisp/progmodes/cc-fonts.el +++ b/lisp/progmodes/cc-fonts.el | |||
| @@ -2089,6 +2089,14 @@ higher." | |||
| 2089 | (c-lang-const c-complex-decl-matchers) | 2089 | (c-lang-const c-complex-decl-matchers) |
| 2090 | (c-lang-const c-basic-matchers-after))) | 2090 | (c-lang-const c-basic-matchers-after))) |
| 2091 | 2091 | ||
| 2092 | (defun c-get-doc-comment-style () | ||
| 2093 | ;; Get the symbol (or list of symbols) constituting the document style. | ||
| 2094 | ;; Return nil if there is no such, otherwise something like `autodoc'. | ||
| 2095 | (if (consp (car-safe c-doc-comment-style)) | ||
| 2096 | (cdr-safe (or (assq c-buffer-is-cc-mode c-doc-comment-style) | ||
| 2097 | (assq 'other c-doc-comment-style))) | ||
| 2098 | c-doc-comment-style)) | ||
| 2099 | |||
| 2092 | (defun c-compose-keywords-list (base-list) | 2100 | (defun c-compose-keywords-list (base-list) |
| 2093 | ;; Incorporate the font lock keyword lists according to | 2101 | ;; Incorporate the font lock keyword lists according to |
| 2094 | ;; `c-doc-comment-style' on the given keyword list and return it. | 2102 | ;; `c-doc-comment-style' on the given keyword list and return it. |
| @@ -2099,11 +2107,7 @@ higher." | |||
| 2099 | (unless (memq c-doc-face-name c-literal-faces) | 2107 | (unless (memq c-doc-face-name c-literal-faces) |
| 2100 | (setq c-literal-faces (cons c-doc-face-name c-literal-faces))) | 2108 | (setq c-literal-faces (cons c-doc-face-name c-literal-faces))) |
| 2101 | 2109 | ||
| 2102 | (let* ((doc-keywords | 2110 | (let* ((doc-keywords (c-get-doc-comment-style)) |
| 2103 | (if (consp (car-safe c-doc-comment-style)) | ||
| 2104 | (cdr-safe (or (assq c-buffer-is-cc-mode c-doc-comment-style) | ||
| 2105 | (assq 'other c-doc-comment-style))) | ||
| 2106 | c-doc-comment-style)) | ||
| 2107 | (list (nconc (c--mapcan | 2111 | (list (nconc (c--mapcan |
| 2108 | (lambda (doc-style) | 2112 | (lambda (doc-style) |
| 2109 | (let ((sym (intern | 2113 | (let ((sym (intern |
| @@ -2552,15 +2556,88 @@ need for `pike-font-lock-extra-types'.") | |||
| 2552 | "Default expressions to highlight in Pike mode.") | 2556 | "Default expressions to highlight in Pike mode.") |
| 2553 | 2557 | ||
| 2554 | (defun pike-font-lock-keywords-2 () | 2558 | (defun pike-font-lock-keywords-2 () |
| 2559 | (c-set-doc-comment-res) | ||
| 2555 | (c-compose-keywords-list pike-font-lock-keywords-2)) | 2560 | (c-compose-keywords-list pike-font-lock-keywords-2)) |
| 2556 | (defun pike-font-lock-keywords-3 () | 2561 | (defun pike-font-lock-keywords-3 () |
| 2562 | (c-set-doc-comment-res) | ||
| 2557 | (c-compose-keywords-list pike-font-lock-keywords-3)) | 2563 | (c-compose-keywords-list pike-font-lock-keywords-3)) |
| 2558 | (defun pike-font-lock-keywords () | 2564 | (defun pike-font-lock-keywords () |
| 2565 | (c-set-doc-comment-res) | ||
| 2559 | (c-compose-keywords-list pike-font-lock-keywords)) | 2566 | (c-compose-keywords-list pike-font-lock-keywords)) |
| 2560 | 2567 | ||
| 2561 | 2568 | ||
| 2562 | ;;; Doc comments. | 2569 | ;;; Doc comments. |
| 2563 | 2570 | ||
| 2571 | (defvar c-doc-line-join-re "a\\`") | ||
| 2572 | ;; Matches a join of two lines in a doc comment. | ||
| 2573 | ;; This should not be changed directly, but instead set by | ||
| 2574 | ;; `c-setup-doc-comment-style'. This variable is used in `c-find-decl-spots' | ||
| 2575 | ;; in (e.g.) autodoc style comments to bridge the gap between a "@\n" at an | ||
| 2576 | ;; EOL and the token following "//!" on the next line. | ||
| 2577 | |||
| 2578 | (defvar c-doc-bright-comment-start-re "a\\`") | ||
| 2579 | ;; Matches the start of a "bright" comment, one whose contents may be | ||
| 2580 | ;; fontified by, e.g., `c-font-lock-declarations'. | ||
| 2581 | |||
| 2582 | (defvar c-doc-line-join-end-ch nil) | ||
| 2583 | ;; A list of characters, each being a last character of a doc comment marker, | ||
| 2584 | ;; e.g. the ! from pike autodoc's "//!". | ||
| 2585 | |||
| 2586 | (defmacro c-set-doc-comment-re-element (suffix) | ||
| 2587 | ;; Set the variable `c-doc-line-join-re' to a buffer local value suitable | ||
| 2588 | ;; for the current doc comment style, or kill the local value. | ||
| 2589 | (let ((var (intern (concat "c-doc" suffix)))) | ||
| 2590 | `(let* ((styles (c-get-doc-comment-style)) | ||
| 2591 | elts) | ||
| 2592 | (when (atom styles) | ||
| 2593 | (setq styles (list styles))) | ||
| 2594 | (setq elts | ||
| 2595 | (mapcar (lambda (style) | ||
| 2596 | (let ((sym | ||
| 2597 | (intern-soft | ||
| 2598 | (concat (symbol-name style) ,suffix)))) | ||
| 2599 | (and sym | ||
| 2600 | (boundp sym) | ||
| 2601 | (symbol-value sym)))) | ||
| 2602 | styles)) | ||
| 2603 | (setq elts (delq nil elts)) | ||
| 2604 | (setq elts (and elts | ||
| 2605 | (concat "\\(" | ||
| 2606 | (mapconcat #'identity elts "\\|") | ||
| 2607 | "\\)"))) | ||
| 2608 | (if elts | ||
| 2609 | (set (make-local-variable ',var) elts) | ||
| 2610 | (kill-local-variable ',var))))) | ||
| 2611 | |||
| 2612 | (defmacro c-set-doc-comment-char-list (suffix) | ||
| 2613 | ;; Set the variable 'c-doc-<suffix>' to the list of *-<suffix>, which must | ||
| 2614 | ;; be characters, and * represents the doc comment style. | ||
| 2615 | (let ((var (intern (concat "c-doc" suffix)))) | ||
| 2616 | `(let* ((styles (c-get-doc-comment-style)) | ||
| 2617 | elts) | ||
| 2618 | (when (atom styles) | ||
| 2619 | (setq styles (list styles))) | ||
| 2620 | (setq elts | ||
| 2621 | (mapcar (lambda (style) | ||
| 2622 | (let ((sym | ||
| 2623 | (intern-soft | ||
| 2624 | (concat (symbol-name style) ,suffix)))) | ||
| 2625 | (and sym | ||
| 2626 | (boundp sym) | ||
| 2627 | (symbol-value sym)))) | ||
| 2628 | styles)) | ||
| 2629 | (setq elts (delq nil elts)) | ||
| 2630 | (if elts | ||
| 2631 | (set (make-local-variable ',var) elts) | ||
| 2632 | (kill-local-variable ',var))))) | ||
| 2633 | |||
| 2634 | (defun c-set-doc-comment-res () | ||
| 2635 | ;; Set the variables `c-doc-line-join-re' and | ||
| 2636 | ;; `c-doc-bright-comment-start-re' from the current doc comment style(s). | ||
| 2637 | (c-set-doc-comment-re-element "-line-join-re") | ||
| 2638 | (c-set-doc-comment-re-element "-bright-comment-start-re") | ||
| 2639 | (c-set-doc-comment-char-list "-line-join-end-ch")) | ||
| 2640 | |||
| 2564 | (defun c-font-lock-doc-comments (prefix limit keywords) | 2641 | (defun c-font-lock-doc-comments (prefix limit keywords) |
| 2565 | ;; Fontify the comments between the point and LIMIT whose start | 2642 | ;; Fontify the comments between the point and LIMIT whose start |
| 2566 | ;; matches PREFIX with `c-doc-face-name'. Assumes comments have been | 2643 | ;; matches PREFIX with `c-doc-face-name'. Assumes comments have been |
| @@ -2621,17 +2698,20 @@ need for `pike-font-lock-extra-types'.") | |||
| 2621 | (goto-char comment-beg) | 2698 | (goto-char comment-beg) |
| 2622 | (while (and (progn | 2699 | (while (and (progn |
| 2623 | (c-forward-single-comment) | 2700 | (c-forward-single-comment) |
| 2701 | (c-put-font-lock-face comment-beg (point) | ||
| 2702 | c-doc-face-name) | ||
| 2624 | (skip-syntax-forward " ") | 2703 | (skip-syntax-forward " ") |
| 2704 | (setq comment-beg (point)) | ||
| 2625 | (< (point) limit)) | 2705 | (< (point) limit)) |
| 2626 | (looking-at prefix)))) | 2706 | (looking-at prefix)))) |
| 2627 | (goto-char comment-beg) | 2707 | (goto-char comment-beg) |
| 2628 | (c-forward-single-comment)) | 2708 | (c-forward-single-comment) |
| 2709 | (c-put-font-lock-face comment-beg (point) c-doc-face-name)) | ||
| 2629 | (if (> (point) limit) (goto-char limit)) | 2710 | (if (> (point) limit) (goto-char limit)) |
| 2630 | (setq comment-beg nil) | 2711 | (setq comment-beg nil) |
| 2631 | 2712 | ||
| 2632 | (let ((region-end (point)) | 2713 | (let ((region-end (point)) |
| 2633 | (keylist keywords) keyword matcher highlights) | 2714 | (keylist keywords) keyword matcher highlights) |
| 2634 | (c-put-font-lock-face region-beg region-end c-doc-face-name) | ||
| 2635 | (save-restriction | 2715 | (save-restriction |
| 2636 | ;; Narrow to the doc comment. Among other things, this | 2716 | ;; Narrow to the doc comment. Among other things, this |
| 2637 | ;; helps by making "^" match at the start of the comment. | 2717 | ;; helps by making "^" match at the start of the comment. |
| @@ -2838,6 +2918,13 @@ need for `pike-font-lock-extra-types'.") | |||
| 2838 | 0 'font-lock-warning-face prepend nil) | 2918 | 0 'font-lock-warning-face prepend nil) |
| 2839 | )) | 2919 | )) |
| 2840 | 2920 | ||
| 2921 | (defconst autodoc-line-join-re "@[\n\r][ \t]*/[/*]!") | ||
| 2922 | ;; Matches a line continuation in autodoc comment style. | ||
| 2923 | (defconst autodoc-bright-comment-start-re "/[/*]!") | ||
| 2924 | ;; Matches an autodoc comment opener. | ||
| 2925 | (defconst autodoc-line-join-end-ch ?!) | ||
| 2926 | ;; The final character of `autodoc-line-join-re'. | ||
| 2927 | |||
| 2841 | (defun autodoc-font-lock-keywords () | 2928 | (defun autodoc-font-lock-keywords () |
| 2842 | ;; Note that we depend on that `c-current-comment-prefix' has got | 2929 | ;; Note that we depend on that `c-current-comment-prefix' has got |
| 2843 | ;; its proper value here. | 2930 | ;; its proper value here. |
diff --git a/lisp/progmodes/cc-mode.el b/lisp/progmodes/cc-mode.el index fc4ba8f5891..aea9c7f3ed1 100644 --- a/lisp/progmodes/cc-mode.el +++ b/lisp/progmodes/cc-mode.el | |||
| @@ -1797,6 +1797,34 @@ Note that this is a strict tail, so won't match, e.g. \"0x....\".") | |||
| 1797 | (funcall fn beg end old-len)) | 1797 | (funcall fn beg end old-len)) |
| 1798 | c-before-font-lock-functions))))))) | 1798 | c-before-font-lock-functions))))))) |
| 1799 | 1799 | ||
| 1800 | (defun c-doc-fl-decl-start (pos) | ||
| 1801 | ;; If the line containing POS is in a doc comment continued line (as defined | ||
| 1802 | ;; by `c-doc-line-join-re'), return the position of the first line of the | ||
| 1803 | ;; sequence. Otherwise, return nil. Point has no significance at entry to | ||
| 1804 | ;; and exit from this function. | ||
| 1805 | (goto-char pos) | ||
| 1806 | (back-to-indentation) | ||
| 1807 | (and (or (looking-at c-comment-start-regexp) | ||
| 1808 | (memq (c-literal-type (c-literal-limits)) '(c c++))) | ||
| 1809 | (progn | ||
| 1810 | (end-of-line) | ||
| 1811 | (let ((here (point))) | ||
| 1812 | (while (re-search-backward c-doc-line-join-re (c-point 'bopl) t)) | ||
| 1813 | (and (not (eq (point) here)) | ||
| 1814 | (c-point 'bol)))))) | ||
| 1815 | |||
| 1816 | (defun c-doc-fl-decl-end (pos) | ||
| 1817 | ;; If the line containing POS is continued by a doc comment continuation | ||
| 1818 | ;; marker (as defined by `c-doc-line-join-re), return the position of | ||
| 1819 | ;; the BOL at the end of the sequence. Otherwise, return nil. Point has no | ||
| 1820 | ;; significance at entry to and exit from this function. | ||
| 1821 | (goto-char pos) | ||
| 1822 | (back-to-indentation) | ||
| 1823 | (let ((here (point))) | ||
| 1824 | (while (re-search-forward c-doc-line-join-re (c-point 'eonl) t)) | ||
| 1825 | (and (not (eq (point) here)) | ||
| 1826 | (c-point 'bonl)))) | ||
| 1827 | |||
| 1800 | (defun c-fl-decl-start (pos) | 1828 | (defun c-fl-decl-start (pos) |
| 1801 | ;; If the beginning of the line containing POS is in the middle of a "local" | 1829 | ;; If the beginning of the line containing POS is in the middle of a "local" |
| 1802 | ;; declaration, return the beginning of that declaration. Otherwise return | 1830 | ;; declaration, return the beginning of that declaration. Otherwise return |
| @@ -1912,9 +1940,10 @@ Note that this is a strict tail, so won't match, e.g. \"0x....\".") | |||
| 1912 | ;; and OLD-LEN are not used. | 1940 | ;; and OLD-LEN are not used. |
| 1913 | (if font-lock-mode | 1941 | (if font-lock-mode |
| 1914 | (setq c-new-BEG | 1942 | (setq c-new-BEG |
| 1915 | (or (c-fl-decl-start c-new-BEG) (c-point 'bol c-new-BEG)) | 1943 | (or (c-fl-decl-start c-new-BEG) (c-doc-fl-decl-start c-new-BEG) |
| 1944 | (c-point 'bol c-new-BEG)) | ||
| 1916 | c-new-END | 1945 | c-new-END |
| 1917 | (or (c-fl-decl-end c-new-END) | 1946 | (or (c-fl-decl-end c-new-END) (c-doc-fl-decl-end c-new-END) |
| 1918 | (c-point 'bonl c-new-END))))) | 1947 | (c-point 'bonl c-new-END))))) |
| 1919 | 1948 | ||
| 1920 | (defun c-context-expand-fl-region (beg end) | 1949 | (defun c-context-expand-fl-region (beg end) |
| @@ -1922,8 +1951,10 @@ Note that this is a strict tail, so won't match, e.g. \"0x....\".") | |||
| 1922 | ;; "local" declaration containing BEG (see `c-fl-decl-start') or BOL BEG is | 1951 | ;; "local" declaration containing BEG (see `c-fl-decl-start') or BOL BEG is |
| 1923 | ;; in. NEW-END is beginning of the line after the one END is in. | 1952 | ;; in. NEW-END is beginning of the line after the one END is in. |
| 1924 | (c-save-buffer-state () | 1953 | (c-save-buffer-state () |
| 1925 | (cons (or (c-fl-decl-start beg) (c-point 'bol beg)) | 1954 | (cons (or (c-fl-decl-start beg) (c-doc-fl-decl-start beg) |
| 1926 | (or (c-fl-decl-end end) (c-point 'bonl (1- end)))))) | 1955 | (c-point 'bol beg)) |
| 1956 | (or (c-fl-decl-end end) (c-doc-fl-decl-end end) | ||
| 1957 | (c-point 'bonl (1- end)))))) | ||
| 1927 | 1958 | ||
| 1928 | (defun c-before-context-fl-expand-region (beg end) | 1959 | (defun c-before-context-fl-expand-region (beg end) |
| 1929 | ;; Expand the region (BEG END) as specified by | 1960 | ;; Expand the region (BEG END) as specified by |