unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Visuwesh <visuweshm@gmail.com>
To: Dmitry Gutov <dgutov@yandex.ru>
Cc: Tom Tromey <tom@tromey.com>, 28407@debbugs.gnu.org
Subject: bug#28407: 26.0.50; xref should use imenu
Date: Sun, 15 May 2022 18:02:14 +0530	[thread overview]
Message-ID: <87y1z35630.fsf@gmail.com> (raw)
In-Reply-To: <3238a206-240a-aa76-87c0-bcb3bdfa00dc@yandex.ru> (Dmitry Gutov's message of "Mon, 11 Sep 2017 00:35:56 +0300")

[-- Attachment #1: Type: text/plain, Size: 2211 bytes --]

[திங்கள் செப்டம்பர் 11, 2017] Dmitry Gutov wrote:

> On 9/10/17 7:23 PM, Tom Tromey wrote:
>> It would be nice if imenu were a back end for xref.
>> Then M-. could also use symbols found by imenu.
>> A further wrinkle on this would be if xref, project, and imenu
>> worked
>> together, so that M-. would automatically know to look at imenu results
>> for other buffers in the same project.
>
> Agreed. It could be a nice default for when no tags table is currently
> visited.

I tried to write a general imenu backend in attached file (extracted
from my init.el) but I hit quite a few roadblocks,

  1. I activate the imenu backend iff there are no tags table defined
     for the buffer but this means that one cannot use the imenu
     backend to jump to definitions for symbols that TAGS do not know
     of currently.  I can think of two ways to solve this problem,

     (a) Check if the symbol is in TAGS table.
     (b) Modify the etags backend so that the user can say "I have no
     TAGS table for this file/project/whatever."

     (a) is definitely not clean, and (b) sounds feasible but similar
     situation can also exist with other backends (like elisp).

     I'm lost on how to solve this problem.

  2. I have not defined all the methods and the completion-table does
     not handle the nested case of the index alist.  AFAIU from `(elisp)
     Programmed Completion', completion "ends" when `try-completion'
     returns t but I seem to be mistaken.  I have to rewrite
     completion-table to be like `imenu--completion-buffer' but I don't
     know how to pull that off.

  3. `imenu-xref--in-alist' is mostly a 1-1 copy of `imenu--in-alist'
     with the only difference being my function returns all matches of
     the symbol instead of just the first one.  This should be easy
     enough to fix by adding an optional argument INCLUDE-ALL to
     `imenu--in-alist'.

I'm testing in python-mode with the following settings,

    (setq imenu-name-lookup-function (lambda (symbol item) (string-prefix-p symbol item))
          python-imenu-format-parent-item-jump-label-function (lambda (_ name) name))


[-- Attachment #2: imenu-xref.el --]
[-- Type: application/emacs-lisp, Size: 3130 bytes --]

  reply	other threads:[~2022-05-15 12:32 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-10 16:23 bug#28407: 26.0.50; xref should use imenu Tom Tromey
2017-09-10 21:35 ` Dmitry Gutov
2022-05-15 12:32   ` Visuwesh [this message]
2022-05-16  6:59     ` Visuwesh
2022-05-29 22:13       ` Dmitry Gutov
2022-05-30  4:18         ` Visuwesh
2022-06-04  0:56           ` Dmitry Gutov
2022-06-25 14:04             ` Visuwesh
2022-06-25 14:19               ` Eli Zaretskii
2022-06-25 14:37                 ` Visuwesh
2022-06-25 15:14                   ` Eli Zaretskii

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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=87y1z35630.fsf@gmail.com \
    --to=visuweshm@gmail.com \
    --cc=28407@debbugs.gnu.org \
    --cc=dgutov@yandex.ru \
    --cc=tom@tromey.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 public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).