aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlan Mackenzie2017-07-12 20:15:56 +0000
committerAlan Mackenzie2017-07-12 20:15:56 +0000
commitdde7f2d48b53996bdf767a8cf91aafc2e10add23 (patch)
tree71e845fc55e94a5c3e5448312d006cd9440cc26e
parent7dd72d76effad5198c0d43a2b68aafbfe34b5ee7 (diff)
downloademacs-dde7f2d48b53996bdf767a8cf91aafc2e10add23.tar.gz
emacs-dde7f2d48b53996bdf767a8cf91aafc2e10add23.zip
Fix some bugs in c-defun-name. This fixes bug #25623.
* lisp/progmodes/cc-cmds.el (c-defun-name): Fix some bugs to do with structs, etc.
-rw-r--r--lisp/progmodes/cc-cmds.el27
1 files changed, 17 insertions, 10 deletions
diff --git a/lisp/progmodes/cc-cmds.el b/lisp/progmodes/cc-cmds.el
index 121ba24f090..dec59c58090 100644
--- a/lisp/progmodes/cc-cmds.el
+++ b/lisp/progmodes/cc-cmds.el
@@ -1843,19 +1843,25 @@ with a brace block."
1843 (unless (eq where 'at-header) 1843 (unless (eq where 'at-header)
1844 (c-backward-to-nth-BOF-{ 1 where) 1844 (c-backward-to-nth-BOF-{ 1 where)
1845 (c-beginning-of-decl-1)) 1845 (c-beginning-of-decl-1))
1846 (when (looking-at c-typedef-key)
1847 (goto-char (match-end 0))
1848 (c-forward-syntactic-ws))
1846 1849
1847 ;; Pick out the defun name, according to the type of defun. 1850 ;; Pick out the defun name, according to the type of defun.
1848 (cond 1851 (cond
1849 ;; struct, union, enum, or similar: 1852 ;; struct, union, enum, or similar:
1850 ((and (looking-at c-type-prefix-key) 1853 ((looking-at c-type-prefix-key)
1851 (progn (c-forward-token-2 2) ; over "struct foo " 1854 (let ((key-pos (point)))
1852 (or (eq (char-after) ?\{) 1855 (c-forward-token-2 1) ; over "struct ".
1853 (looking-at c-symbol-key)))) ; "struct foo bar ..." 1856 (cond
1854 (save-match-data (c-forward-token-2)) 1857 ((looking-at c-symbol-key) ; "struct foo { ..."
1855 (when (eq (char-after) ?\{) 1858 (buffer-substring-no-properties key-pos (match-end 0)))
1856 (c-backward-token-2) 1859 ((eq (char-after) ?{) ; "struct { ... } foo"
1857 (looking-at c-symbol-key)) 1860 (when (c-go-list-forward)
1858 (match-string-no-properties 0)) 1861 (c-forward-syntactic-ws)
1862 (when (looking-at c-symbol-key) ; a bit bogus - there might
1863 ; be several identifiers.
1864 (match-string-no-properties 0)))))))
1859 1865
1860 ((looking-at "DEFUN\\s-*(") ;"DEFUN\\_>") think of XEmacs! 1866 ((looking-at "DEFUN\\s-*(") ;"DEFUN\\_>") think of XEmacs!
1861 ;; DEFUN ("file-name-directory", Ffile_name_directory, Sfile_name_directory, ...) ==> Ffile_name_directory 1867 ;; DEFUN ("file-name-directory", Ffile_name_directory, Sfile_name_directory, ...) ==> Ffile_name_directory
@@ -1900,7 +1906,8 @@ with a brace block."
1900 (c-backward-syntactic-ws)) 1906 (c-backward-syntactic-ws))
1901 (setq name-end (point)) 1907 (setq name-end (point))
1902 (c-back-over-compound-identifier) 1908 (c-back-over-compound-identifier)
1903 (buffer-substring-no-properties (point) name-end))))))))) 1909 (and (looking-at c-symbol-start)
1910 (buffer-substring-no-properties (point) name-end))))))))))
1904 1911
1905(defun c-declaration-limits (near) 1912(defun c-declaration-limits (near)
1906 ;; Return a cons of the beginning and end positions of the current 1913 ;; Return a cons of the beginning and end positions of the current