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: Re: cc-mode Objective C method names Date: Sat, 4 Jan 2020 17:09:35 +0000 Message-ID: <20200104170935.GA68892@breton.holly.idiocy.org> References: <20200101112757.GA41966@breton.holly.idiocy.org> <20200104104854.GA4009@ACM> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="x+6KMIRAuhnl3hBn" Content-Transfer-Encoding: 8bit Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="171763"; mail-complaints-to="usenet@blaine.gmane.org" Cc: Emacs-Devel devel To: Alan Mackenzie Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Jan 04 18:09:54 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 1inmvy-000iTf-85 for ged-emacs-devel@m.gmane.org; Sat, 04 Jan 2020 18:09:54 +0100 Original-Received: from localhost ([::1]:35530 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1inmvw-00089U-Dx for ged-emacs-devel@m.gmane.org; Sat, 04 Jan 2020 12:09:52 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:49975) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1inmvp-00089K-CI for emacs-devel@gnu.org; Sat, 04 Jan 2020 12:09:46 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1inmvn-0002ih-W0 for emacs-devel@gnu.org; Sat, 04 Jan 2020 12:09:45 -0500 Original-Received: from mail-wm1-x32d.google.com ([2a00:1450:4864:20::32d]:39580) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1inmvn-0002Zi-M3 for emacs-devel@gnu.org; Sat, 04 Jan 2020 12:09:43 -0500 Original-Received: by mail-wm1-x32d.google.com with SMTP id 20so11159473wmj.4 for ; Sat, 04 Jan 2020 09:09:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20161025; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to; bh=8VUNOxCtwIHP+/i4xBrnggBEv9oDHB4ccwWCmRSA9Gg=; b=aWAOjwslxef5bxggjFQYfmlM6cx4PlSjNRYbfDqjV6Zs5l/6rHFuOPteNWCXetesGq eqoN+GLqLO/ILosYfP26teJJG/2IDv9ZZ7YWyi6joE3tePw1PsSl6hyMxvPBSzj5Mnto WH+WYq/RRRj6267OKDE0+TNu15qpijETrGJII0Hxl6S7Rm/Ktm3fwHpi4FOO6i2BMwsR V5BZa5INQMQCJlMX26r2jas8qLG4emogh2K6W4UvMnm7+9n1tPNZgKqfI1unU/3t6xW1 npMvq6dtWh2lRJcbSQhKBopwsK/E1KKpq7jPmZ7m6dueI8+z2XJ5umDx6Roej38U2ZBN Quqg== 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:cc:subject:message-id :references:mime-version:content-disposition :content-transfer-encoding:in-reply-to; bh=8VUNOxCtwIHP+/i4xBrnggBEv9oDHB4ccwWCmRSA9Gg=; b=Kl3HacnTT40qNheFE6iZQ55gSOz24N2mgrwRkTSgppS4kfDqWq49x4aAGrj7qcWbUw dWjCX09HkJ7jFTFwgYc0u69Px78lBpa8TLtbvnL+mcToDSnjfwZY2LN9WeiyFgTJSZJ9 /QxGxKh6S6bAtOWHZEyvYbfV8Ytv/EuEq7IMPAlsuATNQaobIV/2pa8VITUy5N9bhbH8 dvBckSplRO+NfOPJpZ5LikKlvwfEF8+gIfMOJZOi8tGhfMSkW9cLmrfDdRoIdbsw+26p qDK/dISYRGW2gIzJZ6FCtLMDU8Egv5y8epIYb18d8PdFLlTGOgPJbba4l9ZibpOs0R47 3Egw== X-Gm-Message-State: APjAAAW1EiJCJ0GJpzNlM/HyE56TqKB+TSBtVCimZ3G2ChyE48qjfLM6 jIoGtENZ9CiTv0G5YQ62+dw= X-Google-Smtp-Source: APXvYqzqdoo4zYnqiO4cCYvxBGN5ouyZKtR08dNvue5oP6rnUcySVOYN84RUCgNoxoKI2DWMzLf5QQ== X-Received: by 2002:a05:600c:22d3:: with SMTP id 19mr24907119wmg.92.1578157781612; Sat, 04 Jan 2020 09:09:41 -0800 (PST) Original-Received: from breton.holly.idiocy.org ([2001:8b0:3f8:8129:3c68:1d99:a68c:dce7]) by smtp.gmail.com with ESMTPSA id o194sm16812761wme.45.2020.01.04.09.09.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 Jan 2020 09:09:40 -0800 (PST) Content-Disposition: inline In-Reply-To: <20200104104854.GA4009@ACM> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::32d 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:243924 Archived-At: --x+6KMIRAuhnl3hBn Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit On Sat, Jan 04, 2020 at 10:48:54AM +0000, Alan Mackenzie wrote: > Hello, Alan. > > On Wed, Jan 01, 2020 at 11:27:57 +0000, Alan Third wrote: > > 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. > > If either ClassName or doSomethingTo is long, you might be taking up too > much space on, for example, the first line of a commit message. But > you've probably already thought this through. How long are these > extended names in practice? They can be extremely long, but our code doesn’t tend to have these very long names. I’m not sure what we could do to shorten them unless we really don’t care very much about accuracy. For example we could drop the class names, but we don’t limit classes to one per file, so we can easily end up with two classes with the same method name in the same file. Alternatively we could not list the parameter labels, but we definitely have methods that only differ by their parameter lists in Emacs. FWIW, I’ve not run into any problems so far. > > 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. > > I've got just a few comments to add to Eli's and Stefan's, so .... I was working through them when I thought of a neater way to do this, but it’s probably less like the rest of the code in cc mode. Hopefully it’s OK. Patch attached. -- Alan Third --x+6KMIRAuhnl3hBn Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="v2-0001-Add-ability-to-find-ObjC-method-names.patch" >From b75a1ac30204d10f395c1885e1ad80692317c94e Mon Sep 17 00:00:00 2001 From: Alan Third Date: Mon, 30 Dec 2019 16:38:47 +0000 Subject: [PATCH v2] 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 | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/lisp/progmodes/cc-cmds.el b/lisp/progmodes/cc-cmds.el index 0343f9df32..18fb459e40 100644 --- a/lisp/progmodes/cc-cmds.el +++ b/lisp/progmodes/cc-cmds.el @@ -2024,6 +2024,23 @@ c-defun-name-1 (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)) -- 2.24.0 --x+6KMIRAuhnl3hBn--