aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lisp/progmodes/cc-cmds.el118
1 files changed, 60 insertions, 58 deletions
diff --git a/lisp/progmodes/cc-cmds.el b/lisp/progmodes/cc-cmds.el
index e71c5230453..1c51a4b6fd2 100644
--- a/lisp/progmodes/cc-cmds.el
+++ b/lisp/progmodes/cc-cmds.el
@@ -1687,68 +1687,70 @@ with a brace block."
1687 (beginning-of-defun-function end-of-defun-function 1687 (beginning-of-defun-function end-of-defun-function
1688 where pos name-end) 1688 where pos name-end)
1689 1689
1690 (save-excursion 1690 (save-restriction
1691 ;; Move back out of any macro/comment/string we happen to be in. 1691 (widen)
1692 (c-beginning-of-macro) 1692 (save-excursion
1693 (setq pos (c-literal-limits)) 1693 ;; Move back out of any macro/comment/string we happen to be in.
1694 (if pos (goto-char (car pos))) 1694 (c-beginning-of-macro)
1695 1695 (setq pos (c-literal-limits))
1696 (setq where (c-where-wrt-brace-construct)) 1696 (if pos (goto-char (car pos)))
1697
1698 ;; Move to the beginning of the current defun, if any, if we're not
1699 ;; already there.
1700 (if (eq where 'outwith-function)
1701 nil
1702 (unless (eq where 'at-header)
1703 (c-backward-to-nth-BOF-{ 1 where)
1704 (c-beginning-of-decl-1))
1705 1697
1706 ;; Pick out the defun name, according to the type of defun. 1698 (setq where (c-where-wrt-brace-construct))
1707 (cond
1708 ;; struct, union, enum, or similar:
1709 ((and (looking-at c-type-prefix-key)
1710 (progn (c-forward-token-2 2) ; over "struct foo "
1711 (or (eq (char-after) ?\{)
1712 (looking-at c-symbol-key)))) ; "struct foo bar ..."
1713 (save-match-data (c-forward-token-2))
1714 (when (eq (char-after) ?\{)
1715 (c-backward-token-2)
1716 (looking-at c-symbol-key))
1717 (match-string-no-properties 0))
1718
1719 ((looking-at "DEFUN\\_>")
1720 ;; DEFUN ("file-name-directory", Ffile_name_directory, Sfile_name_directory, ...) ==> Ffile_name_directory
1721 ;; DEFUN(POSIX::STREAM-LOCK, stream lockp &key BLOCK SHARED START LENGTH) ==> POSIX::STREAM-LOCK
1722 (down-list 1)
1723 (c-forward-syntactic-ws)
1724 (when (eq (char-after) ?\")
1725 (forward-sexp 1)
1726 (c-forward-token-2)) ; over the comma and following WS.
1727 (buffer-substring-no-properties
1728 (point)
1729 (progn
1730 (c-forward-token-2)
1731 (when (looking-at ":") ; CLISP: DEFUN(PACKAGE:LISP-SYMBOL,...)
1732 (skip-chars-forward "^,"))
1733 (c-backward-syntactic-ws)
1734 (point))))
1735 1699
1736 ((looking-at "DEF[a-zA-Z0-9_]* *( *\\([^, ]*\\) *,") 1700 ;; Move to the beginning of the current defun, if any, if we're not
1737 ;; DEFCHECKER(sysconf_arg,prefix=_SC,default=, ...) ==> sysconf_arg 1701 ;; already there.
1738 ;; DEFFLAGSET(syslog_opt_flags,LOG_PID ...) ==> syslog_opt_flags 1702 (if (eq where 'outwith-function)
1739 (match-string-no-properties 1)) 1703 nil
1704 (unless (eq where 'at-header)
1705 (c-backward-to-nth-BOF-{ 1 where)
1706 (c-beginning-of-decl-1))
1740 1707
1741 (t 1708 ;; Pick out the defun name, according to the type of defun.
1742 ;; Normal function or initializer. 1709 (cond
1743 (when (c-syntactic-re-search-forward "[{(]" nil t) 1710 ;; struct, union, enum, or similar:
1744 (backward-char) 1711 ((and (looking-at c-type-prefix-key)
1745 (c-backward-syntactic-ws) 1712 (progn (c-forward-token-2 2) ; over "struct foo "
1746 (when (eq (char-before) ?\=) ; struct foo bar = {0, 0} ; 1713 (or (eq (char-after) ?\{)
1714 (looking-at c-symbol-key)))) ; "struct foo bar ..."
1715 (save-match-data (c-forward-token-2))
1716 (when (eq (char-after) ?\{)
1717 (c-backward-token-2)
1718 (looking-at c-symbol-key))
1719 (match-string-no-properties 0))
1720
1721 ((looking-at "DEFUN\\_>")
1722 ;; DEFUN ("file-name-directory", Ffile_name_directory, Sfile_name_directory, ...) ==> Ffile_name_directory
1723 ;; DEFUN(POSIX::STREAM-LOCK, stream lockp &key BLOCK SHARED START LENGTH) ==> POSIX::STREAM-LOCK
1724 (down-list 1)
1725 (c-forward-syntactic-ws)
1726 (when (eq (char-after) ?\")
1727 (forward-sexp 1)
1728 (c-forward-token-2)) ; over the comma and following WS.
1729 (buffer-substring-no-properties
1730 (point)
1731 (progn
1732 (c-forward-token-2)
1733 (when (looking-at ":") ; CLISP: DEFUN(PACKAGE:LISP-SYMBOL,...)
1734 (skip-chars-forward "^,"))
1735 (c-backward-syntactic-ws)
1736 (point))))
1737
1738 ((looking-at "DEF[a-zA-Z0-9_]* *( *\\([^, ]*\\) *,")
1739 ;; DEFCHECKER(sysconf_arg,prefix=_SC,default=, ...) ==> sysconf_arg
1740 ;; DEFFLAGSET(syslog_opt_flags,LOG_PID ...) ==> syslog_opt_flags
1741 (match-string-no-properties 1))
1742
1743 (t
1744 ;; Normal function or initializer.
1745 (when (c-syntactic-re-search-forward "[{(]" nil t)
1746 (backward-char)
1747 (c-backward-syntactic-ws)
1748 (when (eq (char-before) ?\=) ; struct foo bar = {0, 0} ;
1749 (c-backward-token-2)
1750 (c-backward-syntactic-ws))
1751 (setq name-end (point))
1747 (c-backward-token-2) 1752 (c-backward-token-2)
1748 (c-backward-syntactic-ws)) 1753 (buffer-substring-no-properties (point) name-end)))))))))
1749 (setq name-end (point))
1750 (c-backward-token-2)
1751 (buffer-substring-no-properties (point) name-end))))))))
1752 1754
1753(defun c-declaration-limits (near) 1755(defun c-declaration-limits (near)
1754 ;; Return a cons of the beginning and end positions of the current 1756 ;; Return a cons of the beginning and end positions of the current