[Top][All Lists]

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

Re: Generalizing find-definition

From: Stephen Leake
Subject: Re: Generalizing find-definition
Date: Sat, 06 Dec 2014 12:19:18 -0600
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.94 (windows-nt)

Helmut Eller <address@hidden> writes:

> On Fri, Dec 05 2014, Stephen Leake wrote:
> [...]
>> I have a function that combines 1 and 2 and similar links; it calls
>> ffap-string-at-point, compares that to an alist of (regexp . command),
>> and then defaults to find-file. The alist has:
> [...]
>> Perhaps a similar function could be included in xref?
> Just thinking aloud:
> I guess such filenames or URLs (URIs?) typically occur in comments,
> string literals, or perhaps in things like #include <stdio.h> or
> (require 'some-library).  M-x ffap seems cover this partially, but then
> there's also M-x find-library.  Certainly a lot of things to find!

I just added this for (require 'foo):

  (set (make-local-variable 'ff-search-directories) 'load-path)
  (set (make-local-variable 'ff-special-constructs) nil)
   (cons "^(require '\\(.*\\))" (lambda () (file-name-nondirectory 
(locate-library (match-string 1))))))

That's used by ff-find-other-file.

> A problem seems to be that xref-identifier-at-point would need a
> possibly complicated heuristic to determine if we are at such a filename
> or a "normal" identifier.  

Yes, I think that requires input from the user. Currently, I use C-F11
(bound to 'ff-find-other-file') when the thing at point is something
related to a filename ('require' in elisp, '#include' in C++, 'with' in
Ada), and C-c C-d (now bound to 'xref-find-definitions') when the thing
at point is a symbol.

We could just search for both, and present a list, but I think that
would be more cumbersome than it's worth.

> Maybe it's easier to have a separate xref-file-name-at-point which
> would by default do what ffap-guess-file-name-at-point does. For ELisp
> it should additionally recognize (require 'foo) and somehow reuse
> find-library.

find-file.el and files.el provide similarly customizable 'find a file'
functions. It would be nice to unify them, but that's a lot of work.

I'm most familiar with find-file, but it could easily be that files is a
better structure.

> There's also the problem which keybinding to use.  We will probably
> steal the global bindings for M-. and M-, from etags but beyond that
> we don't have keys for our commands.  At least one additional prefix key
> for a xref keymap would be nice.

ada-mode uses C-c C-o for a wrapper around ff-find-other-file. I don't
see a similar binding in c-mode.

We would probably need to keep xref-minor-mode for now, and provide a
binding in there. Then if it becomes popular, it can be promoted to a
global binding.

-- Stephe

reply via email to

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