bug#81624: New command: xref-find-by-kind
João Távora <[email protected]>
| Newsgroups | gmane.emacs.bugs |
|---|---|
| Message-ID | <[email protected]> |
Dmitry Gutov <[email protected]> writes: > Regarding obarray, I think you're either describing a caching scheme > (indefinite or timed) or a more complex return value for > xref-backend-xref-kinds. The latter. But sort of simpler, not more complex. To illustrate, in Common Lisp, a dedicated package could hold the handful of kind symbols. So the database lives there instead of a list of plists. (defpackage :eglot-kinds (:export "DECLARATION" "IMPLEMENTATION" "TYPE-DEFINITION")) (in-package :eglot-kinds) (cl:setf (cl:get 'declaration 'xref-kind) '(:name "declaration" :key #\c) (cl:get 'type-definition 'xref-kind) '(:name "type definition" :key #\t) (cl:get 'implementation 'xref-kind) '(:name "implementation" :key #\i)) (in-package :eglot) (defmethod xref:xref-kinds ((backend (eql :eglot))) (find-package "EGLOT-KINDS")) (defun eglot:find-type-definition (identifier) (interactive (xref:read-identifier "Find declarations of")) (xref:find-by-kind identifier 'eglot-kinds:declaration)) ... You get the idea... You can do this mostly in Elisp if you really want to, but I admit it's a bit awkward, because there's no named obarrays and no read syntax for them. So the elegant last line would become an odd intern-soft with an extra arg. Now that I think of it, not sure the Elisp version really avoids your "coin-flip" problem, because intern-soft does a runtime lookup anyway, whereas in CL that job is done at read-time and the right symbol reference is already compiled in. Anyway, this is just academic, these lookups are super cheap, don't do it :-) João