emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] emacs-25 b51f1ef: Java Mode: Fontify identifiers in the pr


From: Alan Mackenzie
Subject: [Emacs-diffs] emacs-25 b51f1ef: Java Mode: Fontify identifiers in the presence of annotations.
Date: Mon, 11 Jan 2016 17:46:42 +0000

branch: emacs-25
commit b51f1ef82fa324f08fe94b8fa8aaf8b8ebb3a48e
Author: Alan Mackenzie <address@hidden>
Commit: Alan Mackenzie <address@hidden>

    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.
---
 lisp/progmodes/cc-engine.el |   31 ++++++++++++++++++-------------
 lisp/progmodes/cc-fonts.el  |   11 +----------
 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 98699df..b08c555 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."
     res))
 
 (defun c-forward-annotation ()
-  ;; Used for Java code only at the moment.  Assumes point is on the
-  ;; @, moves forward an annotation.  returns nil if there is no
-  ;; annotation at point.
-  (and (looking-at "@")
-       (progn (forward-char) t)
-       (c-forward-type)
-       (progn (c-forward-syntactic-ws) t)
-       (if (looking-at "(")
-          (c-go-list-forward)
-        t)))
+  ;; Used for Java code only at the moment.  Assumes point is on the @, moves
+  ;; forward an annotation and returns t.  Leaves point unmoved and returns
+  ;; nil if there is no annotation at point.
+  (let ((pos (point)))
+    (or
+     (and (looking-at "@")
+         (not (looking-at c-keywords-regexp))
+         (progn (forward-char) t)
+         (looking-at c-symbol-key)
+         (progn (goto-char (match-end 0))
+                (c-forward-syntactic-ws)
+                t)
+         (if (looking-at "(")
+             (c-go-list-forward)
+           t))
+     (progn (goto-char pos) nil))))
 
 (defmacro c-pull-open-brace (ps)
   ;; 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."
          (when (or (looking-at c-prefix-spec-kwds-re) ;FIXME!!! includes auto
                    (and (c-major-mode-is 'java-mode)
                         (looking-at "@[A-Za-z0-9]+")))
-           (save-match-data
-             (if (looking-at c-typedef-key)
-               (setq at-typedef t)))
+           (if (save-match-data (looking-at c-typedef-key))
+               (setq at-typedef t))
            (setq kwd-sym (c-keyword-sym (match-string 1)))
            (save-excursion
              (c-forward-keyword-clause 1)
diff --git a/lisp/progmodes/cc-fonts.el b/lisp/progmodes/cc-fonts.el
index f74e5cb..03e67a9 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."
          (setq pos (point))))))     ; acts to make the `while' form continue.
   nil)
 
-(defconst c-font-lock-maybe-decl-faces
-  ;; List of faces that might be put at the start of a type when
-  ;; `c-font-lock-declarations' runs.  This needs to be evaluated to
-  ;; ensure that face name aliases in Emacs are resolved.
-  (list nil
-       font-lock-type-face
-       c-reference-face-name
-       font-lock-keyword-face))
-
 (defun c-font-lock-declarations (limit)
   ;; Fontify all the declarations, casts and labels from the point to LIMIT.
   ;; Assumes that strings and comments have been fontified already.
@@ -1256,7 +1247,7 @@ casts and declarations are fontified.  Used on level 2 
and higher."
       (c-find-decl-spots
        limit
        c-decl-start-re
-       c-font-lock-maybe-decl-faces
+       (eval c-maybe-decl-faces)
 
        (lambda (match-pos inside-macro)
         ;; 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 08d84fb..b52da3f 100644
--- a/lisp/progmodes/cc-langs.el
+++ b/lisp/progmodes/cc-langs.el
@@ -3251,6 +3251,19 @@ way."
   objc t)
 (c-lang-defvar c-type-decl-end-used (c-lang-const c-type-decl-end-used))
 
+(c-lang-defconst c-maybe-decl-faces
+  "List of faces that might be put at the start of a type when
+`c-font-lock-declarations' runs.  This must be evaluated (with `eval') at
+runtime to get the actual list of faces.  This ensures that face name
+aliases in Emacs are resolved."
+  t '(list nil
+          font-lock-type-face
+          c-reference-face-name
+          font-lock-keyword-face)
+  java (append (c-lang-const c-maybe-decl-faces)
+              '(font-lock-preprocessor-face)))
+(c-lang-defvar c-maybe-decl-faces (c-lang-const c-maybe-decl-faces))
+
 
 ;;; Wrap up the `c-lang-defvar' system.
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]