diff options
| author | Alan Mackenzie | 2016-01-11 17:46:04 +0000 |
|---|---|---|
| committer | Alan Mackenzie | 2016-01-11 17:46:04 +0000 |
| commit | b51f1ef82fa324f08fe94b8fa8aaf8b8ebb3a48e (patch) | |
| tree | 253448dd0f5f0538beb8ec1d88210ca5c3604fad | |
| parent | 36b953947ee2ee0411139bd4ad7dcffdcc403036 (diff) | |
| download | emacs-b51f1ef82fa324f08fe94b8fa8aaf8b8ebb3a48e.tar.gz emacs-b51f1ef82fa324f08fe94b8fa8aaf8b8ebb3a48e.zip | |
Java Mode: Fontify identifiers in the presence of annotations.
* lisp/progmodes/cc-engine.el (c-forward-annotation): Tidy up the coding:
Don't move point when the defun fails.
(c-forward-decl-or-cast-1): Correct a usage of match data.
* lisp/progmodes/cc-fonts.el (c-font-lock-maybe-decl-faces): Remove.
(c-font-lock-declarations): Use the new c-maybe-decl-faces in place of the
removed variable.
* lisp/progmodes/cc-langs.el (c-maybe-decl-faces): New language variable.
| -rw-r--r-- | lisp/progmodes/cc-engine.el | 31 | ||||
| -rw-r--r-- | lisp/progmodes/cc-fonts.el | 11 | ||||
| -rw-r--r-- | lisp/progmodes/cc-langs.el | 13 |
3 files changed, 32 insertions, 23 deletions
diff --git a/lisp/progmodes/cc-engine.el b/lisp/progmodes/cc-engine.el index 98699df0cab..b08c555e34f 100644 --- a/lisp/progmodes/cc-engine.el +++ b/lisp/progmodes/cc-engine.el | |||
| @@ -6641,16 +6641,22 @@ comment at the start of cc-engine.el for more info." | |||
| 6641 | res)) | 6641 | res)) |
| 6642 | 6642 | ||
| 6643 | (defun c-forward-annotation () | 6643 | (defun c-forward-annotation () |
| 6644 | ;; Used for Java code only at the moment. Assumes point is on the | 6644 | ;; Used for Java code only at the moment. Assumes point is on the @, moves |
| 6645 | ;; @, moves forward an annotation. returns nil if there is no | 6645 | ;; forward an annotation and returns t. Leaves point unmoved and returns |
| 6646 | ;; annotation at point. | 6646 | ;; nil if there is no annotation at point. |
| 6647 | (and (looking-at "@") | 6647 | (let ((pos (point))) |
| 6648 | (progn (forward-char) t) | 6648 | (or |
| 6649 | (c-forward-type) | 6649 | (and (looking-at "@") |
| 6650 | (progn (c-forward-syntactic-ws) t) | 6650 | (not (looking-at c-keywords-regexp)) |
| 6651 | (if (looking-at "(") | 6651 | (progn (forward-char) t) |
| 6652 | (c-go-list-forward) | 6652 | (looking-at c-symbol-key) |
| 6653 | t))) | 6653 | (progn (goto-char (match-end 0)) |
| 6654 | (c-forward-syntactic-ws) | ||
| 6655 | t) | ||
| 6656 | (if (looking-at "(") | ||
| 6657 | (c-go-list-forward) | ||
| 6658 | t)) | ||
| 6659 | (progn (goto-char pos) nil)))) | ||
| 6654 | 6660 | ||
| 6655 | (defmacro c-pull-open-brace (ps) | 6661 | (defmacro c-pull-open-brace (ps) |
| 6656 | ;; Pull the next open brace from PS (which has the form of paren-state), | 6662 | ;; Pull the next open brace from PS (which has the form of paren-state), |
| @@ -6959,9 +6965,8 @@ comment at the start of cc-engine.el for more info." | |||
| 6959 | (when (or (looking-at c-prefix-spec-kwds-re) ;FIXME!!! includes auto | 6965 | (when (or (looking-at c-prefix-spec-kwds-re) ;FIXME!!! includes auto |
| 6960 | (and (c-major-mode-is 'java-mode) | 6966 | (and (c-major-mode-is 'java-mode) |
| 6961 | (looking-at "@[A-Za-z0-9]+"))) | 6967 | (looking-at "@[A-Za-z0-9]+"))) |
| 6962 | (save-match-data | 6968 | (if (save-match-data (looking-at c-typedef-key)) |
| 6963 | (if (looking-at c-typedef-key) | 6969 | (setq at-typedef t)) |
| 6964 | (setq at-typedef t))) | ||
| 6965 | (setq kwd-sym (c-keyword-sym (match-string 1))) | 6970 | (setq kwd-sym (c-keyword-sym (match-string 1))) |
| 6966 | (save-excursion | 6971 | (save-excursion |
| 6967 | (c-forward-keyword-clause 1) | 6972 | (c-forward-keyword-clause 1) |
diff --git a/lisp/progmodes/cc-fonts.el b/lisp/progmodes/cc-fonts.el index f74e5cbf678..03e67a99515 100644 --- a/lisp/progmodes/cc-fonts.el +++ b/lisp/progmodes/cc-fonts.el | |||
| @@ -1157,15 +1157,6 @@ casts and declarations are fontified. Used on level 2 and higher." | |||
| 1157 | (setq pos (point)))))) ; acts to make the `while' form continue. | 1157 | (setq pos (point)))))) ; acts to make the `while' form continue. |
| 1158 | nil) | 1158 | nil) |
| 1159 | 1159 | ||
| 1160 | (defconst c-font-lock-maybe-decl-faces | ||
| 1161 | ;; List of faces that might be put at the start of a type when | ||
| 1162 | ;; `c-font-lock-declarations' runs. This needs to be evaluated to | ||
| 1163 | ;; ensure that face name aliases in Emacs are resolved. | ||
| 1164 | (list nil | ||
| 1165 | font-lock-type-face | ||
| 1166 | c-reference-face-name | ||
| 1167 | font-lock-keyword-face)) | ||
| 1168 | |||
| 1169 | (defun c-font-lock-declarations (limit) | 1160 | (defun c-font-lock-declarations (limit) |
| 1170 | ;; Fontify all the declarations, casts and labels from the point to LIMIT. | 1161 | ;; Fontify all the declarations, casts and labels from the point to LIMIT. |
| 1171 | ;; Assumes that strings and comments have been fontified already. | 1162 | ;; Assumes that strings and comments have been fontified already. |
| @@ -1256,7 +1247,7 @@ casts and declarations are fontified. Used on level 2 and higher." | |||
| 1256 | (c-find-decl-spots | 1247 | (c-find-decl-spots |
| 1257 | limit | 1248 | limit |
| 1258 | c-decl-start-re | 1249 | c-decl-start-re |
| 1259 | c-font-lock-maybe-decl-faces | 1250 | (eval c-maybe-decl-faces) |
| 1260 | 1251 | ||
| 1261 | (lambda (match-pos inside-macro) | 1252 | (lambda (match-pos inside-macro) |
| 1262 | ;; Note to maintainers: don't use `limit' inside this lambda form; | 1253 | ;; Note to maintainers: don't use `limit' inside this lambda form; |
diff --git a/lisp/progmodes/cc-langs.el b/lisp/progmodes/cc-langs.el index 08d84fbb625..b52da3f662d 100644 --- a/lisp/progmodes/cc-langs.el +++ b/lisp/progmodes/cc-langs.el | |||
| @@ -3251,6 +3251,19 @@ way." | |||
| 3251 | objc t) | 3251 | objc t) |
| 3252 | (c-lang-defvar c-type-decl-end-used (c-lang-const c-type-decl-end-used)) | 3252 | (c-lang-defvar c-type-decl-end-used (c-lang-const c-type-decl-end-used)) |
| 3253 | 3253 | ||
| 3254 | (c-lang-defconst c-maybe-decl-faces | ||
| 3255 | "List of faces that might be put at the start of a type when | ||
| 3256 | `c-font-lock-declarations' runs. This must be evaluated (with `eval') at | ||
| 3257 | runtime to get the actual list of faces. This ensures that face name | ||
| 3258 | aliases in Emacs are resolved." | ||
| 3259 | t '(list nil | ||
| 3260 | font-lock-type-face | ||
| 3261 | c-reference-face-name | ||
| 3262 | font-lock-keyword-face) | ||
| 3263 | java (append (c-lang-const c-maybe-decl-faces) | ||
| 3264 | '(font-lock-preprocessor-face))) | ||
| 3265 | (c-lang-defvar c-maybe-decl-faces (c-lang-const c-maybe-decl-faces)) | ||
| 3266 | |||
| 3254 | 3267 | ||
| 3255 | ;;; Wrap up the `c-lang-defvar' system. | 3268 | ;;; Wrap up the `c-lang-defvar' system. |
| 3256 | 3269 | ||