emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: xref backends for elisp-related modes Was: Re: Bad moves with xref-f


From: Dmitry Gutov
Subject: Re: xref backends for elisp-related modes Was: Re: Bad moves with xref-find-definitions
Date: Sun, 26 Apr 2015 16:56:43 +0300
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:36.0) Gecko/20100101 Thunderbird/36.0

On 04/26/2015 02:51 PM, address@hidden (João Távora) wrote:

BTW the necessary level of indirection is already present with
`advice-add': we needn't necessarily add more variables. I mean:

    (advice-add 'elisp-xref-find :override #'etags-xref-find)

Looks good enough to me. Indeed, maybe xref-etags-mode should be replaced by a function that applies these advices.

Should be enough and quite readable. Conversely, I wouldn't be very
annoyed if etags were the default method of finding elisp xrefs. Then I
would use advice-add to set my behaviour, perhaps by doing

I think elisp-xref-find is a better default.

    (advice-add 'elisp-xref-find :override
    #'elisp-compiled-identifier-locations) ; better name pending

This cannot be done globally (or it'll affect all buffers).

Additionally, if `add-function' allowed `:append' for its WHERE arg,
like Common Lisp's method combinations, it would be even cleaner to get
the behaviour desired by Eli (and Vitalie, I think), of multiple
backends.

    (advice-add 'elisp-xref-find :append #'etags-xref-find)

a: If we want it to do appending, that could be implemented in `elisp-xref-find'. Or there could be a variant of it doing that.

b: This doesn't deal with duplicates, which I think is the main problem if we were to go that way.

It does, I know, but it would be a lot simpler, especially for functions
spawning *Help* buffers, to just assume we're in an elisp-related
context. Packages like SLIME or SLY or CIDER that make use of these
major modes should be the ones overriding the backend.

Can we be sure that languages using the default backend (etags) and expecting it to work in their help buffers, will be a negligible minority?

+(defun elisp--setup-xref-backend ()
+  (setq-local xref-find-function #'elisp-xref-find)
+  (setq-local xref-identifier-completion-table-function
+              #'elisp--xref-identifier-completion-table))

Shouldn't this also include the dynamic declarations removed from `emacs-lisp-mode'?



reply via email to

[Prev in Thread] Current Thread [Next in Thread]