[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Xref completion
From: |
William Xu |
Subject: |
Re: Xref completion |
Date: |
Wed, 18 Nov 2020 08:35:58 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/27.1 (darwin) |
Dmitry Gutov <dgutov@yandex.ru> writes:
> On 17.11.2020 23:16, William Xu wrote:
>> (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))))
>
> A solid try, but note you might have a problem when there are several
> matches in the same file: you won't be able to navigate to any but the
> first one.
>
> Of course, depending on your current programming language, this might
> be not important.
In that case, we can just prepend the line and summary in front of the
filename?
(defun my-xref--show-defs-minibuffer (fetcher alist)
(let* ((xrefs (funcall fetcher))
(xref-alist (xref--analyze xrefs))
xref-alist-with-line-info
xref)
(cl-loop for ((group . xrefs) . more1) on xref-alist
do
(cl-loop for (xref . more2) on xrefs do
(with-slots (summary location) xref
(let ((line (xref-location-line location)))
(push (cons (format "%d: %s %s" line summary group)
xref)
xref-alist-with-line-info)))))
(setq xref (if (not (cdr xrefs))
(car xrefs)
(cdr (assoc (completing-read "Jump to definition: "
xref-alist-with-line-info)
xref-alist-with-line-info))))
(xref-pop-to-location xref (assoc-default 'display-action alist))))
--
William
- Xref completion, Pierre Neidhardt, 2020/11/17
- Re: [SPAM UNSURE] Xref completion, Stephen Leake, 2020/11/17
- Re: Xref completion, Eli Zaretskii, 2020/11/17
- Re: Xref completion, Juri Linkov, 2020/11/17
- Re: Xref completion, Dmitry Gutov, 2020/11/17
- Re: Xref completion, William Xu, 2020/11/17
- Re: Xref completion, Dmitry Gutov, 2020/11/17
- Re: Xref completion,
William Xu <=
- Re: Xref completion, Dmitry Gutov, 2020/11/18
- Re: Xref completion, William Xu, 2020/11/18
- Re: Xref completion, Dmitry Gutov, 2020/11/18
- Re: Xref completion, Juri Linkov, 2020/11/18
- Re: Xref completion, Dmitry Gutov, 2020/11/18
- Re: Xref completion, João Távora, 2020/11/18
- Re: Xref completion, Dmitry Gutov, 2020/11/18
- Re: Xref completion, William Xu, 2020/11/19
- Re: Xref completion, Dmitry Gutov, 2020/11/19