summaryrefslogtreecommitdiff
path: root/lisp/progmodes/cc-cmds.el
diff options
context:
space:
mode:
authorAlan Third <alan@idiocy.org>2019-12-30 16:38:47 +0000
committerAlan Third <alan@idiocy.org>2020-01-18 15:35:17 +0000
commit1787b86b89b8973151980cbef115a6584f477509 (patch)
tree7730fee3fd2ae993ade7296f2cee502a9d1143e8 /lisp/progmodes/cc-cmds.el
parent1e291a05f3603ef86ba3666dfdffd1159a36e8cf (diff)
downloademacs-1787b86b89b8973151980cbef115a6584f477509.tar.gz
emacs-1787b86b89b8973151980cbef115a6584f477509.tar.bz2
emacs-1787b86b89b8973151980cbef115a6584f477509.zip
Add ability to find ObjC method names
* lisp/progmodes/cc-cmds.el (c-defun-name-1): Add Objective-C method name ability.
Diffstat (limited to 'lisp/progmodes/cc-cmds.el')
-rw-r--r--lisp/progmodes/cc-cmds.el17
1 files changed, 17 insertions, 0 deletions
diff --git a/lisp/progmodes/cc-cmds.el b/lisp/progmodes/cc-cmds.el
index 1071191775b..da614d77b53 100644
--- a/lisp/progmodes/cc-cmds.el
+++ b/lisp/progmodes/cc-cmds.el
@@ -2024,6 +2024,23 @@ other top level construct with a brace block."
(c-backward-syntactic-ws)
(point))))
+ ((and (c-major-mode-is 'objc-mode) (looking-at "[-+]\\s-*(")) ; Objective-C method
+ ;; Move to the beginning of the method name.
+ (c-forward-token-2 2 t)
+ (let* ((class
+ (save-excursion
+ (when (re-search-backward
+ "^\\s-*@\\(implementation\\|class\\|interface\\)\\s-+\\(\\sw+\\)" nil t)
+ (match-string-no-properties 2))))
+ (limit (save-excursion (re-search-forward "[;{]" nil t)))
+ (method (when (re-search-forward "\\(\\sw+:?\\)" limit t)
+ (match-string-no-properties 1))))
+ (when (and class method)
+ ;; Add the parameter labels onto name. They always end in ':'.
+ (while (re-search-forward "\\(\\sw+:\\)" limit 1)
+ (setq method (concat method (match-string-no-properties 1))))
+ (concat "[" class " " method "]"))))
+
(t ; Normal function or initializer.
(when (looking-at c-defun-type-name-decl-key) ; struct, etc.
(goto-char (match-end 0))