[Top][All Lists]

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

Re: Consistency for xref-show-{xrefs,definitions}-function

From: Dmitry Gutov
Subject: Re: Consistency for xref-show-{xrefs,definitions}-function
Date: Sat, 16 Jan 2021 21:24:12 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0

On 16.01.2021 20:35, Gabriel do Nascimento Ribeiro wrote:

My use case is: when inside a project, the only option to jump to a
certain location is by using 'C-x p g' (which runs 'xref--show-xrefs')
and selecting the desired location from the list of matches in a
separated buffer. I would like to be able to select a single element
from this list of matches, preferably with 'completing-read'.

All right. Is that location a certain symbol's definition, or just some special location that can only be found by a grep search?

I took another look in the code, so I guess we can keep the xrefs
functions as it is and tweak 'project-find-regexp' to be more flexible
on this.

But you still use project-find-regexp for its "normal" purpose, too, right? That is, finding all occurrences of a certain regexp. Maybe to rename all occurrences of a symbol, etc.

To only change its behavior in specific situations, you can add a new command to your init script and bind it to a key. The code can look like:

(defun project-find-regexp-and-jump ()
  ;; Or use a particular function name here directly.
  (let ((xref-show-xrefs-function xref-show-definitions-function))
    (call-interactively #'project-find-regexp)))

Other suggestions welcome, of course.

reply via email to

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