From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.bugs Subject: bug#36678: 27.0.50; imenu not working in C++ (maybe because of namespace) Date: Fri, 2 Aug 2019 19:33:15 +0000 Message-ID: <20190802193315.GC11966__19257.0704895601$1564774523$gmane$org@ACM> References: <20190717163427.18177.qmail@mail.muc.de> <20190731155610.x33urisumbblyryu@Ergus> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="173974"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Mutt/1.10.1 (2018-07-13) Cc: 36678@debbugs.gnu.org To: Ergus Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Aug 02 21:35:18 2019 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1htdKg-000j8r-1X for geb-bug-gnu-emacs@m.gmane.org; Fri, 02 Aug 2019 21:35:18 +0200 Original-Received: from localhost ([::1]:37184 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1htdKf-0006hv-2T for geb-bug-gnu-emacs@m.gmane.org; Fri, 02 Aug 2019 15:35:17 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:49252) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1htdJU-0005yZ-UE for bug-gnu-emacs@gnu.org; Fri, 02 Aug 2019 15:34:06 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1htdJT-00050E-3x for bug-gnu-emacs@gnu.org; Fri, 02 Aug 2019 15:34:04 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:48941) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1htdJR-0004wP-Nc; Fri, 02 Aug 2019 15:34:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1htdJR-0001a6-II; Fri, 02 Aug 2019 15:34:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Alan Mackenzie Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org, bug-cc-mode@gnu.org Resent-Date: Fri, 02 Aug 2019 19:34:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 36678 X-GNU-PR-Package: emacs,cc-mode Original-Received: via spool by 36678-submit@debbugs.gnu.org id=B36678.15647744026027 (code B ref 36678); Fri, 02 Aug 2019 19:34:01 +0000 Original-Received: (at 36678) by debbugs.gnu.org; 2 Aug 2019 19:33:22 +0000 Original-Received: from localhost ([127.0.0.1]:57762 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1htdIo-0001Z8-GX for submit@debbugs.gnu.org; Fri, 02 Aug 2019 15:33:22 -0400 Original-Received: from colin.muc.de ([193.149.48.1]:39560 helo=mail.muc.de) by debbugs.gnu.org with smtp (Exim 4.84_2) (envelope-from ) id 1htdIm-0001Yz-MZ for 36678@debbugs.gnu.org; Fri, 02 Aug 2019 15:33:21 -0400 Original-Received: (qmail 59201 invoked by uid 3782); 2 Aug 2019 18:40:45 -0000 Original-Received: from acm.muc.de (p4FE15FF0.dip0.t-ipconnect.de [79.225.95.240]) by colin.muc.de (tmda-ofmipd) with ESMTP; Fri, 02 Aug 2019 20:40:44 +0200 Original-Received: (qmail 17243 invoked by uid 1000); 2 Aug 2019 19:33:15 -0000 Content-Disposition: inline In-Reply-To: <20190731155610.x33urisumbblyryu@Ergus> X-Delivery-Agent: TMDA/1.1.12 (Macallan) X-Primary-Address: acm@muc.de X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:164386 Archived-At: Hello, Ergus. On Wed, Jul 31, 2019 at 17:56:13 +0200, Ergus wrote: > Hi Alan: > Sorry for the long delay replying this. No problem! > I have been thinking on this for a while because this issue affects me > constantly as I use most of the time C++ now. I've actually spent some time on this. What I now have is the ability of imenu to find functions, even when they are not at column zero, and to record the enclosing namespace/class/etc. of these functions. On M-x imenu , which lists all found functions (more or less), the namespace/class bit only gets displayed as needed to distinguish from other functions of the same name. The above is a bit of an exaggeration: it is not yet clean or robust code, and hasn't been tested much, but does sort of work on the files I've tried it on. What is still missing is a scanning of a function's parameters, needed to distinguish, say, a constructor with two parameters from the same with none. This is still looking a bit tricky. > Maybe this is a stupid suggestion, but I was thinking that if the issue > is performance (for ii) we could add a special function to implement the > expensive part for the functional search in C and use the C regexps. At the moment, the scanning of these C++ files is taking a small number of seconds on my (pretty fast) Ryzen machine. This is slow for imenu. I can't honestly see how we might use a C function to speed all this up. Currently, my new code is just using (c-beginning-of-defun -1) to find the next function, thus avoiding the need to write reams of syntactical analysis code, but not being fast. > Maybe it could be restrictive somehow, but if this solves a problem, > could be good enough and important for C++-mode. Because namespace use > is becoming more and more extended in C++ with the new standards. And > the most common indentations are the > Probably: > 1) For example it could do a first filtration for the buffer in a C > function using C regexp (with fake positives) and then filter again in > the Lisp side? > 2) Or, we could just iterate the file by lines in C and then modify the > regex for the next line conditionally (which is cheaper than in > Lisp). This could create a list in C that we can then use in the Lisp > side more efficiently. All this might be workable, I just don't know. But it would probably make sense to write it in Lisp first, and only then optimise it with C if it really is too slow. > In case we figure out a nice method for that. Does it makes sense? [ .... ] -- Alan Mackenzie (Nuremberg, Germany).