emacs-devel
[Top][All Lists]
Advanced

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

Re: Comparison of tools to search for related files


From: Stefan Monnier
Subject: Re: Comparison of tools to search for related files
Date: Tue, 06 Sep 2022 08:52:30 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux)

Emanuel Berg [2022-09-06 06:45:30] wrote:

> Stefan Monnier wrote:
>
>>
>> But I keep dreaming of a tool that doesn't require *any*
>> setup at all. In my ideal world, from a `MyComponent.js` I'd
>> be able to type `M-x find-file-dwim RET .le RET` and that
>> would jump to `MyComponent.less`.
>>
>> Or from `/opt/emacs-27/lisp/subr.el` I'd type `M-x
>> find-file-dwim RET 28 RET` and that'd jump to
>> `/opt/emacs-28/lisp/subr.el`.
>>
>> Maybe also:
>>
>>     /foo/lisp/toto.el      +  test     =>  /foo/tests/lisp/toto.el
>>     /foo/bar/lisp/toto.el  +  baz      =>  /foo/bazaar/toto.el
>>     /foo/lisp/toto.el      +  te/-te   =>  /foo/test/lisp/toto-tests.el
>
> One would then have several algorithms all intended to find
> one file from another, but using different methods, and the
> DWIM algorithm would try them one by one ...

No, I'm thinking of the DWIM algorithm as a single one.

It takes a file name FN considers it as a concatenation of PREFIX + STR +
SUFFIX and looks for a file that matches PREFIX + TXT + * + SUFFIX

And if TXT has a slash then the slash decomposes TXT into several such
sub-cases.

The hard part is that we're not told which part is PREFIX and which part
is SUFFIX, so we'd have to use `directory-files` looking for files that
match TXT and filter these matches according to whether they can be
treated as PREFIX + TXT + * + SUFFIX.


        Stefan




reply via email to

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