alchemist.el icon indicating copy to clipboard operation
alchemist.el copied to clipboard

Suggestion: "simpler" quick navigation for Phoenix files

Open Trevoke opened this issue 8 years ago • 13 comments

I made the same suggestion to projectile-rails. I am fairly confident it made sense for projectile-rails, but here I'm newish to Elixir and Phoenix, and I don't know if my suggestion is reasonable, especially when you consider umbrella projects. In any case --

It would be nice if I could type the keyboard shortcut to find a controller file and just have to type / have the main name autocompleted.

That is, for user_controller.ex, I'd like to just have to type user. Same for the model user.ex (different context / function / keybinding, so I think it's OK).

What do you think?

Trevoke avatar Apr 09 '16 14:04 Trevoke

Personally I use projectile to locate files. This works pretty well for all elixir projects that follows a strict file naming structure.

I would recommend people needing this functionality to checkout Projectile, which is available on melpa.

gausby avatar Apr 09 '16 14:04 gausby

Well -- alchemist already implements this functionality with C-c a n c for controllers, m for models, etc.

On Sat, Apr 9, 2016 at 10:44 AM Martin Gausby [email protected] wrote:

Personally I use projectile to locate files. This works pretty well for all elixir projects that follows a strict file naming structure.

I would recommend people needing this functionality to checkout Projectile, which is available on melpa.

— You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub https://github.com/tonini/alchemist.el/issues/220#issuecomment-207798345

Trevoke avatar Apr 09 '16 15:04 Trevoke

I am sorry I didn't read your issue-description well enough; i see that you suggest something that works with projectile—the very project I suggest checking out :) That is what I get for checking and replying to issues on my phone while riding a train.

gausby avatar Apr 10 '16 16:04 gausby

Well -- alchemist already implements this functionality with C-c a n c for controllers, m for models, etc.

So does that mean that it's already there what you have looking for?

tonini avatar May 25 '16 06:05 tonini

Almost:

Right now I have to type the full file name, e.g. user_controller.ex. I think it would be nice to be able to just type user once we are at the controller selection in the minibuffer.

Trevoke avatar May 25 '16 12:05 Trevoke

@Trevoke I think that is something you need to add to your own Emacs config. I use ido with fuzzy matching myself and I think that I have what you are asking for. Give flx-ido a try.

gausby avatar May 25 '16 12:05 gausby

Hi Martin,

The same suggestion was accepted and implemented by projectile-rails this way: https://github.com/asok/projectile-rails/issues/2 (there is a link to a commit with cucumber scenarios, which might help explain further what I mean).

It's not something that I need to add to my own emacs config; it is a change to the interface presented by alchemist.

Does this explain better what I am asking for?

On Wed, May 25, 2016 at 8:30 AM Martin Gausby [email protected] wrote:

@Trevoke https://github.com/Trevoke I think that is something you need to add to your own Emacs config. I use ido with fuzzy matching myself and I think that I have what you are asking for. Give flx-ido https://github.com/lewang/flx a try.

— You are receiving this because you were mentioned.

Reply to this email directly or view it on GitHub https://github.com/tonini/alchemist.el/issues/220#issuecomment-221559918

Trevoke avatar May 25 '16 23:05 Trevoke

Okay, I think I got it now:

Say we have the following files in /web/controllers/, auth_controller.ex, profile_controller.ex, and page_controller.ex. Currently the interface for jumping to controllers show: /web/controllers/auth_controller.ex, /web/controllers/profile_controller.ex, etc.

You suggest that they should instead be shown as: auth, profile, page, etc.

I guess this would be possible if we can rely on the filenames to follow the _controller convention; but I don't know if we can trust this assumption; the Phoenix router cares about module names, not file names. A given controller could live in a file somewhere outside of the /web/controllers/ path, and end in something different from _controllers.ex.

The models are even worse because they don't have a _model.ex-postfix.

So, we can't rely on controllers being in the controllers-folder; we can't rely on controllers having the _controller.ex post-fix; the only thing we can rely on is the module name and that sounds like a job for the alchemist-server.

@Trevoke Thanks for reporting this. I think it raises some issues that we need to address.

gausby avatar May 26 '16 08:05 gausby

I'm beginning to pick up on some of the older issues to see if I can help with alchemist. To be clear, this issue is still open because we still want to implement that feature, right?

Trevoke avatar Sep 28 '17 11:09 Trevoke

So, we can't rely on controllers being in the controllers-folder; we can't rely on controllers having the _controller.ex post-fix; the only thing we can rely on is the module name and that sounds like a job for the alchemist-server.

But wouldn't it be possible to implement methods that act like projectile-rails-find-current-<X> but fall back to the normal quick navigation when no file following the default naming convention can't be found?

For example: I'm in the buffer for /web/models/user.ex and want to find the corresponding controller. I trigger alchemist-phoenix-find-current-controller and alchemist looks for /web/controller/user_controller.ex (or even after that any file with this name in /controller subfolders or the whole project) and when it can't find the file it falls back to alchemist-phoenix-find-controllers. In the case the fallback gets triggered, it would maybe even make sense to prefill user into the minibuffer of alchemist-phoenix-find-controllers.

fapdash avatar Mar 12 '18 13:03 fapdash

It's possible, but it assumes a naming convention that is not (yet?) established in the Phoenix world.

On Mon, Mar 12, 2018 at 9:50 AM, FAP [email protected] wrote:

So, we can't rely on controllers being in the controllers-folder; we can't rely on controllers having the _controller.ex post-fix; the only thing we can rely on is the module name and that sounds like a job for the alchemist-server.

But wouldn't it be possible to implement methods that act like projectile-rails-find-current-<X> but fall back to the normal quick navigation when no file following the default naming convention can't be found?

For example: I'm in the buffer for /web/models/user.ex and want to find the corresponding controller. I trigger alchemist-phoenix-find- current-controller and alchemist looks for /web/controller/user_ controller.ex (or even after that any file with this name in /controller subfolders or the whole project) and when it can't find the file it falls back to alchemist-phoenix-find-controllers. In the case the fallback gets triggered, it would maybe even make sense to prefill user into the minibuffer of alchemist-phoenix-find-controllers.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/tonini/alchemist.el/issues/220#issuecomment-372315914, or mute the thread https://github.com/notifications/unsubscribe-auth/AAEJSS6nPIIudJ0Ey8nAzVSzUk5B_ZlTks5tdn0ugaJpZM4IDoAd .

Trevoke avatar Mar 14 '18 01:03 Trevoke

…and considering that the layout of a phoenix project has changed since this thread was started.

I still think the framework specific features of alchemist should get pulled into their own Emacs packages (alchemist-phoenix, alchemist-nerves, etc). Other than that I have no stakes in this.

gausby avatar Mar 14 '18 09:03 gausby

I think that's reasonable.

On Wed, Mar 14, 2018, 05:49 Martin Gausby [email protected] wrote:

…and considering that the layout of a phoenix project has changed since this thread was started.

I still think the framework specific features of alchemist should get pulled into their own Emacs packages (alchemist-phoenix, alchemist-nerves, etc). Other than that I have no stakes in this.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/tonini/alchemist.el/issues/220#issuecomment-372962954, or mute the thread https://github.com/notifications/unsubscribe-auth/AAEJSZj9kA9CRGChfT_qTwzf6QlnkTpMks5teOe0gaJpZM4IDoAd .

Trevoke avatar Mar 14 '18 11:03 Trevoke