emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] Changes to emacs/lisp/progmodes/cc-engine.el,v


From: Alan Mackenzie
Subject: [Emacs-diffs] Changes to emacs/lisp/progmodes/cc-engine.el,v
Date: Fri, 06 Apr 2007 21:21:55 +0000

CVSROOT:        /cvsroot/emacs
Module name:    emacs
Changes by:     Alan Mackenzie <acmacm> 07/04/06 21:21:55

Index: cc-engine.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/progmodes/cc-engine.el,v
retrieving revision 1.55
retrieving revision 1.56
diff -u -b -r1.55 -r1.56
--- cc-engine.el        25 Mar 2007 12:04:11 -0000      1.55
+++ cc-engine.el        6 Apr 2007 21:21:55 -0000       1.56
@@ -5371,7 +5371,7 @@
          ;; True if there's a prefix match outside the outermost
          ;; paren pair that surrounds the declarator.
          got-prefix-before-parens
-y        ;; True if there's a suffix match outside the outermost
+         ;; True if there's a suffix match outside the outermost
          ;; paren pair that surrounds the declarator.  The value is
          ;; the position of the first suffix match.
          got-suffix-after-parens
@@ -5877,19 +5877,23 @@
 
 (defun c-forward-label (&optional assume-markup preceding-token-end limit)
   ;; Assuming that point is at the beginning of a token, check if it starts a
-  ;; label and if so move over it and return t, otherwise don't move and
-  ;; return nil.  "Label" here means "most things with a colon".
+  ;; label and if so move over it and return non-nil (t in default situations,
+  ;; specific symbols (see below) for interesting situations), otherwise don't
+  ;; move and return nil.  "Label" here means "most things with a colon".
   ;;
   ;; More precisely, a "label" is regarded as one of:
-  ;; (i) a goto target like "foo:";
-  ;; (ii) A case label - either the entire construct "case FOO:" or just the
-  ;;   bare "case", should the colon be missing;
-  ;; (iii) a keyword which needs a colon, like "default:" or "private:";
+  ;; (i) a goto target like "foo:" - returns the symbol `goto-target';
+  ;; (ii) A case label - either the entire construct "case FOO:", or just the
+  ;;   bare "case", should the colon be missing.  We return t;
+  ;; (iii) a keyword which needs a colon, like "default:" or "private:";  We
+  ;;   return t;
   ;; (iv) One of QT's "extended" C++ variants of
   ;; "private:"/"protected:"/"public:"/"more:" looking like "public slots:".
+  ;;   Returns the symbol `qt-2kwds-colon'.
+  ;; (v) QT's construct "signals:".  Returns the symbol `qt-1kwd-colon'.
   ;; (v) One of the keywords matched by `c-opt-extra-label-key' (without any
   ;;   colon).  Currently (2006-03), this applies only to Objective C's
-  ;;   keywords "@private", "@protected", and "@public".
+  ;;   keywords "@private", "@protected", and "@public".  Returns t.
   ;;
   ;; One of the things which will NOT be recognised as a label is a bit-field
   ;; element of a struct, something like "int foo:5".
@@ -5918,8 +5922,10 @@
   ;; This function might do hidden buffer changes.
 
   (let ((start (point))
+       label-end
        qt-symbol-idx
-       macro-start)                    ; if we're in one.
+       macro-start                     ; if we're in one.
+       label-type)
     (cond
      ;; "case" or "default" (Doesn't apply to AWK). 
      ((looking-at c-label-kwds-regexp)
@@ -5932,6 +5938,7 @@
 
        ;; Find the label end.
        (goto-char kwd-end)
+       (setq label-type
        (if (and (c-syntactic-re-search-forward
                  ;; Stop on chars that aren't allowed in expressions,
                  ;; and on operator chars that would be meaningless
@@ -5940,7 +5947,7 @@
                  limit t t nil 1)
                 (match-beginning 2))
 
-           (progn
+                 (progn                ; there's a proper :
              (goto-char (match-beginning 2)) ; just after the :
              (c-put-c-type-property (1- (point)) 'c-decl-end)
              t)
@@ -5950,7 +5957,7 @@
          ;; Leave the point at the end of it, but don't put any
          ;; `c-decl-end' marker.
          (goto-char kwd-end)
-         t)))
+               t))))
 
      ;; @private, @protected, @public, in Objective C, or similar.
      ((and c-opt-extra-label-key
@@ -5962,7 +5969,7 @@
       (when c-record-type-identifiers
        (c-record-ref-id (cons (match-beginning 1) (point))))
       (c-put-c-type-property (1- (point)) 'c-decl-end)
-      t)
+      (setq label-type t))
 
      ;; All other cases of labels.
      ((and c-recognize-colon-labels    ; nil for AWK and IDL, otherwise t.
@@ -6038,26 +6045,49 @@
                         (c-forward-syntactic-ws)
                         (c-forward-label nil pte start))))))))))
 
