projectile icon indicating copy to clipboard operation
projectile copied to clipboard

Feature request: Support passing arguments to project type commands

Open Thaodan opened this issue 1 year ago • 4 comments

Use the template below when reporting bugs. Please, make sure that you're running the latest stable Projectile and that the problem you're reporting hasn't been reported (and potentially fixed) already.

Remove all of the placeholder text in your final report!

Expected behavior

Currently a user has to redefine the project command to be able to pass arguments to it, but it would be more useful to have the option to pass arguments to the specific commands in general or per project type.

Like for example for the CMake project type it would be useful to append arguments to the configure command such as -DCMAKE_EXPORT_COMPILE_COMMANDS=YES.

Environment & Version information

Projectile version information

Projectile version: 2.6.0-snapshot

Emacs version

In GNU Emacs 29.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.34, cairo version 1.17.6)

Operating system

Linux odin 5.19.7-pf3-1+ #1 SMP PREEMPT_DYNAMIC Tue Sep 6 17:01:44 EEST 2022 x86_64 GNU/Linux, Arch Linux.

Thaodan avatar Sep 16 '22 20:09 Thaodan

note that for cmake specifically you can use cmake-presets to tailor the project-commands (provided you have a recent enough cmake, which you do on arch). cmake-preset based commands can be enabled via the projectile-enable-cmake-presets variable.

jehelset avatar Sep 17 '22 10:09 jehelset

That is true however that way each project would have to be modified while it is a very generic use case to append user specific options like - DCMAKE_EXPORT_COMPILE_COMMANDS=YES

Thaodan avatar Sep 17 '22 15:09 Thaodan

you can stuff system-wide configurations in f.ex. ~/.config/cmake/presets.json and reuse on a project-level in your user-presets-file with include and inherit. this is not meant to be part of the project or checked into repo.

since cmake doesn't currently try to do any default lookup it does mean that you do need to create a user-config file per project (discussed here), but i almost always want that anyways (and a suitable cookiecutter is easily snippable).

jehelset avatar Sep 17 '22 16:09 jehelset

Currently a user has to redefine the project command to be able to pass arguments to it, but it would be more useful to have the option to pass arguments to the specific commands in general or per project type.

Like for example for the CMake project type it would be useful to append arguments to the configure command such as -DCMAKE_EXPORT_COMPILE_COMMANDS=YES.

Alternatively, to update the configure command for the CMake project type globally you could use projectile-update-project-type:

(defun my-cmake-configure ()
  (concat (projectile--cmake-configure-command) " -DCMAKE_EXPORT_COMPILE_COMMANDS=YES"))

(projectile-update-project-type 
 'cmake
 :configure #'my-cmake-configure)

LaurenceWarne avatar Sep 23 '22 08:09 LaurenceWarne