diff --git a/src/console/PhutilInteractiveEditor.php b/src/console/PhutilInteractiveEditor.php --- a/src/console/PhutilInteractiveEditor.php +++ b/src/console/PhutilInteractiveEditor.php @@ -22,6 +22,7 @@ private $offset = 0; private $preferred; private $fallback; + private $taskMessage; /* -( Creating a New Editor )---------------------------------------------- */ @@ -74,6 +75,18 @@ $editor = $this->getEditor(); $offset = $this->getLineOffset(); + $binary = basename($editor); + + $task_message = $this->getTaskMessage(); + if ($task_message !== null) { + // This message is primarily an assistance to users with GUI-based + // editors configured. Users with terminal-based editors won't have a + // chance to see this prior to the editor being launched. + echo tsprintf(pht("Launching editor '%s' for task: %s\n", + $binary, + $task_message)); + } + $err = $this->invokeEditor($editor, $path, $offset); if ($err) { @@ -85,7 +98,6 @@ 'vim' => true, ); - $binary = basename($editor); if (isset($vi_binaries[$binary])) { // This runs "Q" (an invalid command), then "q" (a valid command, // meaning "quit"). Vim binaries with behavior that makes them poor @@ -266,6 +278,40 @@ return $this; } + /** + * Set the message that identifies the task for which the editor is being + * launched. This message appears to the user just prior to the editor being + * launched. This message should be in statement form, such as "Edit commit + * message.", including the ending punctuation. This is displayed in the form + * "Launching editor 'vim' for task: Edit commit message.". If no message is + * set then nothing will be displayed to the user just prior to launching the + * editor. + * + * @param string The message to display to the user. + * @return $this + * + * @task config + */ + public function setTaskMessage($task_message) { + $this->taskMessage = $task_message; + return $this; + } + + /** + * Retrieve the current message that will display to the user just prior to + * invoking the editor. This is only a brief message identifying why the + * editor is being used, and does not include the full description of what + * displays to the user. See @{method:setTaskMessage} for more information. + * + * @return string The message that will display to the user, or null if no + * message will be displayed. + * + * @task config + */ + public function getTaskMessage() { + return $this->taskMessage; + } + /** * Get the name of the editor program to use. The value of the environmental diff --git a/src/workflow/ArcanistDiffWorkflow.php b/src/workflow/ArcanistDiffWorkflow.php --- a/src/workflow/ArcanistDiffWorkflow.php +++ b/src/workflow/ArcanistDiffWorkflow.php @@ -674,6 +674,7 @@ if ($should_edit) { $edited = $this->newInteractiveEditor($remote_corpus) ->setName('differential-edit-revision-info') + ->setTaskMessage(pht('Edit revision information.')) ->editInteractively(); if ($edited != $remote_corpus) { $remote_corpus = $edited; @@ -1476,6 +1477,7 @@ } else { $new_template = $this->newInteractiveEditor($template) ->setName('new-commit') + ->setTaskMessage(pht('Edit new revision information.')) ->editInteractively(); } $first = false; @@ -1752,6 +1754,7 @@ $comments = $this->newInteractiveEditor($template) ->setName('differential-update-comments') + ->setTaskMessage(pht('Update revision comments.')) ->editInteractively(); return $comments; diff --git a/src/workflow/ArcanistPatchWorkflow.php b/src/workflow/ArcanistPatchWorkflow.php --- a/src/workflow/ArcanistPatchWorkflow.php +++ b/src/workflow/ArcanistPatchWorkflow.php @@ -909,6 +909,7 @@ $commit_message = $this->newInteractiveEditor($template) ->setName('arcanist-patch-commit-message') + ->setTaskMessage(pht('Supply commit message for patch.')) ->editInteractively(); $commit_message = ArcanistCommentRemover::removeComments($commit_message); diff --git a/src/workflow/ArcanistWorkflow.php b/src/workflow/ArcanistWorkflow.php --- a/src/workflow/ArcanistWorkflow.php +++ b/src/workflow/ArcanistWorkflow.php @@ -1234,6 +1234,8 @@ $commit_message = $this->newInteractiveEditor($template) ->setName(pht('commit-message')) + ->setTaskMessage(pht( + 'Supply commit message for uncommitted changes.')) ->editInteractively(); if ($commit_message === $template) {