Wilfred / elisp-def

Find Emacs Lisp definitions
64 stars 6 forks source link

Integration with elisp-mode #1

Open monnier opened 6 years ago

monnier commented 6 years ago

Any chance this could be integrated with elisp-mode's xref support rather than replacing it?

dgutov commented 6 years ago

It shouldn't be too hard either: a lot of necessary code for detecting the current symbol's type is already there (used now for completion).

One part where I'm not sure about, though, is how to reconcile the auto-detection of the symbol's type with reading its name with completion (which we do even for xref-find-definitions, in certain non-default configurations).

Wilfred commented 6 years ago

Hi Stefan! I'm flattered you're trying my package :)

Sorry I didn't respond before: turns out that new GitHub projects don't have the creator watching the repo by default.

elisp-def goes a lot further than elisp-mode for detecting the type of a symbol. It handles anaphora, local variables and docstring references, amongst other things (see the readme for the full list).

The macro expansion and AST walking are sufficiently non-trivial that I wanted to get a good test suite and some users to shake out the bugs.

I'd be willing to look at moving this to elisp-mode in a few months, but I'd like it to have more time baking first :)

alphapapa commented 3 years ago

Hi Wilfred,

Having rediscovered this package, I'm curious: do you still plan to look into integrating this into Emacs someday? It looks very useful, but it would be easier to integrate it into users' workflows if it were part of, e.g. xref rather than a separate package that must be discovered, installed, bound, and remembered. :)

Mihara commented 2 years ago

Seconding this. It would be a lot more convenient to use if it could integrate into xref as a backend rather than override the keybinding with itself.

monnier commented 2 years ago

@Wilfred: There might be a misunderstanding. I did not suggest to integrate this code into elisp-mode.el or into Emacs (it's probably not a bad idea either, but I must admit I haven't thought about how this would go). Instead, I'm suggesting you change your package such that it presents itself as an Xref backend.

More concretely it means your package would do something like

(add-hook 'emacs-lisp-mode-hook #'elisp-def--setup)
(defun elisp-def--setup ()
  (add-hook 'xref-backend-functions #'elisp-def--xref-backend nil t))
(defun elisp-def--xref-backend () 'elisp-def)

And then

(cl-defmethod xref-backend-definitions (_ (eql elisp-def) id) ...)
(cl-defmethod xref-backend-references (_ (eql elisp-def) id) ...)
...

-- Stefan