Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15352122
D21147.id50356.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
5 KB
Referenced Files
None
Subscribers
None
D21147.id50356.diff
View Options
diff --git a/src/applications/settings/setting/PhabricatorEditorSetting.php b/src/applications/settings/setting/PhabricatorEditorSetting.php
--- a/src/applications/settings/setting/PhabricatorEditorSetting.php
+++ b/src/applications/settings/setting/PhabricatorEditorSetting.php
@@ -26,7 +26,7 @@
"\n\n".
"Provide a URI pattern for building external editor URIs in your ".
"environment. For example, if you use TextMate on macOS, the pattern ".
- "for your machine look like this:".
+ "for your machine may look something like this:".
"\n\n".
"```name=\"Example: TextMate on macOS\"\n".
"%s\n".
@@ -36,7 +36,7 @@
"see **[[ %s | %s ]]**.".
"\n\n".
"See the tables below for a list of supported variables and protocols.",
- 'txmt://open/?url=file:///Users/alincoln/editor_links/%r/%f&line=%l',
+ 'txmt://open/?url=file:///Users/alincoln/editor_links/%n/%f&line=%l',
PhabricatorEnv::getDoclink('User Guide: Configuring an External Editor'),
pht('User Guide: Configuring an External Editor'));
}
diff --git a/src/docs/user/userguide/external_editor.diviner b/src/docs/user/userguide/external_editor.diviner
--- a/src/docs/user/userguide/external_editor.diviner
+++ b/src/docs/user/userguide/external_editor.diviner
@@ -6,8 +6,10 @@
Overview
========
-You can configure a URI handler to allow you to open files from Differential
-and Diffusion in your preferred text editor.
+You can configure a URI handler to allow you to open files referenced in
+Differential and Diffusion in your preferred text editor on your local
+machine.
+
Configuring Editors
===================
@@ -17,28 +19,60 @@
will enable an "Open in Editor" link in Differential, and an "Edit" button in
Diffusion.
-In general, you'll set this field to something like:
+In general, you'll set this field to something like this, although the
+particular pattern to use depends on your editor and environment:
```lang=uri
editor://open/?file=%f
```
+
+Mapping Repositories
+====================
+
+When you open a file in an external editor, Phabricator needs to be able to
+build a URI which includes the correct absolute path on disk to the local
+version of the file, including the repository directory.
+
+If all your repositories are named consistently in a single directory, you
+may be able to use the `%n` (repository short name) variable to do this.
+For example:
+
+```lang=uri
+editor://open/?file=/Users/alice/repositories/%n/%f
+```
+
+If your repositories aren't named consistently or aren't in a single location,
+you can build a local directory of symlinks which map a repositoriy identifier
+to the right location on disk:
+
+```
+/Users/alice/editor_links/ $ ls -l
+... search-service/ -> /Users/alice/backend/search/
+... site-templates/ -> /Users/alice/frontend/site/
+```
+
+Then use this directory in your editor URI:
+
+```lang=uri
+editor://open/?file=/Users/alice/editor_links/%n/%f
+```
+
+Instead of `%n` (repository short name), you can also use `%d` (repository ID)
+or `%p` (repository PHID). These identifiers are immutable and all repositories
+always have both identifiers, but they're less human-readable.
+
+
Configuring: TextMate on macOS
==============================
TextMate installs a `txmt://` handler by default, so it's easy to configure
this feature if you use TextMate.
-First, create a local directory with symlinks for each repository callsign. For
-example, if you're developing Phabricator, it might look like this:
-
- /Users/alincoln/editor_links/ $ ls -l
- ... ARC -> /Users/alincoln/workspace/arcanist/
- ... P -> /Users/alincoln/workspace/phabricator/
- ... PHU -> /Users/alincoln/workspace/libphutil/
-
-Then set your "Editor Link" to:
+First, identify the parent directory where your repositories are stored
+(for example, `/Users/alice/repositories/`). Then, configure your editor
+pattern like this:
```lang=uri
-txmt://open/?url=file:///Users/alincoln/editor_links/%r/%f&line=%l
+txmt://open/?url=file:///Users/alice/repositories/%n/%f&line=%l
```
diff --git a/src/infrastructure/editor/PhabricatorEditorURIEngine.php b/src/infrastructure/editor/PhabricatorEditorURIEngine.php
--- a/src/infrastructure/editor/PhabricatorEditorURIEngine.php
+++ b/src/infrastructure/editor/PhabricatorEditorURIEngine.php
@@ -90,14 +90,6 @@
public static function getVariableDefinitions() {
return array(
- '%' => array(
- 'name' => pht('Literal Percent Symbol'),
- 'example' => '%',
- ),
- 'r' => array(
- 'name' => pht('Repository Callsign'),
- 'example' => 'XYZ',
- ),
'f' => array(
'name' => pht('File Name'),
'example' => pht('path/to/source.c'),
@@ -106,6 +98,26 @@
'name' => pht('Line Number'),
'example' => '777',
),
+ 'n' => array(
+ 'name' => pht('Repository Short Name'),
+ 'example' => 'arcanist',
+ ),
+ 'd' => array(
+ 'name' => pht('Repository ID'),
+ 'example' => '42',
+ ),
+ 'p' => array(
+ 'name' => pht('Repository PHID'),
+ 'example' => 'PHID-REPO-abcdefghijklmnopqrst',
+ ),
+ 'r' => array(
+ 'name' => pht('Repository Callsign'),
+ 'example' => 'XYZ',
+ ),
+ '%' => array(
+ 'name' => pht('Literal Percent Symbol'),
+ 'example' => '%',
+ ),
);
}
@@ -119,6 +131,9 @@
$variables = array(
'r' => $this->escapeToken($repository->getCallsign()),
+ 'n' => $this->escapeToken($repository->getRepositorySlug()),
+ 'd' => $this->escapeToken($repository->getID()),
+ 'p' => $this->escapeToken($repository->getPHID()),
);
return $this->newTokensWithVariables($tokens, $variables);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Mar 11, 4:12 PM (1 w, 3 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7341827
Default Alt Text
D21147.id50356.diff (5 KB)
Attached To
Mode
D21147: Add "short name", "id", and "phid" variables for external editor URIs
Attached
Detach File
Event Timeline
Log In to Comment