From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Alan Third Newsgroups: gmane.emacs.devel Subject: cc-mode Objective C method names Date: Wed, 1 Jan 2020 11:27:57 +0000 Message-ID: <20200101112757.GA41966@breton.holly.idiocy.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="FL5UXtIhxfXey3p5" Content-Transfer-Encoding: 8bit Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="73735"; mail-complaints-to="usenet@blaine.gmane.org" To: Emacs-Devel devel Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Jan 01 12:28:19 2020 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1imcAl-000J3D-6w for ged-emacs-devel@m.gmane.org; Wed, 01 Jan 2020 12:28:19 +0100 Original-Received: from localhost ([::1]:57716 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1imcAj-0008P8-VW for ged-emacs-devel@m.gmane.org; Wed, 01 Jan 2020 06:28:18 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:38423) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1imcAX-0008Dv-4A for emacs-devel@gnu.org; Wed, 01 Jan 2020 06:28:06 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1imcAU-00017p-VV for emacs-devel@gnu.org; Wed, 01 Jan 2020 06:28:04 -0500 Original-Received: from mail-wr1-x435.google.com ([2a00:1450:4864:20::435]:38670) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1imcAU-00014a-M7 for emacs-devel@gnu.org; Wed, 01 Jan 2020 06:28:02 -0500 Original-Received: by mail-wr1-x435.google.com with SMTP id y17so36863641wrh.5 for ; Wed, 01 Jan 2020 03:28:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20161025; h=sender:date:from:to:subject:message-id:mime-version :content-disposition:content-transfer-encoding; bh=cd4a2c4iVUqgBx+fujd0vUF9Fi+GHbX4MfBHsE1Yyj8=; b=vcUXQN6MzjQtL8lKb6skGtxUSkCorStOz/d9EBx54rfVsE/bTVaozNVf4lgFghUfPT Do8PU6o1c/B6nkF/D3YnIp+Gc5S+lnfxLQVqytNHFLuDLfyCRXDmslZrXV85e2r86iP7 a7oGjknFDemh1HWDJAfzyFfvWjpQGegODH+RfN/CTccNBLgeJ/SRF5iZ2gHS0RTxLuY/ u8Dqhp3MeiJpfsw20f/SQRt3+xlWrKFIQIwJhpxPyyqflXKUbNjb983cHB0TIP0o9n1l zMvbuAOURk4SjdsXocC9oDYl9lY+yryAImGQuXk9UXPseQvxQyFvKscgM7c9DxKOhKeX qCzA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:subject:message-id :mime-version:content-disposition:content-transfer-encoding; bh=cd4a2c4iVUqgBx+fujd0vUF9Fi+GHbX4MfBHsE1Yyj8=; b=VKPR1XYpHzB1WkWMjVzRkHdpW180FjmpqMrNxfWloPzFVL9MFcLLJovdlvPIHzgUv2 MCEKXgaURAWIIC5ZR9b9ovhyhah9ouSMHgyQ44adFwPvLEgmILVyMBNZ1HHUpYGoz5+y 7ui3Rla6ibtHbIna2rA7SNQXmXraYb7Hcc7+yNkZJTVZAA6YHN4ATy2cjmrATXi5YHdG pr6luAlyJN+H5C+xcgBbbamVckmRz/9yUQoVKOaADC7gegLNiTNnMGVfqhM+vK7DlK/5 a7sLgigxg0cZbFS5RJOqEnEA9b8l2QzeKofLskGS7GlkWinPBo2JdXSU0OhzH9IJlz5G 9FSw== X-Gm-Message-State: APjAAAXqFCb45RrhfAXrfXbMyZ81lmUDyYIYnke5tvcjLqPEQgnTKLb6 vQOaMJFpAfhmobEb3dm3kmrmF/6BxFg= X-Google-Smtp-Source: APXvYqyn3nL4hR5E+haUZk03wIbAZ2cs/5aNrzVyb1Hb8GqZA4GZBye/j1LaDa5MEeTX54uwC02sXw== X-Received: by 2002:adf:f18b:: with SMTP id h11mr73898863wro.56.1577878080810; Wed, 01 Jan 2020 03:28:00 -0800 (PST) Original-Received: from breton.holly.idiocy.org (ip6-2001-08b0-03f8-8129-5065-467f-7969-bf01.holly.idiocy.org. [2001:8b0:3f8:8129:5065:467f:7969:bf01]) by smtp.gmail.com with ESMTPSA id f1sm53228224wrp.93.2020.01.01.03.27.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Jan 2020 03:28:00 -0800 (PST) Content-Disposition: inline X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::435 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:243829 Archived-At: --FL5UXtIhxfXey3p5 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit One small annoyance I’ve had with developing Emacs is that the helpers for filling in the changelog entries don’t work with Objective C methods. I’ve tried writing a patch to make it work. For reference, an Objective C class looks something like: @implementation ClassName - (int)doSomething { /* do that something */ return 1; } - (void)doSomethingTo: (SomeClass *)object with: (int)someParam { return; } @end And I think the methods’ names should be written something like: -[ClassName doSomething] -[ClassName doSomethingTo:with:] The ‘-’ means it’s an instance method and a ‘+’ would mean it was a class method. It appears to work for me, but I’m not great at Emacs lisp so I thought it best to run this by the mailing list in case I’ve made any boneheaded errors. Thanks! -- Alan Third --FL5UXtIhxfXey3p5 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="0001-Add-ability-to-find-ObjC-method-names.patch" >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 --FL5UXtIhxfXey3p5--