]> git.eshelyaron.com Git - emacs.git/commitdiff
(c-defun-name): Make it work for "struct foo bar [] = { ...".
authorAlan Mackenzie <acm@muc.de>
Fri, 17 Oct 2008 20:24:45 +0000 (20:24 +0000)
committerAlan Mackenzie <acm@muc.de>
Fri, 17 Oct 2008 20:24:45 +0000 (20:24 +0000)
lisp/progmodes/cc-cmds.el

index 8a51ca81cfae3286ef77f9ee7082aa1043d734cb..8e7df4c95a69db4ee683abfa6323efdff3c16a5c 100644 (file)
@@ -1704,17 +1704,16 @@ with a brace block."
 
        ;; Pick out the defun name, according to the type of defun.
        (cond
+         ;; struct, union, enum, or similar:
         ((and (looking-at c-type-prefix-key)
               (progn (c-forward-token-2 2) ; over "struct foo "
-                     (eq (char-after) ?\{)))
-         ;; struct, union, enum, or similar:
-         (c-backward-syntactic-ws)
-         (setq name-end (point))
-         (buffer-substring-no-properties
-          (progn
-            (c-backward-token-2 2)
-            (point))
-          name-end))
+                     (or (eq (char-after) ?\{)
+                         (looking-at c-symbol-key)))) ; "struct foo bar ..."
+         (save-match-data (c-forward-token-2))
+         (when (eq (char-after) ?\{)
+           (c-backward-token-2)
+           (looking-at c-symbol-key))
+         (match-string-no-properties 0))
 
         ((looking-at "DEFUN\\_>")
          ;; DEFUN ("file-name-directory", Ffile_name_directory, Sfile_name_directory, ...) ==> Ffile_name_directory