jacktasia / dumb-jump

an Emacs "jump to definition" package for 50+ languages
GNU General Public License v3.0
1.57k stars 150 forks source link

jump function doesn't respect a module name #409

Open achempion opened 2 years ago

achempion commented 2 years ago

I have a simple example file.ex

defmodule Module1 do
  def create do
  end
end

defmodule Module2 do
  def create do
  end
end

defmodule Module3 do
  def create do
  end
end

Module1.create()

When I point cursor to the last line on create function and press M-., I get prompt with three suggestions

/path/to/file.ex
12:   def create do
 7:   def create do
 2:   def create do

It seems dumb-jump ignores the module name when searching for definition.


dumb-jump version: 20211018.1545 emacs version: 28.0.90 (9.0)

init.el

(dumb-jump-mode)
(add-hook 'xref-backend-functions #'dumb-jump-xref-activate)
phikal commented 2 years ago

Well yes, dumb-jump generates a regular expression from a database that is passed to a grep-like program. For the case of elixir, these are the rules it uses. The "dumb" comes preciesly from a lack of a semantical understanding of the text that is being searched.

Also, you don't have to activate both dumb-jump-mode and add dumb-jump-xref-activate to xref-backend-functions. The former just binds the legacy commands, that are (officially) superceeded by the Xref interface.

achempion commented 2 years ago

Nice, thank you for the response. Could I take a look into modifying those regexps in order to make them "smarter" or you want to keep them as is?

phikal commented 2 years ago

Boris Kuznetsov @.***> writes:

Nice, thank you for the response. Could I take a look into modifying those regexps in order to make them "smarter" or you want to keep them as is?

I don't see why not (provided the implementation is sane and you extend the tests with positive and negative cases), but it's not up to me to decide.

-- Philip Kaludercic