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

Add a hook triggered before each run of P4 command #210

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

thekondor
Copy link

Motivation: be able to run project's configuration commands before P4 command is executed.
Example:

  • Automatically deduce current workspace (e.g. based on buffer's directory) and set ${P4CLIENT} environment variable up;
  • Keep a history of run P4 commands.

Andrew Sichevoi and others added 3 commits April 7, 2015 08:34
…time before 'p4' is command executed. The hook is useful for dynamic environment setup.
…before 'p4' is command executed. The hook is useful for dynamic environment setup.
@gareth-rees
Copy link
Owner

  1. It's already possible to work with multiple client workspaces by setting the P4CONFIG environment variable and putting a configuration file in each workspace. This mechanism has the advantage of being supported by Perforce, and it works from the shell, or from P4V, whereas a hook function in Emacs only works inside Emacs. Can you explain why P4CONFIG doesn't work for you?
  2. Can you explain why you need a history of Perforce commands?
  3. There's already a hook p4-modify-args-function which is called every time the p4 client is run. You could supply a function that modifies the arguments to add the appropriate -c flag to override the client workspace, or that saves the arguments in a history list. Can you explain why this doesn't work for your use case?

@thekondor
Copy link
Author

Hi,

  • I am fully aware of P4CONFIG, and it works like a charm when there is not too many active workspaces. Due to the environment I might have at least 10 active workspaces per day; they also can belong to various Perforce servers (actually, the difference goes by TCP ports, but doesn't matter). Maintenance of P4CONFIG becomes a bit tedious; it is much easier to have a script that deduces a right workspace for you to set the right P4CLIENT up.
  • In the case of similar merges in several workspaces. But that is a minor case for me, just an example of the possible usage. The main case is n.1.
  • As far as I remember, p4-modify-args-function does work in the context of newly created buffer intended for p4 command output. So there is no way to get a full path of the target buffer. I will be happy if I am wrong at this point, please correct me.

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

Successfully merging this pull request may close these issues.

2 participants