emacs-devel
[Top][All Lists]
Advanced

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

Re: Xref completion


From: William Xu
Subject: Re: Xref completion
Date: Tue, 17 Nov 2020 22:16:56 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (darwin)

Juri Linkov <juri@linkov.net> writes:

>> In particular, I've overridden the behaviour with regards to Xrefs and
>> instead of showing the Xref buffer, I'm now offering completion: the
>> user can match against the symbol but also against the file and line
>> position.
>
> It seems this should be possible by customizing the value of
> xref-show-definitions-function to a function that would redirect
> a list of found results to completing-read.

Wow, that is a life saver.

(defun my-xref--show-defs-minibuffer (fetcher alist)
  (let* ((xrefs (funcall fetcher))
         (xref-alist (xref--analyze xrefs))
         (xref (if (not (cdr xrefs))
                   (car xrefs)
                 (cadr (assoc (completing-read "Jump to definition: " 
xref-alist)
                              xref-alist)))))
    (xref-pop-to-location xref (assoc-default 'display-action alist))))

(setq xref-show-definitions-function 'my-xref--show-defs-minibuffer)

-- 
William




reply via email to

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