+          ;; Point is still at the beginning of the possible label construct.
+          ;; 
           ;; Check that the next nonsymbol token is ":", or that we're in one
           ;; of QT's "slots" declarations.  Allow '(' for the sake of macro
           ;; arguments.  FIXME: Should build this regexp from the language
           ;; constants.
-          (when (c-syntactic-re-search-forward
-                 "[ \t[:?;{=*/%&|,<>address@hidden" limit t t) ; not at EOB
+          (cond
+           ;; public: protected: private:
+           ((and
+             (c-major-mode-is 'c++-mode)
+             (search-forward-regexp
+              "\\=p\\(r\\(ivate\\|otected\\)\\|ublic\\)\\>[^_]" nil t)
+             (progn (backward-char)
+                    (c-forward-syntactic-ws limit)
+                    (looking-at ":\\([^:]\\|\\'\\)"))) ; A single colon.
+            (forward-char)
+            (setq label-type t))
+           ;; QT double keyword like "protected slots:" or goto target.
+           ((progn (goto-char start) nil))
+           ((when (c-syntactic-re-search-forward
+                   "[ \t\n[:?;{=*/%&|,<>address@hidden" limit t t) ; not at EOB
             (backward-char)
+              (setq label-end (point))
             (setq qt-symbol-idx
                   (and (c-major-mode-is 'c++-mode)
                        (string-match
                         "\\(p\\(r\\(ivate\\|otected\\)\\|ublic\\)\\|more\\)\\>"
                         (buffer-substring start (point)))))
             (c-forward-syntactic-ws limit)
-            (when (or (looking-at ":\\([^:]\\|\\'\\)") ; A single colon.
-                      (and qt-symbol-idx
+              (cond
+               ((looking-at ":\\([^:]\\|\\'\\)") ; A single colon.
+                (forward-char)
+                (setq label-type
+                      (if (string= "signals" ; Special QT macro
+                                   (buffer-substring-no-properties start 
label-end))
+                          'qt-1kwd-colon
+                        'goto-target)))
+               ((and qt-symbol-idx
                            (search-forward-regexp "\\=slots\\>" limit t)
                            (progn (c-forward-syntactic-ws limit)
-                                  (looking-at ":\\([^:]\\|\\'\\)")))) ; A 
single colon
-              (forward-char)           ; to after the colon.
-              t)))
+                            (looking-at ":\\([^:]\\|\\'\\)"))) ; A single colon
+                (forward-char)
+                (setq label-type 'qt-2kwds-colon)))))))
 
       (save-restriction
        (narrow-to-region start (point))
@@ -6068,6 +6098,7 @@
          (while (progn
                   (when (looking-at c-nonlabel-token-key)
                     (goto-char start)
+                    (setq label-type nil)
                     (throw 'check-label nil))
                   (and (c-safe (c-forward-sexp)
                                (c-forward-syntactic-ws)
@@ -6087,12 +6118,12 @@
 
          (c-put-c-type-property (1- (point-max)) 'c-decl-end)
          (goto-char (point-max))
-         t)))
+         )))
 
      (t
       ;; Not a label.
-      (goto-char start)
-      nil))))
+      (goto-char start)))
+    label-type))
 
 (defun c-forward-objc-directive ()
   ;; Assuming the point is at the beginning of a token, try to move




reply via email to

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