MhvxvLvJrg · 2022-09-04 17:00
For those who are using the built-in project.el, have you changed the default behaviour upon switching to a project? I have to say that the default menu which asks for \[f\] Find file, \[d\] Find directory, etc. feels a bit slow IMHO. I would rather prefer to automatically open a dired buffer of the project root, open the most recent file, or open the minibuffer to fuzzy search for a file. Any snippet that you can share, so that I don't reinvent the wheel.
eleven_cupfuls · 2022-09-04 17:15
The simplest way to do this I think would be to skip `project-switch-project` and make a new command with an interactive spec that prompts for a project selection, like so:
(defun ml/project-do-something (project)
"Do something awesome in a project.
Prompts for a project if there is no current one."
(interactive (list (project-current t)))
...)
The `t` argument to `project-current` means it will show the project selector if there isn't one. And then just bind this to whatever you want; you could even override the existing `project-switch-project` binding.
In case you are not aware, you can also add your own commands to the project menu; see `project-switch-commands`. There is also the option `project-switch-use-entire-map` which allows anything in `project-prefix-map` to be run when switching.
And finally if you are looking for a project file fuzzy find command, here is one: https://gitlab.com/woolsweater/dotemacs.d/-/blob/c1e3a9c732d89ce0e562946cf924a8cf5aa35828/startup/builtin.el#L452-494 although it probably needs some tweaking for your use. It is pretty tuned to my workflow (and the Mac Port specifically).
TheFrenchPoulp · 2022-09-04 19:34
I use `gp` for `project-switch-project` with the following menu:
'((project-dired "Root" ?D)
(project-find-file "File" ?f)
(magit-project-status "Git" ?g)
(me/project-todo "Todo" ?o)
(me/project-search "Search" ?s)
(widowmaker-terminal-dwim "Terminal" ?t))
The todo command creates or open a `TODO.org` at the project root and the terminal command raise or create a vterm window where `shackle` and `popper` kick in
And `gP` to select a project and land on the magit-status directly. In the past that used to be the find-file command buty usage has evolved with time
hvis · 2022-09-04 21:39
`project-switch-commands` docstring:
> ... The value can also be a symbol, the name of the command to be
invoked immediately without any dispatch menu.
eleven_cupfuls · 2022-09-04 22:06
Oh, very nice. It seems that my project.el is somewhat out of date; I do not have that. But that definitely solves the question.
hvis · 2022-09-04 22:30
The version 0.8.1 includes that change (it's the latest; and it was released a year ago).
You can install it from GNU ELPA.
link0ff · 2022-09-07 18:55
You can bind the default project command to `RET`,
so just `C-x p p RET` will open Dired:
(with-eval-after-load 'project
(define-key project-prefix-map [return] 'project-dired))
JDRiverRun · 2022-09-11 12:37
I wrote [consult-jump-project](https://github.com/jdtsmith/consult-jump-project) to scratch this particular itch. After project selection it pops up recent project files/buffers and a project dired (used for preview) to select among.