all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Alan Mackenzie <acm@muc.de>
To: Ergus <spacibba@aol.com>
Cc: 36678@debbugs.gnu.org
Subject: bug#36678: 27.0.50; imenu not working in C++ (maybe because of namespace)
Date: Fri, 2 Aug 2019 19:33:15 +0000	[thread overview]
Message-ID: <20190802193315.GC11966__19257.0704895601$1564774523$gmane$org@ACM> (raw)
In-Reply-To: <20190731155610.x33urisumbblyryu@Ergus>

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 <tab>, 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).





  reply	other threads:[~2019-08-02 19:33 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-15 20:33 bug#36678: 27.0.50; imenu not working in C++ (maybe because of namespace) Ergus
     [not found] ` <mailman.1463.1563222851.2688.bug-gnu-emacs@gnu.org>
2019-07-17 14:39   ` Alan Mackenzie
2019-07-17 16:34   ` Alan Mackenzie
2019-07-31 15:56     ` Ergus
2019-08-02 19:33       ` Alan Mackenzie [this message]
     [not found]       ` <20190802193315.GC11966@ACM>
2019-08-02 19:56         ` Paul Smith
2019-08-03  2:25           ` Richard Stallman
2019-08-03 11:27           ` Alan Mackenzie
2019-08-03 15:09             ` Paul Smith
2019-08-04  3:01               ` Richard Stallman
2019-08-04 13:56                 ` Paul Smith
2019-08-05  2:25                   ` Richard Stallman
2019-08-04  2:56             ` Richard Stallman
2019-08-04  8:51               ` Alan Mackenzie
2019-08-05  2:26                 ` Richard Stallman
     [not found]           ` <E1htjjb-0002eO-Fo@fencepost.gnu.org>
2019-08-03  7:20             ` Eli Zaretskii
2019-08-03 14:43             ` Paul Smith
2019-08-05  2:24               ` Richard Stallman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='20190802193315.GC11966__19257.0704895601$1564774523$gmane$org@ACM' \
    --to=acm@muc.de \
    --cc=36678@debbugs.gnu.org \
    --cc=spacibba@aol.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.