Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom command on file saving #425

Open
Flamaros opened this issue Sep 20, 2024 · 4 comments
Open

Custom command on file saving #425

Flamaros opened this issue Sep 20, 2024 · 4 comments

Comments

@Flamaros
Copy link

It would pretty nice to be able to execute custom command just before the file saving to be able to checkout the file on perforce by exemple.

Maybe some users may want to do this by file extensions for commands like linters, but for me it's more by project and if file is in read only state (I may check that in the custom command directly).

Some other features might helps here, like an easy way to copy the full path of the currently edited file.

@focus-editor
Copy link
Owner

There's currently a command Copy Current Line Info which copies the full path and the line number.

Would something like this be what you want?

[[hooks]]

[before save]
command:   ...
working_dir: ...
files: *.cpp *.h

[after save]
command:   ...
working_dir: ...
files: *.cpp *.h

@Flamaros
Copy link
Author

Thx to point me the command for the line info.

Yes the format of hooks seems good, but I think that we also need some variables like:
$relative_file_path (relative to the project path of file to save ?)
$full_file_path (full path of file to save
$working_directory
$project_directory

Ex.

[[hooks]]

[before save]
command:   p4 synchronize $full_file_path
working_dir: $project_directory
files: *.cpp *.h

@focus-editor
Copy link
Owner

It will probably be a while before we get to this because there are other things higher up on the list.

Did you know you could use the build command system to achieve the same effect, with the only difference is that it would not auto-run on save but that you'd need to bind it to a key combination and execute explicitly?

There are variables available there already:

# %FILE%      - full path to currenly active file
# %FILE_DIR%  - the directory of the currently active file
# %FILE_NAME% - current file name, with extension
# %FILE_NAME_NO_EXTENSION% - current file name, without extension
# %BUILD_WORKING_DIR%  - working dir of the build command
# %RUN_WORKING_DIR%    - working dir of the run command
# %PROJECT_CONFIG_DIR% - the dir containing the active project config file

@Flamaros
Copy link
Author

I tried that, on a personal project to trigger build, the navigation through errors is nice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants