>From 2945f1c6c57eeabdbeb8e7c058070587a9bf4c0a Mon Sep 17 00:00:00 2001 From: Alan Third Date: Mon, 30 Dec 2019 16:38:47 +0000 Subject: [PATCH] Add ability to find ObjC method names * lisp/progmodes/cc-cmds.el (c-defun-name-1): Add Objective-C method name ability. --- lisp/progmodes/cc-cmds.el | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/lisp/progmodes/cc-cmds.el b/lisp/progmodes/cc-cmds.el index 0343f9df32..9165398132 100644 --- a/lisp/progmodes/cc-cmds.el +++ b/lisp/progmodes/cc-cmds.el @@ -2024,6 +2024,36 @@ c-defun-name-1 (c-backward-syntactic-ws) (point)))) + ((looking-at "[-+]\\s-*(") ; Objective-C method + (let ((class + (save-excursion + (re-search-backward "@\\(implementation\\|class\\|interface\\)") + (c-forward-token-2) + (thing-at-point 'word t))) + (type (buffer-substring-no-properties (point) (+ (point) 1))) + (name + (save-excursion + (c-forward-token-2 2 t) + (let ((name "")) + (while (not (looking-at "[{;]")) + (let ((start (point)) + (end + (progn + (c-forward-syntactic-ws) + (forward-word) + (if (looking-at ":") + (+ (point) 1) + (point))))) + (when (looking-at ":") + (c-forward-token-2) + (if (looking-at "(") + (c-forward-token-2 2 t) + (c-forward-token-2 1 t))) + (c-forward-syntactic-ws) + (setq name (concat name (buffer-substring-no-properties start end))))) + name)))) + (format "%s[%s %s]" type class name))) + (t ; Normal function or initializer. (when (looking-at c-defun-type-name-decl-key) ; struct, etc. (goto-char (match-end 0)) -- 2.24.0